├── .commitlintrc.json ├── .env.sample ├── .eslintrc.json ├── .github ├── actions │ └── setup-node │ │ └── action.yml └── workflows │ ├── code-style-reusable.yml │ ├── code-style.yml │ ├── commit-lint-reusable.yml │ ├── commit-lint.yml │ ├── release.yml │ ├── test-reusable.yml │ └── test.yml ├── .gitignore ├── .husky ├── commit-msg └── pre-commit ├── .nvmrc ├── .prettierrc ├── .releaserc ├── .taprc ├── CHANGELOG.md ├── EXAMPLES_API.md ├── EXAMPLES_CLI.md ├── LICENSE ├── README.md ├── commitlint.config.js ├── examples ├── README.md ├── create_deployment.ts ├── create_wallet.ts ├── details_of_single_provider.ts ├── estimate_gas.ts ├── fixtures │ └── example.sdl.yaml ├── get_deployments.ts ├── get_lease_status.ts ├── get_state.ts ├── list_all_providers.ts ├── signed_message.ts ├── signed_msg_send.ts ├── take_down_deployment.ts └── tsconfig.json ├── jest.config.js ├── package-lock.json ├── package.json ├── src ├── certificates │ ├── certificate-manager │ │ ├── CertificateManager.spec.ts │ │ ├── CertificateManager.ts │ │ └── index.ts │ ├── generate509 │ │ ├── generate509.spec.ts │ │ ├── generate509.ts │ │ └── index.ts │ └── index.ts ├── config │ └── network.ts ├── error │ ├── SdlValidationError.ts │ ├── ValidationError.ts │ └── index.ts ├── index.ts ├── keplr │ └── index.ts ├── network │ └── index.ts ├── pbclient │ ├── pbclient.spec.ts │ └── pbclient.ts ├── protobuf │ ├── akash │ │ ├── audit │ │ │ ├── v1beta1 │ │ │ │ ├── audit.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ │ ├── v1beta2 │ │ │ │ ├── audit.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ │ └── v1beta3 │ │ │ │ ├── audit.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ ├── base │ │ │ ├── v1beta1 │ │ │ │ ├── attribute.ts │ │ │ │ ├── endpoint.ts │ │ │ │ ├── resource.ts │ │ │ │ └── resourcevalue.ts │ │ │ ├── v1beta2 │ │ │ │ ├── attribute.ts │ │ │ │ ├── endpoint.ts │ │ │ │ ├── resource.ts │ │ │ │ ├── resourceunits.ts │ │ │ │ └── resourcevalue.ts │ │ │ └── v1beta3 │ │ │ │ ├── attribute.ts │ │ │ │ ├── cpu.ts │ │ │ │ ├── endpoint.ts │ │ │ │ ├── gpu.ts │ │ │ │ ├── memory.ts │ │ │ │ ├── resources.ts │ │ │ │ ├── resourceunits.ts │ │ │ │ ├── resourcevalue.ts │ │ │ │ └── storage.ts │ │ ├── cert │ │ │ ├── v1beta1 │ │ │ │ ├── cert.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ │ ├── v1beta2 │ │ │ │ ├── cert.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ │ └── v1beta3 │ │ │ │ ├── cert.ts │ │ │ │ ├── genesis.ts │ │ │ │ └── query.ts │ │ ├── deployment │ │ │ ├── v1beta1 │ │ │ │ ├── authz.ts │ │ │ │ ├── deployment.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── group.ts │ │ │ │ ├── params.ts │ │ │ │ └── query.ts │ │ │ ├── v1beta2 │ │ │ │ ├── authz.ts │ │ │ │ ├── deployment.ts │ │ │ │ ├── deploymentmsg.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── group.ts │ │ │ │ ├── groupid.ts │ │ │ │ ├── groupmsg.ts │ │ │ │ ├── groupspec.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ ├── resource.ts │ │ │ │ └── service.ts │ │ │ └── v1beta3 │ │ │ │ ├── authz.ts │ │ │ │ ├── deployment.ts │ │ │ │ ├── deploymentmsg.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── group.ts │ │ │ │ ├── groupid.ts │ │ │ │ ├── groupmsg.ts │ │ │ │ ├── groupspec.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ ├── resource.ts │ │ │ │ ├── resourceunit.ts │ │ │ │ └── service.ts │ │ ├── escrow │ │ │ ├── v1beta1 │ │ │ │ ├── genesis.ts │ │ │ │ ├── query.ts │ │ │ │ └── types.ts │ │ │ ├── v1beta2 │ │ │ │ ├── genesis.ts │ │ │ │ ├── query.ts │ │ │ │ └── types.ts │ │ │ └── v1beta3 │ │ │ │ ├── genesis.ts │ │ │ │ ├── query.ts │ │ │ │ └── types.ts │ │ ├── gov │ │ │ └── v1beta3 │ │ │ │ ├── genesis.ts │ │ │ │ └── params.ts │ │ ├── icaauth │ │ │ ├── query.ts │ │ │ └── tx.ts │ │ ├── inflation │ │ │ ├── v1beta2 │ │ │ │ ├── genesis.ts │ │ │ │ └── params.ts │ │ │ └── v1beta3 │ │ │ │ ├── genesis.ts │ │ │ │ └── params.ts │ │ ├── market │ │ │ ├── v1beta1 │ │ │ │ ├── bid.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── lease.ts │ │ │ │ ├── order.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ └── service.ts │ │ │ ├── v1beta2 │ │ │ │ ├── bid.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── lease.ts │ │ │ │ ├── order.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ └── service.ts │ │ │ ├── v1beta3 │ │ │ │ ├── bid.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── lease.ts │ │ │ │ ├── order.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ └── service.ts │ │ │ └── v1beta4 │ │ │ │ ├── bid.ts │ │ │ │ ├── genesis.ts │ │ │ │ ├── lease.ts │ │ │ │ ├── order.ts │ │ │ │ ├── params.ts │ │ │ │ ├── query.ts │ │ │ │ └── service.ts │ │ ├── provider │ │ │ ├── v1beta1 │ │ │ │ ├── genesis.ts │ │ │ │ ├── provider.ts │ │ │ │ └── query.ts │ │ │ ├── v1beta2 │ │ │ │ ├── genesis.ts │ │ │ │ ├── provider.ts │ │ │ │ └── query.ts │ │ │ └── v1beta3 │ │ │ │ ├── genesis.ts │ │ │ │ ├── provider.ts │ │ │ │ └── query.ts │ │ ├── staking │ │ │ └── v1beta3 │ │ │ │ ├── genesis.ts │ │ │ │ └── params.ts │ │ └── take │ │ │ └── v1beta3 │ │ │ ├── genesis.ts │ │ │ ├── params.ts │ │ │ └── query.ts │ ├── cosmos │ │ └── base │ │ │ ├── query │ │ │ └── v1beta1 │ │ │ │ └── pagination.ts │ │ │ └── v1beta1 │ │ │ └── coin.ts │ ├── cosmos_proto │ │ └── cosmos.ts │ ├── gogoproto │ │ └── gogo.ts │ ├── google │ │ ├── api │ │ │ ├── annotations.ts │ │ │ └── http.ts │ │ └── protobuf │ │ │ ├── any.ts │ │ │ └── descriptor.ts │ └── typeRegistry.ts ├── rpc │ └── index.ts ├── sdl │ ├── SDL │ │ ├── SDL.spec.ts │ │ └── SDL.ts │ ├── index.ts │ ├── sizes.ts │ └── types.ts ├── stargate │ └── index.ts ├── types │ ├── global.d.ts │ └── network.ts ├── util.ts ├── wallet │ ├── index.ts │ └── storage.ts └── webpack │ ├── crypto.ts │ └── perf_hooks.ts ├── tap-snapshots └── tests │ ├── test_deployments.ts.test.cjs │ ├── test_sdl_gpu.ts.test.cjs │ ├── test_sdl_gpu_ram.ts.test.cjs │ ├── test_sdl_gpu_vendor_only.ts.test.cjs │ ├── test_sdl_ip_lease.ts.test.cjs │ ├── test_sdl_v3_resources.ts.test.cjs │ └── test_sdl_wordpress.ts.test.cjs ├── test.html ├── test ├── fixtures │ ├── groups-basic-snapshot.json │ ├── manifest-basic-snapshot.json │ └── sdl-basic.json ├── setup-unit-tests.ts ├── setup.ts └── templates.ts ├── tests ├── __snapshots__ │ ├── sdl_gpu_ram_interface.spec.ts.snap │ └── sdl_persistent_storage_attributes.spec.ts.snap ├── fixtures │ ├── gpu_basic.manifest.json │ ├── gpu_basic.sdl.yml │ ├── gpu_basic_no_model.sdl.yml │ ├── gpu_basic_ram.manifest.json │ ├── gpu_basic_ram.sdl.yml │ ├── gpu_basic_ram_interface.manifest.json │ ├── gpu_basic_ram_interface.sdl.yml │ ├── gpu_invalid_interface.sdl.yml │ ├── gpu_invalid_no_attributes.sdl.yml │ ├── gpu_invalid_no_vendor.sdl.yml │ ├── gpu_invalid_no_vendor_name.sdl.yml │ ├── gpu_invalid_vendor.sdl.yml │ ├── gpu_no_gpu_invalid_has_attributes.sdl.yml │ ├── gpu_no_gpu_valid.sdl.yml │ ├── ip_lease_valid.sdl.yml │ ├── persistent_storage_invalid.sdl.yml │ ├── persistent_storage_valid.sdl.yml │ ├── wordpress.manifest.json │ └── wordpress.sdl.yml ├── sdl_gpu_invalid_vendor.spec.ts ├── sdl_gpu_ram_interface.spec.ts ├── sdl_persistent_storage_attributes.spec.ts ├── test_deployments.ts ├── test_sdl_basic.ts ├── test_sdl_basic_beta3.ts ├── test_sdl_empty_profile.ts ├── test_sdl_env.ts ├── test_sdl_gpu.ts ├── test_sdl_gpu_attributes.ts ├── test_sdl_gpu_ram.ts ├── test_sdl_gpu_vendor_only.ts ├── test_sdl_httpopts.ts ├── test_sdl_ip_lease.ts ├── test_sdl_sweeper.ts ├── test_sdl_v3_resources.ts ├── test_sdl_wordpress.ts └── util.ts ├── tsconfig.build.json ├── tsconfig.json └── webpack.config.js /.commitlintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": ["@commitlint/config-conventional"], 3 | "rules": { 4 | "scope-enum": [2, "always", ["certificates", "network", "wallet", "api", "stargate", "sdl", "examples"]] 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.env.sample: -------------------------------------------------------------------------------- 1 | MNEMONIC='' -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "ignorePatterns": ["node_modules/", "build/", "umd/"], 3 | "env": { 4 | "node": true, 5 | "es2021": true 6 | }, 7 | "extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"], 8 | "parser": "@typescript-eslint/parser", 9 | "parserOptions": { 10 | "ecmaVersion": "latest", 11 | "sourceType": "module" 12 | }, 13 | "plugins": ["@typescript-eslint"], 14 | "rules": { 15 | "@typescript-eslint/no-unused-vars": ["error", { "ignoreRestSiblings": true }], 16 | "@typescript-eslint/no-explicit-any": "warn" 17 | }, 18 | "overrides": [ 19 | { 20 | "files": ["*.js"], 21 | "rules": { 22 | "@typescript-eslint/no-var-requires": "off" 23 | } 24 | } 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /.github/actions/setup-node/action.yml: -------------------------------------------------------------------------------- 1 | name: 'Setup Node.js and Cache Dependencies' 2 | description: 'Checks out code, sets up Node.js, installs dependencies, and handles caching' 3 | 4 | inputs: 5 | node-version: 6 | description: 'Node.js version to setup' 7 | required: true 8 | default: 'v20.11.1' 9 | 10 | runs: 11 | using: 'composite' 12 | steps: 13 | - name: Setup Node.js 14 | uses: actions/setup-node@v4 15 | with: 16 | node-version: ${{ inputs.node-version }} 17 | 18 | - name: Restore node_modules cache 19 | id: deps-cache 20 | uses: martijnhols/actions-cache/restore@v3 21 | with: 22 | path: node_modules 23 | key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('package-lock.json') }} 24 | 25 | - name: Install dependencies 26 | if: steps.deps-cache.outputs.cache-hit != 'true' 27 | shell: bash 28 | run: npm install 29 | 30 | - name: Cache node modules 31 | if: steps.deps-cache.outputs.cache-hit != 'true' 32 | uses: martijnhols/actions-cache/save@v3 33 | with: 34 | path: node_modules 35 | key: ${{ runner.os }}-build-ts-deps-cache-${{ hashFiles('package-lock.json') }} -------------------------------------------------------------------------------- /.github/workflows/code-style-reusable.yml: -------------------------------------------------------------------------------- 1 | name: Code Style 2 | 3 | on: 4 | - workflow_call 5 | 6 | env: 7 | HUSKY: 0 8 | 9 | jobs: 10 | lint: 11 | name: Lint 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup Node.js and Cache Dependencies 18 | uses: ./.github/actions/setup-node 19 | 20 | - name: Lint 21 | run: npm run lint -------------------------------------------------------------------------------- /.github/workflows/code-style.yml: -------------------------------------------------------------------------------- 1 | name: Code Style 2 | 3 | on: 4 | - pull_request 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | code-style: 12 | name: Code Style 13 | uses: ./.github/workflows/code-style-reusable.yml 14 | secrets: inherit 15 | -------------------------------------------------------------------------------- /.github/workflows/commit-lint-reusable.yml: -------------------------------------------------------------------------------- 1 | name: Commit Lint 2 | 3 | on: 4 | - workflow_call 5 | 6 | env: 7 | HUSKY: 0 8 | 9 | jobs: 10 | commit-lint: 11 | name: Validate PR commits with commitlint 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Validate PR commits with commitlint 18 | uses: wagoid/commitlint-github-action@v6 19 | 20 | -------------------------------------------------------------------------------- /.github/workflows/commit-lint.yml: -------------------------------------------------------------------------------- 1 | name: Commit Lint 2 | 3 | on: 4 | - pull_request 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | commit-lint: 12 | name: Commit Lint 13 | uses: ./.github/workflows/commit-lint-reusable.yml 14 | secrets: inherit -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release from Master on Push 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | env: 13 | HUSKY: 0 14 | 15 | jobs: 16 | commit-lint: 17 | name: Commit Lint 18 | uses: ./.github/workflows/commit-lint-reusable.yml 19 | secrets: inherit 20 | 21 | code-style: 22 | name: Code Style 23 | uses: ./.github/workflows/code-style-reusable.yml 24 | secrets: inherit 25 | 26 | test: 27 | name: Run tests and report coverage 28 | uses: ./.github/workflows/test-reusable.yml 29 | secrets: inherit 30 | 31 | release: 32 | name: Build and release npm package 33 | needs: [commit-lint, code-style, test] 34 | runs-on: ubuntu-latest 35 | permissions: 36 | contents: write 37 | issues: write 38 | pull-requests: write 39 | id-token: write 40 | steps: 41 | - name: Checkout 42 | uses: actions/checkout@v4 43 | 44 | - name: Setup Node.js and Cache Dependencies 45 | uses: ./.github/actions/setup-node 46 | 47 | - name: Release npm package 48 | env: 49 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 50 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} 51 | run: npx semantic-release 52 | 53 | -------------------------------------------------------------------------------- /.github/workflows/test-reusable.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | - workflow_call 5 | 6 | env: 7 | HUSKY: 0 8 | 9 | jobs: 10 | test: 11 | name: Test and report coverage 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Setup Node.js and Cache Dependencies 18 | uses: ./.github/actions/setup-node 19 | 20 | - name: Install dependencies 21 | if: steps.deps-cache.outputs.cache-hit != 'true' 22 | run: npm install 23 | 24 | - name: Test 25 | run: npm run test:cov 26 | 27 | - name: Upload Test Coverage 28 | uses: codecov/codecov-action@v4 29 | with: 30 | files: ./ts/coverage 31 | token: ${{ secrets.CODECOV_TOKEN }} 32 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | - pull_request 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | test: 12 | name: Test 13 | uses: ./.github/workflows/test-reusable.yml 14 | secrets: inherit 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node.js dependencies 2 | node_modules/ 3 | 4 | # Build outputs 5 | build/ 6 | umd/ 7 | 8 | # Coverage directory 9 | .nyc_output/ 10 | coverage 11 | 12 | # Log files 13 | yarn-error.log 14 | 15 | # OS-generated files 16 | .DS_Store 17 | 18 | # IDE-specific directories 19 | .idea/ 20 | .vscode/ 21 | 22 | # Tests artifacts 23 | .coverage/ 24 | coverage/ 25 | 26 | .env 27 | cert.json 28 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | npx --no -- commitlint --edit $1 2 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | node_modules/.bin/lint-staged 2 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v18.17.0 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 160, 3 | "tabWidth": 2, 4 | "useTabs": false, 5 | "semi": true, 6 | "quoteProps": "as-needed", 7 | "jsxSingleQuote": false, 8 | "jsxBracketSameLine": false, 9 | "trailingComma": "none", 10 | "requirePragma": false, 11 | "insertPragma": false, 12 | "singleQuote": false, 13 | "arrowParens": "avoid", 14 | "endOfLine": "crlf", 15 | "htmlWhitespaceSensitivity": "strict" 16 | } 17 | -------------------------------------------------------------------------------- /.releaserc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "@semantic-release/commit-analyzer", 4 | "@semantic-release/release-notes-generator", 5 | [ 6 | "@semantic-release/changelog", 7 | { 8 | "changelogFile": "CHANGELOG.md" 9 | } 10 | ], 11 | [ 12 | "@semantic-release/npm", 13 | { 14 | "tarballDir": "package" 15 | } 16 | ], 17 | [ 18 | "@semantic-release/github", 19 | { 20 | "assets": "package/*.tgz" 21 | } 22 | ], 23 | "@semantic-release/git" 24 | ], 25 | "branches": [ 26 | { 27 | "name": "main" 28 | } 29 | ], 30 | "preset": "conventionalcommits" 31 | } 32 | -------------------------------------------------------------------------------- /.taprc: -------------------------------------------------------------------------------- 1 | branches: 0 2 | functions: 0 3 | lines: 0 4 | statements: 0 -------------------------------------------------------------------------------- /EXAMPLES_API.md: -------------------------------------------------------------------------------- 1 | ### Broadcast a Deploy Certificate to the Chain 2 | 3 | ```typescript 4 | import { certificate as akashCertificate, keplr } from "@akashnetwork/akashjs"; 5 | 6 | const chain = keplr.getChains().testnet; 7 | const signer = await keplr.getSigner(chain); 8 | const client = await keplr.get(chain, signer); 9 | const accounts = await signer.getAccounts(); 10 | 11 | try { 12 | const myAddress = accounts[0].address; 13 | 14 | const pems: akashCertificate.pems = await akashCertificate.createCertificate( 15 | myAddress 16 | ); 17 | 18 | akashCertificate.broadcastCertificate( 19 | { csr: pems.csr, publicKey: pems.publicKey }, 20 | myAddress, 21 | client 22 | ); 23 | } catch (error) { 24 | console.log(`Akash Transport : ${error.message}`); 25 | } 26 | ``` 27 | -------------------------------------------------------------------------------- /EXAMPLES_CLI.md: -------------------------------------------------------------------------------- 1 | ## CLI 2 | 3 | ### Getting Started 4 | 5 | ```bash 6 | ➜ npm i -g @akashnetwork/akashjs 7 | ➜ akjs 8 | version: 0.0.7 9 | ``` 10 | 11 | ### Setting up a Wallet 12 | 13 | On NodeJS these keys are stored using `keytar`, which requires `libsecret` be installed on Linux. 14 | 15 | ``` 16 | Debian/Ubuntu: sudo apt-get install libsecret-1-dev 17 | Red Hat-based: sudo yum install libsecret-devel 18 | Arch Linux: sudo pacman -S libsecret 19 | ``` 20 | 21 | ```bash 22 | ➜ akjs wallet create mypassword mypassword 23 | { 24 | mnemonic: 'current advice giraffe sail employ surface lonely right learn moar illness dynamic', 25 | address: 'akash1xx6lpgznxuhfh7ymg64hqs27twuwj4x0wahu123' 26 | } 27 | ``` 28 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { extends: ["@commitlint/config-conventional"] }; 2 | -------------------------------------------------------------------------------- /examples/create_wallet.ts: -------------------------------------------------------------------------------- 1 | import { Secp256k1HdWallet } from "@cosmjs/launchpad"; 2 | 3 | async function main() { 4 | const wallet = await Secp256k1HdWallet.generate(undefined, { prefix: "akash" }); 5 | await wallet.getAccounts(); 6 | } 7 | 8 | main(); 9 | -------------------------------------------------------------------------------- /examples/details_of_single_provider.ts: -------------------------------------------------------------------------------- 1 | import { QueryClientImpl, QueryProviderRequest, QueryProviderResponse } from "@akashnetwork/akash-api/akash/provider/v1beta3"; 2 | import { getRpc } from "@akashnetwork/akashjs/build/rpc"; 3 | 4 | async function main() { 5 | const client = new QueryClientImpl(await getRpc("http://rpc.akashnet.net")); 6 | 7 | const getProviderInfoRequest = QueryProviderRequest.fromPartial({ 8 | owner: "akashSomeProviderAddress" 9 | }); 10 | const providerResponse = await client.Provider(getProviderInfoRequest); 11 | const data = QueryProviderResponse.toJSON(providerResponse); 12 | 13 | console.log(data); 14 | } 15 | 16 | main(); 17 | -------------------------------------------------------------------------------- /examples/estimate_gas.ts: -------------------------------------------------------------------------------- 1 | import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; 2 | import { SigningStargateClient } from "@cosmjs/stargate"; 3 | import { MsgCloseDeployment } from "@akashnetwork/akash-api/akash/deployment/v1beta3"; 4 | import { getAkashTypeRegistry, getTypeUrl } from "@akashnetwork/akashjs/build/stargate"; 5 | import dotenv from "dotenv"; 6 | 7 | dotenv.config({ path: "../.env" }); 8 | 9 | async function main() { 10 | const mnemonic = process.env.MNEMONIC || ""; 11 | if (!mnemonic) { 12 | throw new Error("MNEMONIC environment variable is not set. Please set the environment variable in the .env file. See .env.sample for more information."); 13 | } 14 | const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" }); 15 | 16 | // get first account 17 | const [account] = await wallet.getAccounts(); 18 | 19 | // Use the encode method for the message to wrap the data 20 | const message = MsgCloseDeployment.fromPartial({ 21 | id: { 22 | dseq: "555555", 23 | owner: account.address 24 | } 25 | }); 26 | 27 | // Set the appropriate typeUrl and attach the encoded message as the value 28 | const msgAny = { 29 | typeUrl: getTypeUrl(MsgCloseDeployment), 30 | value: message 31 | }; 32 | 33 | // You can use your own RPC node, or get a list of public nodes from akashjs 34 | const rpcEndpoint = "http://rpc.akashnet.net"; 35 | 36 | const myRegistry = new Registry(getAkashTypeRegistry()); 37 | 38 | const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet, { 39 | registry: myRegistry 40 | }); 41 | 42 | const gas = await client.simulate(account.address, [msgAny], "take down deployment"); 43 | 44 | console.log(gas); 45 | } 46 | 47 | main(); 48 | -------------------------------------------------------------------------------- /examples/fixtures/example.sdl.yaml: -------------------------------------------------------------------------------- 1 | # Welcome to the Akash Network! 🚀☁ 2 | # This file is called a Stack Definition Laguage (SDL) 3 | # SDL is a human friendly data standard for declaring deployment attributes. 4 | # The SDL file is a "form" to request resources from the Network. 5 | # SDL is compatible with the YAML standard and similar to Docker Compose files. 6 | 7 | --- 8 | # Indicates version of Akash configuration file. Currently only "2.0" is accepted. 9 | version: "2.0" 10 | 11 | # The top-level services entry contains a map of workloads to be ran on the Akash deployment. Each key is a service name; values are a map containing the following keys: 12 | # https://akash.network/docs/getting-started/stack-definition-language/#services 13 | services: 14 | # The name of the service "web" 15 | web: 16 | # The docker container image with version. You must specify a version, the "latest" tag doesn't work. 17 | image: baktun/hello-akash-world:1.0.0 18 | # You can map ports here https://akash.network/docs/getting-started/stack-definition-language/#servicesexpose 19 | expose: 20 | - port: 3000 21 | as: 80 22 | to: 23 | - global: true 24 | 25 | # The profiles section contains named compute and placement profiles to be used in the deployment. 26 | # https://akash.network/docs/getting-started/stack-definition-language/#profiles 27 | profiles: 28 | # profiles.compute is map of named compute profiles. Each profile specifies compute resources to be leased for each service instance uses uses the profile. 29 | # https://akash.network/docs/getting-started/stack-definition-language/#profilescompute 30 | compute: 31 | # The name of the service 32 | web: 33 | resources: 34 | cpu: 35 | units: 0.5 36 | memory: 37 | size: 512Mi 38 | storage: 39 | size: 512Mi 40 | 41 | # profiles.placement is map of named datacenter profiles. Each profile specifies required datacenter attributes and pricing configuration for each compute profile that will be used within the datacenter. It also specifies optional list of signatures of which tenants expects audit of datacenter attributes. 42 | # https://akash.network/docs/getting-started/stack-definition-language/#profilesplacement 43 | placement: 44 | dcloud: 45 | pricing: 46 | # The name of the service 47 | web: 48 | denom: uakt 49 | amount: 1000 50 | 51 | # The deployment section defines how to deploy the services. It is a mapping of service name to deployment configuration. 52 | # https://akash.network/docs/getting-started/stack-definition-language/#deployment 53 | deployment: 54 | # The name of the service 55 | web: 56 | dcloud: 57 | profile: web 58 | count: 1 59 | -------------------------------------------------------------------------------- /examples/get_deployments.ts: -------------------------------------------------------------------------------- 1 | import { QueryDeploymentsResponse, QueryDeploymentsRequest, QueryClientImpl } from "@akashnetwork/akash-api/akash/deployment/v1beta3"; 2 | import { getRpc } from "@akashnetwork/akashjs/build/rpc"; 3 | 4 | async function main() { 5 | const request = QueryDeploymentsRequest.fromJSON({ 6 | filters: { 7 | owner: "akashSomeOwnerAddress" 8 | } 9 | }); 10 | 11 | const client = new QueryClientImpl(await getRpc("http://rpc.akashnet.net")); 12 | const response = await client.Deployments(request); 13 | const data = QueryDeploymentsResponse.toJSON(response); 14 | 15 | console.log(data); 16 | } 17 | 18 | main(); 19 | -------------------------------------------------------------------------------- /examples/get_lease_status.ts: -------------------------------------------------------------------------------- 1 | import { QueryClientImpl, QueryLeaseRequest, QueryLeaseResponse } from "@akashnetwork/akash-api/akash/market/v1beta4"; 2 | import { getRpc } from "@akashnetwork/akashjs/build/rpc"; 3 | 4 | async function main() { 5 | const client = new QueryClientImpl(await getRpc("http://rpc.akashnet.net")); 6 | 7 | const getLeaseStatusRequest = QueryLeaseRequest.fromPartial({ 8 | id: { 9 | owner: "akashSomeOwnerAddress", 10 | provider: "akashSomeProviderAddress", 11 | dseq: 1111, // deployment dseq 12 | gseq: 1, // most of the time the value is 1 13 | oseq: 1 // most of the time the value is 1 14 | } 15 | }); 16 | 17 | const leaseStatusResponse = await client.Lease(getLeaseStatusRequest); 18 | const data = QueryLeaseResponse.toJSON(leaseStatusResponse); 19 | 20 | console.log(data); 21 | } 22 | 23 | main(); 24 | -------------------------------------------------------------------------------- /examples/get_state.ts: -------------------------------------------------------------------------------- 1 | import { getMetadata } from "@akashnetwork/akashjs/build/network"; 2 | 3 | async function fetchMetadata() { 4 | try { 5 | console.log("Fetching metadata..."); 6 | const metadata = await getMetadata("mainnet"); 7 | console.log(JSON.stringify(metadata, null, 2)); 8 | } catch (error) { 9 | console.error("Error fetching metadata:", error); 10 | } 11 | } 12 | 13 | fetchMetadata(); 14 | -------------------------------------------------------------------------------- /examples/list_all_providers.ts: -------------------------------------------------------------------------------- 1 | import { QueryClientImpl, QueryProvidersRequest, QueryProvidersResponse } from "@akashnetwork/akash-api/akash/provider/v1beta3"; 2 | import { getRpc } from "@akashnetwork/akashjs/build/rpc"; 3 | 4 | async function main() { 5 | const client = new QueryClientImpl(await getRpc("http://rpc.akashnet.net")); 6 | 7 | const providersRequest = QueryProvidersRequest.fromPartial({ 8 | pagination: { 9 | limit: 100, //change to a value of your choice default: 100 10 | countTotal: true // set to true to receive total count in response 11 | } 12 | }); 13 | const providersResponse = await client.Providers(providersRequest); 14 | const data = QueryProvidersResponse.toJSON(providersResponse); 15 | 16 | console.log(data); 17 | } 18 | 19 | main(); 20 | -------------------------------------------------------------------------------- /examples/signed_message.ts: -------------------------------------------------------------------------------- 1 | import { Secp256k1HdWallet, StdSignDoc } from "@cosmjs/launchpad"; 2 | 3 | function getMessage(): StdSignDoc { 4 | return { value: "test message" } as unknown as StdSignDoc; 5 | } 6 | 7 | async function main() { 8 | const wallet = await Secp256k1HdWallet.generate(undefined, { prefix: "akash" }); 9 | 10 | const [account] = await wallet.getAccounts(); 11 | const msg = getMessage(); 12 | 13 | const signedMessage = await wallet.signAmino(account.address, msg); 14 | 15 | console.log(signedMessage); 16 | } 17 | 18 | main(); 19 | -------------------------------------------------------------------------------- /examples/signed_msg_send.ts: -------------------------------------------------------------------------------- 1 | import { coins, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; 2 | import { defaultRegistryTypes, SigningStargateClient } from "@cosmjs/stargate"; 3 | import dotenv from "dotenv"; 4 | 5 | dotenv.config({ path: "../.env" }); 6 | 7 | async function main() { 8 | const mnemonic = process.env.MNEMONIC || ""; 9 | if (!mnemonic) { 10 | throw new Error("MNEMONIC environment variable is not set. Please set the environment variable in the .env file. See .env.sample for more information."); 11 | } 12 | const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" }); 13 | 14 | // get first account 15 | const [account] = await wallet.getAccounts(); 16 | 17 | // Setup a send message 18 | const message = { 19 | fromAddress: account.address, 20 | toAddress: "akash123...", 21 | amount: coins(10, "akt") 22 | }; 23 | 24 | // Set the appropriate typeUrl and attach the encoded message as the value 25 | const msgAny = { 26 | typeUrl: "/cosmos.bank.v1beta1.MsgSend", 27 | value: message 28 | }; 29 | 30 | // You can use your own RPC node, or get a list of public nodes from akashjs 31 | const rpcEndpoint = "http://your.rpc.node"; 32 | 33 | const myRegistry = new Registry(defaultRegistryTypes); 34 | 35 | const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet, { 36 | registry: myRegistry 37 | }); 38 | 39 | const fee = { 40 | amount: [ 41 | { 42 | denom: "uakt", 43 | amount: "5000" 44 | } 45 | ], 46 | gas: "800000" 47 | }; 48 | 49 | const msg = await client.sign(account.address, [msgAny], fee, "send funds with akashjs"); 50 | 51 | console.log(msg); 52 | } 53 | 54 | main(); 55 | -------------------------------------------------------------------------------- /examples/take_down_deployment.ts: -------------------------------------------------------------------------------- 1 | import { DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; 2 | import { SigningStargateClient } from "@cosmjs/stargate"; 3 | import { getAkashTypeRegistry, getTypeUrl } from "@akashnetwork/akashjs/build/stargate"; 4 | import { MsgCloseDeployment } from "@akashnetwork/akash-api/akash/deployment/v1beta3"; 5 | import dotenv from "dotenv"; 6 | 7 | dotenv.config({ path: "../.env" }); 8 | 9 | async function main() { 10 | const mnemonic = process.env.MNEMONIC || ""; 11 | if (!mnemonic) { 12 | throw new Error("MNEMONIC environment variable is not set. Please set the environment variable in the .env file. See .env.sample for more information."); 13 | } 14 | const wallet = await DirectSecp256k1HdWallet.fromMnemonic(mnemonic, { prefix: "akash" }); 15 | 16 | // get first account 17 | const [account] = await wallet.getAccounts(); 18 | 19 | // Use the encode method for the message to wrap the data 20 | const message = MsgCloseDeployment.fromPartial({ 21 | id: { 22 | dseq: "19837048", 23 | owner: account.address 24 | } 25 | }); 26 | 27 | // Set the appropriate typeUrl and attach the encoded message as the value 28 | const msgAny = { 29 | typeUrl: getTypeUrl(MsgCloseDeployment), 30 | value: message 31 | }; 32 | 33 | // You can use your own RPC node, or get a list of public nodes from akashjs 34 | const rpcEndpoint = "http://rpc.akashnet.net"; 35 | 36 | const myRegistry = new Registry(getAkashTypeRegistry()); 37 | 38 | const client = await SigningStargateClient.connectWithSigner(rpcEndpoint, wallet, { 39 | registry: myRegistry 40 | }); 41 | 42 | const fee = { 43 | amount: [ 44 | { 45 | denom: "uakt", 46 | amount: "20000" 47 | } 48 | ], 49 | gas: "800000" 50 | }; 51 | 52 | await client.signAndBroadcast(account.address, [msgAny], fee, "take down deployment"); 53 | } 54 | 55 | main(); 56 | -------------------------------------------------------------------------------- /examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.build.json", 3 | "compilerOptions": { 4 | "paths": { 5 | "@akashnetwork/akashjs/build/*": ["../src/*"] 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | const common = { 2 | transform: { 3 | "^.+\\.(t|j)s$": ["ts-jest", { tsconfig: "./tsconfig.json" }] 4 | }, 5 | rootDir: ".", 6 | setupFiles: ["./test/setup.ts"] 7 | }; 8 | 9 | module.exports = { 10 | collectCoverageFrom: ["./src/**/*.{js,ts}", "!./src/protobuf/**/*"], 11 | projects: [ 12 | { 13 | displayName: "unit", 14 | ...common, 15 | testMatch: ["/src/**/*.spec.ts", "/tests/**/*.spec.ts"], 16 | setupFilesAfterEnv: ["./test/setup-unit-tests.ts"] 17 | } 18 | ] 19 | }; 20 | -------------------------------------------------------------------------------- /src/certificates/certificate-manager/index.ts: -------------------------------------------------------------------------------- 1 | import { CertificateManager } from "./CertificateManager"; 2 | 3 | /** 4 | * An instance of the CertificateManager class. 5 | * 6 | * @example 7 | * // Import the certificateManager instance 8 | * import { certificateManager } from './certificate-manager'; 9 | * 10 | * // Use the certificateManager instance 11 | * certificateManager.issueCertificate('user123'); 12 | */ 13 | const certificateManager = new CertificateManager(); 14 | 15 | export { 16 | /** 17 | * CertificateManager class for managing certificates. 18 | * 19 | * @example 20 | * // Import the CertificateManager class 21 | * import { CertificateManager } from './certificate-manager'; 22 | * 23 | * // Create a new instance of CertificateManager 24 | * const myCertificateManager = new CertificateManager(); 25 | */ 26 | CertificateManager, 27 | certificateManager 28 | }; 29 | -------------------------------------------------------------------------------- /src/certificates/generate509/generate509.spec.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @module generate509.spec 3 | * Test suite for the X.509 certificate generation functionality 4 | */ 5 | 6 | import { faker } from "@faker-js/faker"; 7 | import { create } from "./generate509"; 8 | 9 | /** 10 | * Test suite for the generate509 module 11 | * @group Certificates 12 | */ 13 | describe("generate509", () => { 14 | /** 15 | * Tests the certificate generation functionality 16 | * Verifies that the generated certificate components are in the correct PEM format 17 | */ 18 | it("should generate a CSR", async () => { 19 | const address = `akash1${faker.string.alpha({ length: 38 })}`; 20 | const cert = await create(address); 21 | 22 | expect(cert).toMatchObject({ 23 | csr: expect.stringMatching(/^-----BEGIN CERTIFICATE-----[\s\S]*-----END CERTIFICATE-----$/), 24 | publicKey: expect.stringMatching(/^-----BEGIN EC PUBLIC KEY-----[\s\S]*-----END EC PUBLIC KEY-----$/), 25 | privateKey: expect.stringMatching(/^-----BEGIN PRIVATE KEY-----[\s\S]*-----END PRIVATE KEY-----$/) 26 | }); 27 | }); 28 | }); 29 | -------------------------------------------------------------------------------- /src/certificates/generate509/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./generate509"; 2 | -------------------------------------------------------------------------------- /src/config/network.ts: -------------------------------------------------------------------------------- 1 | import { MainnetNetworkId, NetworkId, SandboxNetworkId, TestnetNetworkId } from "../types/network"; 2 | 3 | /** 4 | * The network ID for the mainnet environment. 5 | * @type {MainnetNetworkId} 6 | */ 7 | export const MAINNET_ID: MainnetNetworkId = "mainnet"; 8 | 9 | /** 10 | * The network ID for the sandbox environment. 11 | * @type {SandboxNetworkId} 12 | */ 13 | export const SANDBOX_ID: SandboxNetworkId = "sandbox"; 14 | 15 | /** 16 | * The network ID for the testnet environment. 17 | * @type {TestnetNetworkId} 18 | */ 19 | export const TESTNET_ID: TestnetNetworkId = "testnet"; 20 | 21 | /** 22 | * A mapping of network IDs to their respective USDC IBC denominations. 23 | * @type {Record} 24 | */ 25 | export const USDC_IBC_DENOMS: Record = { 26 | [MAINNET_ID]: "ibc/170C677610AC31DF0904FFE09CD3B5C657492170E7E52372E48756B71E56F2F1", 27 | [SANDBOX_ID]: "ibc/12C6A0C374171B595A0A9E18B83FA09D295FB1F2D8C6DAA3AC28683471752D84", 28 | [TESTNET_ID]: "" 29 | }; 30 | 31 | /** 32 | * The denomination for the AKT token. 33 | * @type {string} 34 | */ 35 | export const AKT_DENOM = "uakt"; 36 | -------------------------------------------------------------------------------- /src/error/SdlValidationError.ts: -------------------------------------------------------------------------------- 1 | import { ValidationError } from "./ValidationError"; 2 | 3 | /** 4 | * Represents an SDL validation error. 5 | * Extends the base `ValidationError` class. 6 | */ 7 | export class SdlValidationError extends ValidationError { 8 | /** 9 | * Asserts a condition and throws an `SdlValidationError` if the condition is false. 10 | * @param condition - The condition to assert. 11 | * @param message - The error message to throw if the assertion fails. 12 | * @example 13 | * SdlValidationError.assert(someCondition, "Condition failed"); 14 | */ 15 | static assert(condition: unknown, message: string): asserts condition { 16 | if (!condition) { 17 | throw new SdlValidationError(message); 18 | } 19 | } 20 | 21 | /** 22 | * Creates an instance of `SdlValidationError`. 23 | * @param message - The error message. 24 | */ 25 | constructor(message: string) { 26 | super(message); 27 | this.name = "SdlValidationError"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/error/ValidationError.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Represents a generic validation error. 3 | * Extends the native `Error` class. 4 | */ 5 | export class ValidationError extends Error { 6 | /** 7 | * Asserts a condition and throws a `ValidationError` if the condition is false. 8 | * @param condition - The condition to assert. 9 | * @param message - The error message to throw if the assertion fails. 10 | * @example 11 | * ValidationError.assert(someCondition, "Condition failed"); 12 | */ 13 | static assert(condition: unknown, message: string): asserts condition { 14 | if (!condition) { 15 | throw new ValidationError(message); 16 | } 17 | } 18 | 19 | /** 20 | * Creates an instance of `ValidationError`. 21 | * @param message - The error message. 22 | */ 23 | constructor(message: string) { 24 | super(message); 25 | this.name = "ValidationError"; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/error/index.ts: -------------------------------------------------------------------------------- 1 | export * from "./SdlValidationError"; 2 | export * from "./ValidationError"; 3 | -------------------------------------------------------------------------------- /src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Main exports for the Akash JS 3 | * @module akashjs 4 | */ 5 | 6 | export * as certificate from "./certificates"; 7 | export * as stargate from "./stargate"; 8 | export * as keplr from "./keplr"; 9 | export * as wallet from "./wallet"; 10 | export * as network from "./network"; 11 | export * as rpc from "./rpc"; 12 | 13 | export * as protoclient from "./pbclient/pbclient"; 14 | export * as sdl from "./sdl"; 15 | export * from "./error"; 16 | -------------------------------------------------------------------------------- /src/keplr/index.ts: -------------------------------------------------------------------------------- 1 | import { getAkashTypeRegistry } from "../stargate"; 2 | import { defaultRegistryTypes, SigningStargateClient } from "@cosmjs/stargate"; 3 | import { OfflineDirectSigner, OfflineSigner, Registry } from "@cosmjs/proto-signing"; 4 | import { AminoTypes } from "@cosmjs/stargate"; 5 | import { Certificate } from "@akashnetwork/akash-api/akash/cert/v1beta2"; 6 | import { MsgCreateCertificate } from "@akashnetwork/akash-api/deprecated/akash/cert/v1beta1"; 7 | 8 | /** 9 | * Represents a blockchain chain. 10 | * @typedef {Object} Chain 11 | * @property {string} id - The unique identifier of the chain. 12 | */ 13 | interface Chain { 14 | id: string; 15 | } 16 | 17 | /** 18 | * Returns the available blockchain chains. 19 | * @returns {Object} An object containing mainnet and testnet chain configurations. 20 | */ 21 | export function getChains() { 22 | return { 23 | mainnet: { 24 | id: "akashnet-2", 25 | name: "Akash Mainnet", 26 | messagePath: "v1beta2" 27 | }, 28 | testnet: { id: "testnet-1", name: "Akash Testnet", messagePath: "v1beta2" } 29 | }; 30 | } 31 | 32 | /** 33 | * Retrieves the signer for a given blockchain chain. 34 | * @param {Chain} chain - The blockchain chain for which to get the signer. 35 | * @returns {Promise} A promise that resolves to the signer. 36 | */ 37 | export function getSigner(chain: Chain) { 38 | return window.getOfflineSignerAuto(chain.id); 39 | } 40 | 41 | /** 42 | * Connects to a blockchain endpoint with a given signer. 43 | * @param {Chain} chain - The blockchain chain to connect to. 44 | * @param {OfflineSigner | OfflineDirectSigner} signer - The signer to use for the connection. 45 | * @param {string} endPoint - The endpoint URL to connect to. 46 | * @returns {Promise} A promise that resolves to the connected client. 47 | */ 48 | export async function get(chain: Chain, signer: OfflineSigner | OfflineDirectSigner, endPoint: string) { 49 | // Define custom Amino types for specific message types 50 | const customAminoTypes = new AminoTypes({ 51 | // Specify the message type for creating a certificate 52 | "/akash.cert.v1beta2.MsgCreateCertificate": { 53 | // Define the Amino type string for the message 54 | aminoType: "cert/cert-create-certificate", 55 | // Function to convert the message to Amino format 56 | toAmino: ({ cert, pubkey }: MsgCreateCertificate) => { 57 | // Encode the certificate and public key into a binary format 58 | const buf = Certificate.encode( 59 | Certificate.fromPartial({ 60 | cert, 61 | pubkey 62 | }) 63 | ).finish(); 64 | // Convert the binary data to a base64 string 65 | const encoded = Buffer.from(buf); 66 | return encoded.toString("base64"); 67 | }, 68 | // Function to convert the message from Amino format 69 | fromAmino: ({ cert, pubkey }: MsgCreateCertificate) => { 70 | // Create a partial Certificate object from the Amino data 71 | return Certificate.fromPartial({ 72 | cert, 73 | pubkey 74 | }); 75 | } 76 | } 77 | }); 78 | 79 | // Create a registry that includes default types and Akash-specific types 80 | const myRegistry = new Registry([...defaultRegistryTypes, ...getAkashTypeRegistry()]); 81 | 82 | // Connect to the blockchain endpoint using the provided signer and custom configurations 83 | return await SigningStargateClient.connectWithSigner(endPoint, signer, { 84 | registry: myRegistry, // Use the custom registry 85 | aminoTypes: customAminoTypes // Use the custom Amino types 86 | }); 87 | } 88 | -------------------------------------------------------------------------------- /src/network/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Network functionality for interacting with Akash networks 3 | * @module network 4 | */ 5 | 6 | import fetch from "node-fetch"; 7 | import { performance } from "perf_hooks"; 8 | import { awaitAll, filter, map, prop, sortBy } from "../util"; 9 | 10 | /** Network type identifier */ 11 | type NETWORK_TYPE = "mainnet" | "testnet" | "edgenet"; 12 | 13 | /** Network endpoint type */ 14 | type ENDPOINT_TYPE = "rpc" | "rest"; 15 | 16 | /** 17 | * Network metadata interface 18 | */ 19 | interface INetworkMetadata { 20 | chain_name: string; 21 | status: string; 22 | network_type: string; 23 | pretty_name: string; 24 | chain_id: string; 25 | bech32_prefix: string; 26 | daemon_name: string; 27 | node_home: string; 28 | genesis: { 29 | genesis_url: string; 30 | }; 31 | codebase: { 32 | git_repo: string; 33 | recommended_version: string; 34 | compatible_versions: [string]; 35 | binaries: { 36 | [target: string]: string; 37 | }; 38 | }; 39 | peers: { 40 | seeds: [ 41 | { 42 | id: string; 43 | address: string; 44 | } 45 | ]; 46 | persistent_peers: [ 47 | { 48 | id: string; 49 | address: string; 50 | } 51 | ]; 52 | }; 53 | apis: { 54 | [type: string]: [{ address: string }]; 55 | }; 56 | } 57 | 58 | /** 59 | * Gets metadata for a specific network 60 | * @param {NETWORK_TYPE} network - The network to get metadata for 61 | * @returns {Promise} The network metadata 62 | */ 63 | export async function getMetadata(network: NETWORK_TYPE): Promise { 64 | return fetch(`https://raw.githubusercontent.com/ovrclk/net/master/${network}/meta.json`).then(res => res.json()); 65 | } 66 | 67 | /** 68 | * Retrieves endpoints for a specific network and type 69 | * @param {NETWORK_TYPE} network - The network to get endpoints for 70 | * @param {ENDPOINT_TYPE} type - The type of endpoint to retrieve 71 | * @returns {Promise<{ address: string }[]>} A promise that resolves to an array of endpoint addresses 72 | */ 73 | export function getEndpoints(network: NETWORK_TYPE, type: ENDPOINT_TYPE) { 74 | return getMetadata(network).then(meta => meta.apis[type]); 75 | } 76 | 77 | /** 78 | * Retrieves and sorts endpoints by their health status 79 | * @param {NETWORK_TYPE} network - The network to get endpoints for 80 | * @param {ENDPOINT_TYPE} type - The type of endpoint to retrieve 81 | * @returns {Promise<{ address: string, responseTime: number | null }[]>} A promise that resolves to an array of endpoints sorted by response time 82 | */ 83 | export function getEndpointsSorted(network: NETWORK_TYPE, type: ENDPOINT_TYPE) { 84 | return getEndpoints(network, type) 85 | .then(map(getEndpointHealthStatus(800))) 86 | .then(awaitAll) 87 | .then(filter(isNodeResponsive)) 88 | .then(sortBy(prop("responseTime"))); 89 | } 90 | 91 | /** 92 | * Checks if a node is responsive based on its response time 93 | * @param {{ responseTime: number | null }} endpoint - The endpoint to check 94 | * @returns {boolean} True if the node is responsive, false otherwise 95 | */ 96 | function isNodeResponsive(endpoint: { responseTime: number | null }) { 97 | return endpoint.responseTime !== null; 98 | } 99 | 100 | /** 101 | * Returns a function that checks the health status of an endpoint 102 | * @param {number} timeout - The timeout for the health check request 103 | * @returns {function({ address: string }): Promise<{ address: string, responseTime: number | null }>} A function that returns a promise resolving to the endpoint's health status 104 | */ 105 | function getEndpointHealthStatus(timeout: number) { 106 | return ({ address }: { address: string }) => { 107 | const startTime = performance.now(); 108 | 109 | return fetch(`${address}/node_info`, { timeout }) 110 | .then(() => ({ 111 | address, 112 | responseTime: Math.floor(performance.now() - startTime) 113 | })) 114 | .catch(() => ({ 115 | address, 116 | responseTime: null 117 | })); 118 | }; 119 | } 120 | -------------------------------------------------------------------------------- /src/pbclient/pbclient.spec.ts: -------------------------------------------------------------------------------- 1 | import { faker } from "@faker-js/faker"; 2 | 3 | import { createAminoMessage } from "./pbclient"; 4 | import { Message } from "../stargate"; 5 | import { AminoMsg } from "@cosmjs/amino"; 6 | 7 | describe("createAminoMessage", () => { 8 | /** 9 | * Test to ensure createAminoMessage function creates an Amino message correctly. 10 | */ 11 | it("creates an amino message", () => { 12 | const message = faker.helpers.arrayElement(Object.values(Message)); 13 | const messageBody: AminoMsg = { 14 | type: faker.string.alpha(10), 15 | value: faker.string.alpha(10) 16 | }; 17 | const result = createAminoMessage(message, messageBody); 18 | 19 | expect(result).toEqual({ 20 | typeUrl: message, 21 | value: messageBody 22 | }); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /src/pbclient/pbclient.ts: -------------------------------------------------------------------------------- 1 | import { Message } from "../stargate"; 2 | import { AminoMsg } from "@cosmjs/amino"; 3 | import { MsgCreateCertificate, MsgRevokeCertificate } from "@akashnetwork/akash-api/akash/cert/v1beta3"; 4 | 5 | const FEE = { 6 | amount: [ 7 | { 8 | denom: "uakt", 9 | amount: "2500" 10 | } 11 | ], 12 | gas: "100000" 13 | }; 14 | 15 | /** 16 | * Creates an Amino message object. 17 | * 18 | * @param {Message} message - The type of the message. 19 | * @param {AminoMsg} messageBody - The body of the message. 20 | * @returns {object} The Amino message object. 21 | */ 22 | export function createAminoMessage(message: Message, messageBody: AminoMsg) { 23 | return { 24 | typeUrl: message, 25 | value: messageBody 26 | }; 27 | } 28 | 29 | type WithoutType = Omit; 30 | type MessageTypes = { 31 | [Message.MsgCreateCertificate]: WithoutType; 32 | [Message.MsgRevokeCertificate]: Omit, "id"> & { 33 | id: WithoutType; 34 | }; 35 | }; 36 | 37 | /** 38 | * Creates a Stargate message object with a fee. 39 | * 40 | * @template T 41 | * @param {T} message - The type of the message. 42 | * @param {MessageTypes[T]} messageBody - The body of the message. 43 | * @returns {object} The Stargate message object with a fee. 44 | */ 45 | export function createStarGateMessage(message: T, messageBody: MessageTypes[T]) { 46 | return { 47 | message: { 48 | typeUrl: message, 49 | value: messageBody 50 | }, 51 | fee: FEE 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /src/protobuf/akash/audit/v1beta1/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import _m0 from "protobufjs/minimal"; 5 | import { AuditedAttributes } from "../../../akash/audit/v1beta1/audit"; 6 | 7 | export const protobufPackage = "akash.audit.v1beta1"; 8 | 9 | /** GenesisState defines the basic genesis state used by audit module */ 10 | export interface GenesisState { 11 | $type: "akash.audit.v1beta1.GenesisState"; 12 | attributes: AuditedAttributes[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.audit.v1beta1.GenesisState", attributes: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.audit.v1beta1.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.attributes) { 24 | AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.attributes) { 57 | obj.attributes = message.attributes.map(e => (e ? AuditedAttributes.toJSON(e) : undefined)); 58 | } else { 59 | obj.attributes = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/audit/v1beta2/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { AuditedAttributes } from "./audit"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.audit.v1beta2"; 8 | 9 | /** GenesisState defines the basic genesis state used by audit module */ 10 | export interface GenesisState { 11 | $type: "akash.audit.v1beta2.GenesisState"; 12 | attributes: AuditedAttributes[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.audit.v1beta2.GenesisState", attributes: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.audit.v1beta2.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.attributes) { 24 | AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.attributes) { 57 | obj.attributes = message.attributes.map(e => (e ? AuditedAttributes.toJSON(e) : undefined)); 58 | } else { 59 | obj.attributes = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/audit/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { AuditedAttributes } from "./audit"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.audit.v1beta3"; 8 | 9 | /** GenesisState defines the basic genesis state used by audit module */ 10 | export interface GenesisState { 11 | $type: "akash.audit.v1beta3.GenesisState"; 12 | attributes: AuditedAttributes[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.audit.v1beta3.GenesisState", attributes: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.audit.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.attributes) { 24 | AuditedAttributes.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.attributes.push(AuditedAttributes.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => AuditedAttributes.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.attributes) { 57 | obj.attributes = message.attributes.map(e => (e ? AuditedAttributes.toJSON(e) : undefined)); 58 | } else { 59 | obj.attributes = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.attributes = object.attributes?.map(e => AuditedAttributes.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/base/v1beta3/cpu.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { ResourceValue } from "./resourcevalue"; 5 | import { Attribute } from "./attribute"; 6 | import * as _m0 from "protobufjs/minimal"; 7 | 8 | export const protobufPackage = "akash.base.v1beta3"; 9 | 10 | /** CPU stores resource units and cpu config attributes */ 11 | export interface CPU { 12 | $type: "akash.base.v1beta3.CPU"; 13 | units: ResourceValue | undefined; 14 | attributes: Attribute[]; 15 | } 16 | 17 | function createBaseCPU(): CPU { 18 | return { $type: "akash.base.v1beta3.CPU", units: undefined, attributes: [] }; 19 | } 20 | 21 | export const CPU = { 22 | $type: "akash.base.v1beta3.CPU" as const, 23 | 24 | encode(message: CPU, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 25 | if (message.units !== undefined) { 26 | ResourceValue.encode(message.units, writer.uint32(10).fork()).ldelim(); 27 | } 28 | for (const v of message.attributes) { 29 | Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); 30 | } 31 | return writer; 32 | }, 33 | 34 | decode(input: _m0.Reader | Uint8Array, length?: number): CPU { 35 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 36 | let end = length === undefined ? reader.len : reader.pos + length; 37 | const message = createBaseCPU(); 38 | while (reader.pos < end) { 39 | const tag = reader.uint32(); 40 | switch (tag >>> 3) { 41 | case 1: 42 | message.units = ResourceValue.decode(reader, reader.uint32()); 43 | break; 44 | case 2: 45 | message.attributes.push(Attribute.decode(reader, reader.uint32())); 46 | break; 47 | default: 48 | reader.skipType(tag & 7); 49 | break; 50 | } 51 | } 52 | return message; 53 | }, 54 | 55 | fromJSON(object: any): CPU { 56 | return { 57 | $type: CPU.$type, 58 | units: isSet(object.units) ? ResourceValue.fromJSON(object.units) : undefined, 59 | attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromJSON(e)) : [] 60 | }; 61 | }, 62 | 63 | toJSON(message: CPU): unknown { 64 | const obj: any = {}; 65 | message.units !== undefined && (obj.units = message.units ? ResourceValue.toJSON(message.units) : undefined); 66 | if (message.attributes) { 67 | obj.attributes = message.attributes.map(e => (e ? Attribute.toJSON(e) : undefined)); 68 | } else { 69 | obj.attributes = []; 70 | } 71 | return obj; 72 | }, 73 | 74 | fromPartial, I>>(object: I): CPU { 75 | const message = createBaseCPU(); 76 | message.units = object.units !== undefined && object.units !== null ? ResourceValue.fromPartial(object.units) : undefined; 77 | message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; 78 | return message; 79 | } 80 | }; 81 | 82 | messageTypeRegistry.set(CPU.$type, CPU); 83 | 84 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 85 | 86 | export type DeepPartial = T extends Builtin 87 | ? T 88 | : T extends Long 89 | ? string | number | Long 90 | : T extends Array 91 | ? Array> 92 | : T extends ReadonlyArray 93 | ? ReadonlyArray> 94 | : T extends {} 95 | ? { [K in Exclude]?: DeepPartial } 96 | : Partial; 97 | 98 | type KeysOfUnion = T extends T ? keyof T : never; 99 | export type Exact = P extends Builtin 100 | ? P 101 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 102 | 103 | if (_m0.util.Long !== Long) { 104 | _m0.util.Long = Long as any; 105 | _m0.configure(); 106 | } 107 | 108 | function isSet(value: any): boolean { 109 | return value !== null && value !== undefined; 110 | } 111 | -------------------------------------------------------------------------------- /src/protobuf/akash/base/v1beta3/gpu.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { ResourceValue } from "./resourcevalue"; 5 | import { Attribute } from "./attribute"; 6 | import * as _m0 from "protobufjs/minimal"; 7 | 8 | export const protobufPackage = "akash.base.v1beta3"; 9 | 10 | /** GPU stores resource units and cpu config attributes */ 11 | export interface GPU { 12 | $type: "akash.base.v1beta3.GPU"; 13 | units: ResourceValue | undefined; 14 | attributes: Attribute[]; 15 | } 16 | 17 | function createBaseGPU(): GPU { 18 | return { $type: "akash.base.v1beta3.GPU", units: undefined, attributes: [] }; 19 | } 20 | 21 | export const GPU = { 22 | $type: "akash.base.v1beta3.GPU" as const, 23 | 24 | encode(message: GPU, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 25 | if (message.units !== undefined) { 26 | ResourceValue.encode(message.units, writer.uint32(10).fork()).ldelim(); 27 | } 28 | for (const v of message.attributes) { 29 | Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); 30 | } 31 | return writer; 32 | }, 33 | 34 | decode(input: _m0.Reader | Uint8Array, length?: number): GPU { 35 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 36 | let end = length === undefined ? reader.len : reader.pos + length; 37 | const message = createBaseGPU(); 38 | while (reader.pos < end) { 39 | const tag = reader.uint32(); 40 | switch (tag >>> 3) { 41 | case 1: 42 | message.units = ResourceValue.decode(reader, reader.uint32()); 43 | break; 44 | case 2: 45 | message.attributes.push(Attribute.decode(reader, reader.uint32())); 46 | break; 47 | default: 48 | reader.skipType(tag & 7); 49 | break; 50 | } 51 | } 52 | return message; 53 | }, 54 | 55 | fromJSON(object: any): GPU { 56 | return { 57 | $type: GPU.$type, 58 | units: isSet(object.units) ? ResourceValue.fromJSON(object.units) : undefined, 59 | attributes: Array.isArray(object?.attributes) ? object.attributes.map((e: any) => Attribute.fromJSON(e)) : [] 60 | }; 61 | }, 62 | 63 | toJSON(message: GPU): unknown { 64 | const obj: any = {}; 65 | message.units !== undefined && (obj.units = message.units ? ResourceValue.toJSON(message.units) : undefined); 66 | if (message.attributes) { 67 | obj.attributes = message.attributes.map(e => (e ? Attribute.toJSON(e) : undefined)); 68 | } else { 69 | obj.attributes = []; 70 | } 71 | return obj; 72 | }, 73 | 74 | fromPartial, I>>(object: I): GPU { 75 | const message = createBaseGPU(); 76 | message.units = object.units !== undefined && object.units !== null ? ResourceValue.fromPartial(object.units) : undefined; 77 | message.attributes = object.attributes?.map(e => Attribute.fromPartial(e)) || []; 78 | return message; 79 | } 80 | }; 81 | 82 | messageTypeRegistry.set(GPU.$type, GPU); 83 | 84 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 85 | 86 | export type DeepPartial = T extends Builtin 87 | ? T 88 | : T extends Long 89 | ? string | number | Long 90 | : T extends Array 91 | ? Array> 92 | : T extends ReadonlyArray 93 | ? ReadonlyArray> 94 | : T extends {} 95 | ? { [K in Exclude]?: DeepPartial } 96 | : Partial; 97 | 98 | type KeysOfUnion = T extends T ? keyof T : never; 99 | export type Exact = P extends Builtin 100 | ? P 101 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 102 | 103 | if (_m0.util.Long !== Long) { 104 | _m0.util.Long = Long as any; 105 | _m0.configure(); 106 | } 107 | 108 | function isSet(value: any): boolean { 109 | return value !== null && value !== undefined; 110 | } 111 | -------------------------------------------------------------------------------- /src/protobuf/akash/deployment/v1beta1/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.deployment.v1beta1"; 8 | 9 | /** Params defines the parameters for the x/deployment package */ 10 | export interface Params { 11 | $type: "akash.deployment.v1beta1.Params"; 12 | deploymentMinDeposit: Coin | undefined; 13 | } 14 | 15 | function createBaseParams(): Params { 16 | return { 17 | $type: "akash.deployment.v1beta1.Params", 18 | deploymentMinDeposit: undefined 19 | }; 20 | } 21 | 22 | export const Params = { 23 | $type: "akash.deployment.v1beta1.Params" as const, 24 | 25 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 26 | if (message.deploymentMinDeposit !== undefined) { 27 | Coin.encode(message.deploymentMinDeposit, writer.uint32(10).fork()).ldelim(); 28 | } 29 | return writer; 30 | }, 31 | 32 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 33 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 34 | let end = length === undefined ? reader.len : reader.pos + length; 35 | const message = createBaseParams(); 36 | while (reader.pos < end) { 37 | const tag = reader.uint32(); 38 | switch (tag >>> 3) { 39 | case 1: 40 | message.deploymentMinDeposit = Coin.decode(reader, reader.uint32()); 41 | break; 42 | default: 43 | reader.skipType(tag & 7); 44 | break; 45 | } 46 | } 47 | return message; 48 | }, 49 | 50 | fromJSON(object: any): Params { 51 | return { 52 | $type: Params.$type, 53 | deploymentMinDeposit: isSet(object.deploymentMinDeposit) ? Coin.fromJSON(object.deploymentMinDeposit) : undefined 54 | }; 55 | }, 56 | 57 | toJSON(message: Params): unknown { 58 | const obj: any = {}; 59 | message.deploymentMinDeposit !== undefined && 60 | (obj.deploymentMinDeposit = message.deploymentMinDeposit ? Coin.toJSON(message.deploymentMinDeposit) : undefined); 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): Params { 65 | const message = createBaseParams(); 66 | message.deploymentMinDeposit = 67 | object.deploymentMinDeposit !== undefined && object.deploymentMinDeposit !== null ? Coin.fromPartial(object.deploymentMinDeposit) : undefined; 68 | return message; 69 | } 70 | }; 71 | 72 | messageTypeRegistry.set(Params.$type, Params); 73 | 74 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 75 | 76 | export type DeepPartial = T extends Builtin 77 | ? T 78 | : T extends Long 79 | ? string | number | Long 80 | : T extends Array 81 | ? Array> 82 | : T extends ReadonlyArray 83 | ? ReadonlyArray> 84 | : T extends {} 85 | ? { [K in Exclude]?: DeepPartial } 86 | : Partial; 87 | 88 | type KeysOfUnion = T extends T ? keyof T : never; 89 | export type Exact = P extends Builtin 90 | ? P 91 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 92 | 93 | if (_m0.util.Long !== Long) { 94 | _m0.util.Long = Long as any; 95 | _m0.configure(); 96 | } 97 | 98 | function isSet(value: any): boolean { 99 | return value !== null && value !== undefined; 100 | } 101 | -------------------------------------------------------------------------------- /src/protobuf/akash/deployment/v1beta2/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.deployment.v1beta2"; 8 | 9 | /** Params defines the parameters for the x/deployment package */ 10 | export interface Params { 11 | $type: "akash.deployment.v1beta2.Params"; 12 | deploymentMinDeposit: Coin | undefined; 13 | } 14 | 15 | function createBaseParams(): Params { 16 | return { 17 | $type: "akash.deployment.v1beta2.Params", 18 | deploymentMinDeposit: undefined 19 | }; 20 | } 21 | 22 | export const Params = { 23 | $type: "akash.deployment.v1beta2.Params" as const, 24 | 25 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 26 | if (message.deploymentMinDeposit !== undefined) { 27 | Coin.encode(message.deploymentMinDeposit, writer.uint32(10).fork()).ldelim(); 28 | } 29 | return writer; 30 | }, 31 | 32 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 33 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 34 | let end = length === undefined ? reader.len : reader.pos + length; 35 | const message = createBaseParams(); 36 | while (reader.pos < end) { 37 | const tag = reader.uint32(); 38 | switch (tag >>> 3) { 39 | case 1: 40 | message.deploymentMinDeposit = Coin.decode(reader, reader.uint32()); 41 | break; 42 | default: 43 | reader.skipType(tag & 7); 44 | break; 45 | } 46 | } 47 | return message; 48 | }, 49 | 50 | fromJSON(object: any): Params { 51 | return { 52 | $type: Params.$type, 53 | deploymentMinDeposit: isSet(object.deploymentMinDeposit) ? Coin.fromJSON(object.deploymentMinDeposit) : undefined 54 | }; 55 | }, 56 | 57 | toJSON(message: Params): unknown { 58 | const obj: any = {}; 59 | message.deploymentMinDeposit !== undefined && 60 | (obj.deploymentMinDeposit = message.deploymentMinDeposit ? Coin.toJSON(message.deploymentMinDeposit) : undefined); 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): Params { 65 | const message = createBaseParams(); 66 | message.deploymentMinDeposit = 67 | object.deploymentMinDeposit !== undefined && object.deploymentMinDeposit !== null ? Coin.fromPartial(object.deploymentMinDeposit) : undefined; 68 | return message; 69 | } 70 | }; 71 | 72 | messageTypeRegistry.set(Params.$type, Params); 73 | 74 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 75 | 76 | export type DeepPartial = T extends Builtin 77 | ? T 78 | : T extends Long 79 | ? string | number | Long 80 | : T extends Array 81 | ? Array> 82 | : T extends ReadonlyArray 83 | ? ReadonlyArray> 84 | : T extends {} 85 | ? { [K in Exclude]?: DeepPartial } 86 | : Partial; 87 | 88 | type KeysOfUnion = T extends T ? keyof T : never; 89 | export type Exact = P extends Builtin 90 | ? P 91 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 92 | 93 | if (_m0.util.Long !== Long) { 94 | _m0.util.Long = Long as any; 95 | _m0.configure(); 96 | } 97 | 98 | function isSet(value: any): boolean { 99 | return value !== null && value !== undefined; 100 | } 101 | -------------------------------------------------------------------------------- /src/protobuf/akash/deployment/v1beta3/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.deployment.v1beta3"; 8 | 9 | /** Params defines the parameters for the x/deployment package */ 10 | export interface Params { 11 | $type: "akash.deployment.v1beta3.Params"; 12 | minDeposits: Coin[]; 13 | } 14 | 15 | function createBaseParams(): Params { 16 | return { $type: "akash.deployment.v1beta3.Params", minDeposits: [] }; 17 | } 18 | 19 | export const Params = { 20 | $type: "akash.deployment.v1beta3.Params" as const, 21 | 22 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.minDeposits) { 24 | Coin.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseParams(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.minDeposits.push(Coin.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): Params { 48 | return { 49 | $type: Params.$type, 50 | minDeposits: Array.isArray(object?.minDeposits) ? object.minDeposits.map((e: any) => Coin.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: Params): unknown { 55 | const obj: any = {}; 56 | if (message.minDeposits) { 57 | obj.minDeposits = message.minDeposits.map(e => (e ? Coin.toJSON(e) : undefined)); 58 | } else { 59 | obj.minDeposits = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): Params { 65 | const message = createBaseParams(); 66 | message.minDeposits = object.minDeposits?.map(e => Coin.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(Params.$type, Params); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/escrow/v1beta1/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Account, Payment } from "./types"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.escrow.v1beta1"; 8 | 9 | /** GenesisState defines the basic genesis state used by escrow module */ 10 | export interface GenesisState { 11 | $type: "akash.escrow.v1beta1.GenesisState"; 12 | accounts: Account[]; 13 | payments: Payment[]; 14 | } 15 | 16 | function createBaseGenesisState(): GenesisState { 17 | return { 18 | $type: "akash.escrow.v1beta1.GenesisState", 19 | accounts: [], 20 | payments: [] 21 | }; 22 | } 23 | 24 | export const GenesisState = { 25 | $type: "akash.escrow.v1beta1.GenesisState" as const, 26 | 27 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 28 | for (const v of message.accounts) { 29 | Account.encode(v!, writer.uint32(10).fork()).ldelim(); 30 | } 31 | for (const v of message.payments) { 32 | Payment.encode(v!, writer.uint32(18).fork()).ldelim(); 33 | } 34 | return writer; 35 | }, 36 | 37 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 38 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 39 | let end = length === undefined ? reader.len : reader.pos + length; 40 | const message = createBaseGenesisState(); 41 | while (reader.pos < end) { 42 | const tag = reader.uint32(); 43 | switch (tag >>> 3) { 44 | case 1: 45 | message.accounts.push(Account.decode(reader, reader.uint32())); 46 | break; 47 | case 2: 48 | message.payments.push(Payment.decode(reader, reader.uint32())); 49 | break; 50 | default: 51 | reader.skipType(tag & 7); 52 | break; 53 | } 54 | } 55 | return message; 56 | }, 57 | 58 | fromJSON(object: any): GenesisState { 59 | return { 60 | $type: GenesisState.$type, 61 | accounts: Array.isArray(object?.accounts) ? object.accounts.map((e: any) => Account.fromJSON(e)) : [], 62 | payments: Array.isArray(object?.payments) ? object.payments.map((e: any) => Payment.fromJSON(e)) : [] 63 | }; 64 | }, 65 | 66 | toJSON(message: GenesisState): unknown { 67 | const obj: any = {}; 68 | if (message.accounts) { 69 | obj.accounts = message.accounts.map(e => (e ? Account.toJSON(e) : undefined)); 70 | } else { 71 | obj.accounts = []; 72 | } 73 | if (message.payments) { 74 | obj.payments = message.payments.map(e => (e ? Payment.toJSON(e) : undefined)); 75 | } else { 76 | obj.payments = []; 77 | } 78 | return obj; 79 | }, 80 | 81 | fromPartial, I>>(object: I): GenesisState { 82 | const message = createBaseGenesisState(); 83 | message.accounts = object.accounts?.map(e => Account.fromPartial(e)) || []; 84 | message.payments = object.payments?.map(e => Payment.fromPartial(e)) || []; 85 | return message; 86 | } 87 | }; 88 | 89 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 90 | 91 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 92 | 93 | export type DeepPartial = T extends Builtin 94 | ? T 95 | : T extends Long 96 | ? string | number | Long 97 | : T extends Array 98 | ? Array> 99 | : T extends ReadonlyArray 100 | ? ReadonlyArray> 101 | : T extends {} 102 | ? { [K in Exclude]?: DeepPartial } 103 | : Partial; 104 | 105 | type KeysOfUnion = T extends T ? keyof T : never; 106 | export type Exact = P extends Builtin 107 | ? P 108 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 109 | 110 | if (_m0.util.Long !== Long) { 111 | _m0.util.Long = Long as any; 112 | _m0.configure(); 113 | } 114 | -------------------------------------------------------------------------------- /src/protobuf/akash/gov/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { DepositParams } from "./params"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.gov.v1beta3"; 8 | 9 | /** GenesisState stores slice of genesis deployment instance */ 10 | export interface GenesisState { 11 | $type: "akash.gov.v1beta3.GenesisState"; 12 | depositParams: DepositParams | undefined; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.gov.v1beta3.GenesisState", depositParams: undefined }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.gov.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.depositParams !== undefined) { 24 | DepositParams.encode(message.depositParams, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.depositParams = DepositParams.decode(reader, reader.uint32()); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | depositParams: isSet(object.depositParams) ? DepositParams.fromJSON(object.depositParams) : undefined 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | message.depositParams !== undefined && (obj.depositParams = message.depositParams ? DepositParams.toJSON(message.depositParams) : undefined); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): GenesisState { 61 | const message = createBaseGenesisState(); 62 | message.depositParams = object.depositParams !== undefined && object.depositParams !== null ? DepositParams.fromPartial(object.depositParams) : undefined; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/inflation/v1beta2/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Params } from "./params"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.inflation.v1beta2"; 8 | 9 | /** GenesisState stores slice of genesis deployment instance */ 10 | export interface GenesisState { 11 | $type: "akash.inflation.v1beta2.GenesisState"; 12 | params: Params | undefined; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.inflation.v1beta2.GenesisState", params: undefined }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.inflation.v1beta2.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.params !== undefined) { 24 | Params.encode(message.params, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.params = Params.decode(reader, reader.uint32()); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | params: isSet(object.params) ? Params.fromJSON(object.params) : undefined 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): GenesisState { 61 | const message = createBaseGenesisState(); 62 | message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/inflation/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Params } from "./params"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.inflation.v1beta3"; 8 | 9 | /** GenesisState stores slice of genesis deployment instance */ 10 | export interface GenesisState { 11 | $type: "akash.inflation.v1beta3.GenesisState"; 12 | params: Params | undefined; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.inflation.v1beta3.GenesisState", params: undefined }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.inflation.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.params !== undefined) { 24 | Params.encode(message.params, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.params = Params.decode(reader, reader.uint32()); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | params: isSet(object.params) ? Params.fromJSON(object.params) : undefined 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): GenesisState { 61 | const message = createBaseGenesisState(); 62 | message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta1/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import _m0 from "protobufjs/minimal"; 5 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 6 | 7 | export const protobufPackage = "akash.market.v1beta1"; 8 | 9 | /** Params is the params for the x/market module */ 10 | export interface Params { 11 | $type: "akash.market.v1beta1.Params"; 12 | bidMinDeposit?: Coin; 13 | orderMaxBids: number; 14 | } 15 | 16 | function createBaseParams(): Params { 17 | return { 18 | $type: "akash.market.v1beta1.Params", 19 | bidMinDeposit: undefined, 20 | orderMaxBids: 0 21 | }; 22 | } 23 | 24 | export const Params = { 25 | $type: "akash.market.v1beta1.Params" as const, 26 | 27 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 28 | if (message.bidMinDeposit !== undefined) { 29 | Coin.encode(message.bidMinDeposit, writer.uint32(10).fork()).ldelim(); 30 | } 31 | if (message.orderMaxBids !== 0) { 32 | writer.uint32(16).uint32(message.orderMaxBids); 33 | } 34 | return writer; 35 | }, 36 | 37 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 38 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 39 | let end = length === undefined ? reader.len : reader.pos + length; 40 | const message = createBaseParams(); 41 | while (reader.pos < end) { 42 | const tag = reader.uint32(); 43 | switch (tag >>> 3) { 44 | case 1: 45 | message.bidMinDeposit = Coin.decode(reader, reader.uint32()); 46 | break; 47 | case 2: 48 | message.orderMaxBids = reader.uint32(); 49 | break; 50 | default: 51 | reader.skipType(tag & 7); 52 | break; 53 | } 54 | } 55 | return message; 56 | }, 57 | 58 | fromJSON(object: any): Params { 59 | return { 60 | $type: Params.$type, 61 | bidMinDeposit: isSet(object.bidMinDeposit) ? Coin.fromJSON(object.bidMinDeposit) : undefined, 62 | orderMaxBids: isSet(object.orderMaxBids) ? Number(object.orderMaxBids) : 0 63 | }; 64 | }, 65 | 66 | toJSON(message: Params): unknown { 67 | const obj: any = {}; 68 | message.bidMinDeposit !== undefined && (obj.bidMinDeposit = message.bidMinDeposit ? Coin.toJSON(message.bidMinDeposit) : undefined); 69 | message.orderMaxBids !== undefined && (obj.orderMaxBids = Math.round(message.orderMaxBids)); 70 | return obj; 71 | }, 72 | 73 | fromPartial, I>>(object: I): Params { 74 | const message = createBaseParams(); 75 | message.bidMinDeposit = object.bidMinDeposit !== undefined && object.bidMinDeposit !== null ? Coin.fromPartial(object.bidMinDeposit) : undefined; 76 | message.orderMaxBids = object.orderMaxBids ?? 0; 77 | return message; 78 | } 79 | }; 80 | 81 | messageTypeRegistry.set(Params.$type, Params); 82 | 83 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 84 | 85 | export type DeepPartial = T extends Builtin 86 | ? T 87 | : T extends Long 88 | ? string | number | Long 89 | : T extends Array 90 | ? Array> 91 | : T extends ReadonlyArray 92 | ? ReadonlyArray> 93 | : T extends {} 94 | ? { [K in Exclude]?: DeepPartial } 95 | : Partial; 96 | 97 | type KeysOfUnion = T extends T ? keyof T : never; 98 | export type Exact = P extends Builtin 99 | ? P 100 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 101 | 102 | if (_m0.util.Long !== Long) { 103 | _m0.util.Long = Long as any; 104 | _m0.configure(); 105 | } 106 | 107 | function isSet(value: any): boolean { 108 | return value !== null && value !== undefined; 109 | } 110 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta1/service.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import Long from "long"; 3 | import _m0 from "protobufjs/minimal"; 4 | import { MsgCreateBidResponse, MsgCloseBidResponse, MsgCreateBid, MsgCloseBid } from "../../../akash/market/v1beta1/bid"; 5 | import { 6 | MsgWithdrawLeaseResponse, 7 | MsgCreateLeaseResponse, 8 | MsgCloseLeaseResponse, 9 | MsgWithdrawLease, 10 | MsgCreateLease, 11 | MsgCloseLease 12 | } from "../../../akash/market/v1beta1/lease"; 13 | 14 | export const protobufPackage = "akash.market.v1beta1"; 15 | 16 | /** Msg defines the market Msg service */ 17 | export interface Msg { 18 | /** CreateBid defines a method to create a bid given proper inputs. */ 19 | CreateBid(request: MsgCreateBid): Promise; 20 | /** CloseBid defines a method to close a bid given proper inputs. */ 21 | CloseBid(request: MsgCloseBid): Promise; 22 | /** WithdrawLease withdraws accrued funds from the lease payment */ 23 | WithdrawLease(request: MsgWithdrawLease): Promise; 24 | /** CreateLease creates a new lease */ 25 | CreateLease(request: MsgCreateLease): Promise; 26 | /** CloseLease defines a method to close an order given proper inputs. */ 27 | CloseLease(request: MsgCloseLease): Promise; 28 | } 29 | 30 | export class MsgClientImpl implements Msg { 31 | private readonly rpc: Rpc; 32 | constructor(rpc: Rpc) { 33 | this.rpc = rpc; 34 | this.CreateBid = this.CreateBid.bind(this); 35 | this.CloseBid = this.CloseBid.bind(this); 36 | this.WithdrawLease = this.WithdrawLease.bind(this); 37 | this.CreateLease = this.CreateLease.bind(this); 38 | this.CloseLease = this.CloseLease.bind(this); 39 | } 40 | CreateBid(request: MsgCreateBid): Promise { 41 | const data = MsgCreateBid.encode(request).finish(); 42 | const promise = this.rpc.request("akash.market.v1beta1.Msg", "CreateBid", data); 43 | return promise.then(data => MsgCreateBidResponse.decode(new _m0.Reader(data))); 44 | } 45 | 46 | CloseBid(request: MsgCloseBid): Promise { 47 | const data = MsgCloseBid.encode(request).finish(); 48 | const promise = this.rpc.request("akash.market.v1beta1.Msg", "CloseBid", data); 49 | return promise.then(data => MsgCloseBidResponse.decode(new _m0.Reader(data))); 50 | } 51 | 52 | WithdrawLease(request: MsgWithdrawLease): Promise { 53 | const data = MsgWithdrawLease.encode(request).finish(); 54 | const promise = this.rpc.request("akash.market.v1beta1.Msg", "WithdrawLease", data); 55 | return promise.then(data => MsgWithdrawLeaseResponse.decode(new _m0.Reader(data))); 56 | } 57 | 58 | CreateLease(request: MsgCreateLease): Promise { 59 | const data = MsgCreateLease.encode(request).finish(); 60 | const promise = this.rpc.request("akash.market.v1beta1.Msg", "CreateLease", data); 61 | return promise.then(data => MsgCreateLeaseResponse.decode(new _m0.Reader(data))); 62 | } 63 | 64 | CloseLease(request: MsgCloseLease): Promise { 65 | const data = MsgCloseLease.encode(request).finish(); 66 | const promise = this.rpc.request("akash.market.v1beta1.Msg", "CloseLease", data); 67 | return promise.then(data => MsgCloseLeaseResponse.decode(new _m0.Reader(data))); 68 | } 69 | } 70 | 71 | interface Rpc { 72 | request(service: string, method: string, data: Uint8Array): Promise; 73 | } 74 | 75 | if (_m0.util.Long !== Long) { 76 | _m0.util.Long = Long as any; 77 | _m0.configure(); 78 | } 79 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta2/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.market.v1beta2"; 8 | 9 | /** Params is the params for the x/market module */ 10 | export interface Params { 11 | $type: "akash.market.v1beta2.Params"; 12 | bidMinDeposit: Coin | undefined; 13 | orderMaxBids: number; 14 | } 15 | 16 | function createBaseParams(): Params { 17 | return { 18 | $type: "akash.market.v1beta2.Params", 19 | bidMinDeposit: undefined, 20 | orderMaxBids: 0 21 | }; 22 | } 23 | 24 | export const Params = { 25 | $type: "akash.market.v1beta2.Params" as const, 26 | 27 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 28 | if (message.bidMinDeposit !== undefined) { 29 | Coin.encode(message.bidMinDeposit, writer.uint32(10).fork()).ldelim(); 30 | } 31 | if (message.orderMaxBids !== 0) { 32 | writer.uint32(16).uint32(message.orderMaxBids); 33 | } 34 | return writer; 35 | }, 36 | 37 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 38 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 39 | let end = length === undefined ? reader.len : reader.pos + length; 40 | const message = createBaseParams(); 41 | while (reader.pos < end) { 42 | const tag = reader.uint32(); 43 | switch (tag >>> 3) { 44 | case 1: 45 | message.bidMinDeposit = Coin.decode(reader, reader.uint32()); 46 | break; 47 | case 2: 48 | message.orderMaxBids = reader.uint32(); 49 | break; 50 | default: 51 | reader.skipType(tag & 7); 52 | break; 53 | } 54 | } 55 | return message; 56 | }, 57 | 58 | fromJSON(object: any): Params { 59 | return { 60 | $type: Params.$type, 61 | bidMinDeposit: isSet(object.bidMinDeposit) ? Coin.fromJSON(object.bidMinDeposit) : undefined, 62 | orderMaxBids: isSet(object.orderMaxBids) ? Number(object.orderMaxBids) : 0 63 | }; 64 | }, 65 | 66 | toJSON(message: Params): unknown { 67 | const obj: any = {}; 68 | message.bidMinDeposit !== undefined && (obj.bidMinDeposit = message.bidMinDeposit ? Coin.toJSON(message.bidMinDeposit) : undefined); 69 | message.orderMaxBids !== undefined && (obj.orderMaxBids = Math.round(message.orderMaxBids)); 70 | return obj; 71 | }, 72 | 73 | fromPartial, I>>(object: I): Params { 74 | const message = createBaseParams(); 75 | message.bidMinDeposit = object.bidMinDeposit !== undefined && object.bidMinDeposit !== null ? Coin.fromPartial(object.bidMinDeposit) : undefined; 76 | message.orderMaxBids = object.orderMaxBids ?? 0; 77 | return message; 78 | } 79 | }; 80 | 81 | messageTypeRegistry.set(Params.$type, Params); 82 | 83 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 84 | 85 | export type DeepPartial = T extends Builtin 86 | ? T 87 | : T extends Long 88 | ? string | number | Long 89 | : T extends Array 90 | ? Array> 91 | : T extends ReadonlyArray 92 | ? ReadonlyArray> 93 | : T extends {} 94 | ? { [K in Exclude]?: DeepPartial } 95 | : Partial; 96 | 97 | type KeysOfUnion = T extends T ? keyof T : never; 98 | export type Exact = P extends Builtin 99 | ? P 100 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 101 | 102 | if (_m0.util.Long !== Long) { 103 | _m0.util.Long = Long as any; 104 | _m0.configure(); 105 | } 106 | 107 | function isSet(value: any): boolean { 108 | return value !== null && value !== undefined; 109 | } 110 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta2/service.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { MsgCreateBidResponse, MsgCloseBidResponse, MsgCreateBid, MsgCloseBid } from "./bid"; 3 | import { MsgWithdrawLeaseResponse, MsgCreateLeaseResponse, MsgCloseLeaseResponse, MsgWithdrawLease, MsgCreateLease, MsgCloseLease } from "./lease"; 4 | import * as _m0 from "protobufjs/minimal"; 5 | 6 | export const protobufPackage = "akash.market.v1beta2"; 7 | 8 | /** Msg defines the market Msg service */ 9 | export interface Msg { 10 | /** CreateBid defines a method to create a bid given proper inputs. */ 11 | CreateBid(request: MsgCreateBid): Promise; 12 | /** CloseBid defines a method to close a bid given proper inputs. */ 13 | CloseBid(request: MsgCloseBid): Promise; 14 | /** WithdrawLease withdraws accrued funds from the lease payment */ 15 | WithdrawLease(request: MsgWithdrawLease): Promise; 16 | /** CreateLease creates a new lease */ 17 | CreateLease(request: MsgCreateLease): Promise; 18 | /** CloseLease defines a method to close an order given proper inputs. */ 19 | CloseLease(request: MsgCloseLease): Promise; 20 | } 21 | 22 | export class MsgClientImpl implements Msg { 23 | private readonly rpc: Rpc; 24 | constructor(rpc: Rpc) { 25 | this.rpc = rpc; 26 | this.CreateBid = this.CreateBid.bind(this); 27 | this.CloseBid = this.CloseBid.bind(this); 28 | this.WithdrawLease = this.WithdrawLease.bind(this); 29 | this.CreateLease = this.CreateLease.bind(this); 30 | this.CloseLease = this.CloseLease.bind(this); 31 | } 32 | CreateBid(request: MsgCreateBid): Promise { 33 | const data = MsgCreateBid.encode(request).finish(); 34 | const promise = this.rpc.request("akash.market.v1beta2.Msg", "CreateBid", data); 35 | return promise.then(data => MsgCreateBidResponse.decode(new _m0.Reader(data))); 36 | } 37 | 38 | CloseBid(request: MsgCloseBid): Promise { 39 | const data = MsgCloseBid.encode(request).finish(); 40 | const promise = this.rpc.request("akash.market.v1beta2.Msg", "CloseBid", data); 41 | return promise.then(data => MsgCloseBidResponse.decode(new _m0.Reader(data))); 42 | } 43 | 44 | WithdrawLease(request: MsgWithdrawLease): Promise { 45 | const data = MsgWithdrawLease.encode(request).finish(); 46 | const promise = this.rpc.request("akash.market.v1beta2.Msg", "WithdrawLease", data); 47 | return promise.then(data => MsgWithdrawLeaseResponse.decode(new _m0.Reader(data))); 48 | } 49 | 50 | CreateLease(request: MsgCreateLease): Promise { 51 | const data = MsgCreateLease.encode(request).finish(); 52 | const promise = this.rpc.request("akash.market.v1beta2.Msg", "CreateLease", data); 53 | return promise.then(data => MsgCreateLeaseResponse.decode(new _m0.Reader(data))); 54 | } 55 | 56 | CloseLease(request: MsgCloseLease): Promise { 57 | const data = MsgCloseLease.encode(request).finish(); 58 | const promise = this.rpc.request("akash.market.v1beta2.Msg", "CloseLease", data); 59 | return promise.then(data => MsgCloseLeaseResponse.decode(new _m0.Reader(data))); 60 | } 61 | } 62 | 63 | interface Rpc { 64 | request(service: string, method: string, data: Uint8Array): Promise; 65 | } 66 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta3/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.market.v1beta3"; 8 | 9 | /** Params is the params for the x/market module */ 10 | export interface Params { 11 | $type: "akash.market.v1beta3.Params"; 12 | bidMinDeposit: Coin | undefined; 13 | orderMaxBids: number; 14 | } 15 | 16 | function createBaseParams(): Params { 17 | return { 18 | $type: "akash.market.v1beta3.Params", 19 | bidMinDeposit: undefined, 20 | orderMaxBids: 0 21 | }; 22 | } 23 | 24 | export const Params = { 25 | $type: "akash.market.v1beta3.Params" as const, 26 | 27 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 28 | if (message.bidMinDeposit !== undefined) { 29 | Coin.encode(message.bidMinDeposit, writer.uint32(10).fork()).ldelim(); 30 | } 31 | if (message.orderMaxBids !== 0) { 32 | writer.uint32(16).uint32(message.orderMaxBids); 33 | } 34 | return writer; 35 | }, 36 | 37 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 38 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 39 | let end = length === undefined ? reader.len : reader.pos + length; 40 | const message = createBaseParams(); 41 | while (reader.pos < end) { 42 | const tag = reader.uint32(); 43 | switch (tag >>> 3) { 44 | case 1: 45 | message.bidMinDeposit = Coin.decode(reader, reader.uint32()); 46 | break; 47 | case 2: 48 | message.orderMaxBids = reader.uint32(); 49 | break; 50 | default: 51 | reader.skipType(tag & 7); 52 | break; 53 | } 54 | } 55 | return message; 56 | }, 57 | 58 | fromJSON(object: any): Params { 59 | return { 60 | $type: Params.$type, 61 | bidMinDeposit: isSet(object.bidMinDeposit) ? Coin.fromJSON(object.bidMinDeposit) : undefined, 62 | orderMaxBids: isSet(object.orderMaxBids) ? Number(object.orderMaxBids) : 0 63 | }; 64 | }, 65 | 66 | toJSON(message: Params): unknown { 67 | const obj: any = {}; 68 | message.bidMinDeposit !== undefined && (obj.bidMinDeposit = message.bidMinDeposit ? Coin.toJSON(message.bidMinDeposit) : undefined); 69 | message.orderMaxBids !== undefined && (obj.orderMaxBids = Math.round(message.orderMaxBids)); 70 | return obj; 71 | }, 72 | 73 | fromPartial, I>>(object: I): Params { 74 | const message = createBaseParams(); 75 | message.bidMinDeposit = object.bidMinDeposit !== undefined && object.bidMinDeposit !== null ? Coin.fromPartial(object.bidMinDeposit) : undefined; 76 | message.orderMaxBids = object.orderMaxBids ?? 0; 77 | return message; 78 | } 79 | }; 80 | 81 | messageTypeRegistry.set(Params.$type, Params); 82 | 83 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 84 | 85 | export type DeepPartial = T extends Builtin 86 | ? T 87 | : T extends Long 88 | ? string | number | Long 89 | : T extends Array 90 | ? Array> 91 | : T extends ReadonlyArray 92 | ? ReadonlyArray> 93 | : T extends {} 94 | ? { [K in Exclude]?: DeepPartial } 95 | : Partial; 96 | 97 | type KeysOfUnion = T extends T ? keyof T : never; 98 | export type Exact = P extends Builtin 99 | ? P 100 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 101 | 102 | if (_m0.util.Long !== Long) { 103 | _m0.util.Long = Long as any; 104 | _m0.configure(); 105 | } 106 | 107 | function isSet(value: any): boolean { 108 | return value !== null && value !== undefined; 109 | } 110 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta3/service.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { MsgCreateBidResponse, MsgCloseBidResponse, MsgCreateBid, MsgCloseBid } from "./bid"; 3 | import { MsgWithdrawLeaseResponse, MsgCreateLeaseResponse, MsgCloseLeaseResponse, MsgWithdrawLease, MsgCreateLease, MsgCloseLease } from "./lease"; 4 | import * as _m0 from "protobufjs/minimal"; 5 | 6 | export const protobufPackage = "akash.market.v1beta3"; 7 | 8 | /** Msg defines the market Msg service */ 9 | export interface Msg { 10 | /** CreateBid defines a method to create a bid given proper inputs. */ 11 | CreateBid(request: MsgCreateBid): Promise; 12 | /** CloseBid defines a method to close a bid given proper inputs. */ 13 | CloseBid(request: MsgCloseBid): Promise; 14 | /** WithdrawLease withdraws accrued funds from the lease payment */ 15 | WithdrawLease(request: MsgWithdrawLease): Promise; 16 | /** CreateLease creates a new lease */ 17 | CreateLease(request: MsgCreateLease): Promise; 18 | /** CloseLease defines a method to close an order given proper inputs. */ 19 | CloseLease(request: MsgCloseLease): Promise; 20 | } 21 | 22 | export class MsgClientImpl implements Msg { 23 | private readonly rpc: Rpc; 24 | constructor(rpc: Rpc) { 25 | this.rpc = rpc; 26 | this.CreateBid = this.CreateBid.bind(this); 27 | this.CloseBid = this.CloseBid.bind(this); 28 | this.WithdrawLease = this.WithdrawLease.bind(this); 29 | this.CreateLease = this.CreateLease.bind(this); 30 | this.CloseLease = this.CloseLease.bind(this); 31 | } 32 | CreateBid(request: MsgCreateBid): Promise { 33 | const data = MsgCreateBid.encode(request).finish(); 34 | const promise = this.rpc.request("akash.market.v1beta3.Msg", "CreateBid", data); 35 | return promise.then(data => MsgCreateBidResponse.decode(new _m0.Reader(data))); 36 | } 37 | 38 | CloseBid(request: MsgCloseBid): Promise { 39 | const data = MsgCloseBid.encode(request).finish(); 40 | const promise = this.rpc.request("akash.market.v1beta3.Msg", "CloseBid", data); 41 | return promise.then(data => MsgCloseBidResponse.decode(new _m0.Reader(data))); 42 | } 43 | 44 | WithdrawLease(request: MsgWithdrawLease): Promise { 45 | const data = MsgWithdrawLease.encode(request).finish(); 46 | const promise = this.rpc.request("akash.market.v1beta3.Msg", "WithdrawLease", data); 47 | return promise.then(data => MsgWithdrawLeaseResponse.decode(new _m0.Reader(data))); 48 | } 49 | 50 | CreateLease(request: MsgCreateLease): Promise { 51 | const data = MsgCreateLease.encode(request).finish(); 52 | const promise = this.rpc.request("akash.market.v1beta3.Msg", "CreateLease", data); 53 | return promise.then(data => MsgCreateLeaseResponse.decode(new _m0.Reader(data))); 54 | } 55 | 56 | CloseLease(request: MsgCloseLease): Promise { 57 | const data = MsgCloseLease.encode(request).finish(); 58 | const promise = this.rpc.request("akash.market.v1beta3.Msg", "CloseLease", data); 59 | return promise.then(data => MsgCloseLeaseResponse.decode(new _m0.Reader(data))); 60 | } 61 | } 62 | 63 | interface Rpc { 64 | request(service: string, method: string, data: Uint8Array): Promise; 65 | } 66 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta4/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Coin } from "../../../cosmos/base/v1beta1/coin"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.market.v1beta4"; 8 | 9 | /** Params is the params for the x/market module */ 10 | export interface Params { 11 | $type: "akash.market.v1beta4.Params"; 12 | bidMinDeposit: Coin | undefined; 13 | orderMaxBids: number; 14 | } 15 | 16 | function createBaseParams(): Params { 17 | return { 18 | $type: "akash.market.v1beta4.Params", 19 | bidMinDeposit: undefined, 20 | orderMaxBids: 0 21 | }; 22 | } 23 | 24 | export const Params = { 25 | $type: "akash.market.v1beta4.Params" as const, 26 | 27 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 28 | if (message.bidMinDeposit !== undefined) { 29 | Coin.encode(message.bidMinDeposit, writer.uint32(10).fork()).ldelim(); 30 | } 31 | if (message.orderMaxBids !== 0) { 32 | writer.uint32(16).uint32(message.orderMaxBids); 33 | } 34 | return writer; 35 | }, 36 | 37 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 38 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 39 | let end = length === undefined ? reader.len : reader.pos + length; 40 | const message = createBaseParams(); 41 | while (reader.pos < end) { 42 | const tag = reader.uint32(); 43 | switch (tag >>> 3) { 44 | case 1: 45 | message.bidMinDeposit = Coin.decode(reader, reader.uint32()); 46 | break; 47 | case 2: 48 | message.orderMaxBids = reader.uint32(); 49 | break; 50 | default: 51 | reader.skipType(tag & 7); 52 | break; 53 | } 54 | } 55 | return message; 56 | }, 57 | 58 | fromJSON(object: any): Params { 59 | return { 60 | $type: Params.$type, 61 | bidMinDeposit: isSet(object.bidMinDeposit) ? Coin.fromJSON(object.bidMinDeposit) : undefined, 62 | orderMaxBids: isSet(object.orderMaxBids) ? Number(object.orderMaxBids) : 0 63 | }; 64 | }, 65 | 66 | toJSON(message: Params): unknown { 67 | const obj: any = {}; 68 | message.bidMinDeposit !== undefined && (obj.bidMinDeposit = message.bidMinDeposit ? Coin.toJSON(message.bidMinDeposit) : undefined); 69 | message.orderMaxBids !== undefined && (obj.orderMaxBids = Math.round(message.orderMaxBids)); 70 | return obj; 71 | }, 72 | 73 | fromPartial, I>>(object: I): Params { 74 | const message = createBaseParams(); 75 | message.bidMinDeposit = object.bidMinDeposit !== undefined && object.bidMinDeposit !== null ? Coin.fromPartial(object.bidMinDeposit) : undefined; 76 | message.orderMaxBids = object.orderMaxBids ?? 0; 77 | return message; 78 | } 79 | }; 80 | 81 | messageTypeRegistry.set(Params.$type, Params); 82 | 83 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 84 | 85 | export type DeepPartial = T extends Builtin 86 | ? T 87 | : T extends Long 88 | ? string | number | Long 89 | : T extends Array 90 | ? Array> 91 | : T extends ReadonlyArray 92 | ? ReadonlyArray> 93 | : T extends {} 94 | ? { [K in Exclude]?: DeepPartial } 95 | : Partial; 96 | 97 | type KeysOfUnion = T extends T ? keyof T : never; 98 | export type Exact = P extends Builtin 99 | ? P 100 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 101 | 102 | if (_m0.util.Long !== Long) { 103 | _m0.util.Long = Long as any; 104 | _m0.configure(); 105 | } 106 | 107 | function isSet(value: any): boolean { 108 | return value !== null && value !== undefined; 109 | } 110 | -------------------------------------------------------------------------------- /src/protobuf/akash/market/v1beta4/service.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { MsgCreateBidResponse, MsgCloseBidResponse, MsgCreateBid, MsgCloseBid } from "./bid"; 3 | import { MsgWithdrawLeaseResponse, MsgCreateLeaseResponse, MsgCloseLeaseResponse, MsgWithdrawLease, MsgCreateLease, MsgCloseLease } from "./lease"; 4 | import * as _m0 from "protobufjs/minimal"; 5 | 6 | export const protobufPackage = "akash.market.v1beta4"; 7 | 8 | /** Msg defines the market Msg service */ 9 | export interface Msg { 10 | /** CreateBid defines a method to create a bid given proper inputs. */ 11 | CreateBid(request: MsgCreateBid): Promise; 12 | /** CloseBid defines a method to close a bid given proper inputs. */ 13 | CloseBid(request: MsgCloseBid): Promise; 14 | /** WithdrawLease withdraws accrued funds from the lease payment */ 15 | WithdrawLease(request: MsgWithdrawLease): Promise; 16 | /** CreateLease creates a new lease */ 17 | CreateLease(request: MsgCreateLease): Promise; 18 | /** CloseLease defines a method to close an order given proper inputs. */ 19 | CloseLease(request: MsgCloseLease): Promise; 20 | } 21 | 22 | export class MsgClientImpl implements Msg { 23 | private readonly rpc: Rpc; 24 | constructor(rpc: Rpc) { 25 | this.rpc = rpc; 26 | this.CreateBid = this.CreateBid.bind(this); 27 | this.CloseBid = this.CloseBid.bind(this); 28 | this.WithdrawLease = this.WithdrawLease.bind(this); 29 | this.CreateLease = this.CreateLease.bind(this); 30 | this.CloseLease = this.CloseLease.bind(this); 31 | } 32 | CreateBid(request: MsgCreateBid): Promise { 33 | const data = MsgCreateBid.encode(request).finish(); 34 | const promise = this.rpc.request("akash.market.v1beta4.Msg", "CreateBid", data); 35 | return promise.then(data => MsgCreateBidResponse.decode(new _m0.Reader(data))); 36 | } 37 | 38 | CloseBid(request: MsgCloseBid): Promise { 39 | const data = MsgCloseBid.encode(request).finish(); 40 | const promise = this.rpc.request("akash.market.v1beta4.Msg", "CloseBid", data); 41 | return promise.then(data => MsgCloseBidResponse.decode(new _m0.Reader(data))); 42 | } 43 | 44 | WithdrawLease(request: MsgWithdrawLease): Promise { 45 | const data = MsgWithdrawLease.encode(request).finish(); 46 | const promise = this.rpc.request("akash.market.v1beta4.Msg", "WithdrawLease", data); 47 | return promise.then(data => MsgWithdrawLeaseResponse.decode(new _m0.Reader(data))); 48 | } 49 | 50 | CreateLease(request: MsgCreateLease): Promise { 51 | const data = MsgCreateLease.encode(request).finish(); 52 | const promise = this.rpc.request("akash.market.v1beta4.Msg", "CreateLease", data); 53 | return promise.then(data => MsgCreateLeaseResponse.decode(new _m0.Reader(data))); 54 | } 55 | 56 | CloseLease(request: MsgCloseLease): Promise { 57 | const data = MsgCloseLease.encode(request).finish(); 58 | const promise = this.rpc.request("akash.market.v1beta4.Msg", "CloseLease", data); 59 | return promise.then(data => MsgCloseLeaseResponse.decode(new _m0.Reader(data))); 60 | } 61 | } 62 | 63 | interface Rpc { 64 | request(service: string, method: string, data: Uint8Array): Promise; 65 | } 66 | -------------------------------------------------------------------------------- /src/protobuf/akash/provider/v1beta1/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import _m0 from "protobufjs/minimal"; 5 | import { Provider } from "../../../akash/provider/v1beta1/provider"; 6 | 7 | export const protobufPackage = "akash.provider.v1beta1"; 8 | 9 | /** GenesisState defines the basic genesis state used by provider module */ 10 | export interface GenesisState { 11 | $type: "akash.provider.v1beta1.GenesisState"; 12 | providers: Provider[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.provider.v1beta1.GenesisState", providers: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.provider.v1beta1.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.providers) { 24 | Provider.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.providers.push(Provider.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.providers) { 57 | obj.providers = message.providers.map(e => (e ? Provider.toJSON(e) : undefined)); 58 | } else { 59 | obj.providers = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/provider/v1beta2/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Provider } from "./provider"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.provider.v1beta2"; 8 | 9 | /** GenesisState defines the basic genesis state used by provider module */ 10 | export interface GenesisState { 11 | $type: "akash.provider.v1beta2.GenesisState"; 12 | providers: Provider[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.provider.v1beta2.GenesisState", providers: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.provider.v1beta2.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.providers) { 24 | Provider.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.providers.push(Provider.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.providers) { 57 | obj.providers = message.providers.map(e => (e ? Provider.toJSON(e) : undefined)); 58 | } else { 59 | obj.providers = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/provider/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Provider } from "./provider"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.provider.v1beta3"; 8 | 9 | /** GenesisState defines the basic genesis state used by provider module */ 10 | export interface GenesisState { 11 | $type: "akash.provider.v1beta3.GenesisState"; 12 | providers: Provider[]; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.provider.v1beta3.GenesisState", providers: [] }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.provider.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | for (const v of message.providers) { 24 | Provider.encode(v!, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.providers.push(Provider.decode(reader, reader.uint32())); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | providers: Array.isArray(object?.providers) ? object.providers.map((e: any) => Provider.fromJSON(e)) : [] 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | if (message.providers) { 57 | obj.providers = message.providers.map(e => (e ? Provider.toJSON(e) : undefined)); 58 | } else { 59 | obj.providers = []; 60 | } 61 | return obj; 62 | }, 63 | 64 | fromPartial, I>>(object: I): GenesisState { 65 | const message = createBaseGenesisState(); 66 | message.providers = object.providers?.map(e => Provider.fromPartial(e)) || []; 67 | return message; 68 | } 69 | }; 70 | 71 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 72 | 73 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 74 | 75 | export type DeepPartial = T extends Builtin 76 | ? T 77 | : T extends Long 78 | ? string | number | Long 79 | : T extends Array 80 | ? Array> 81 | : T extends ReadonlyArray 82 | ? ReadonlyArray> 83 | : T extends {} 84 | ? { [K in Exclude]?: DeepPartial } 85 | : Partial; 86 | 87 | type KeysOfUnion = T extends T ? keyof T : never; 88 | export type Exact = P extends Builtin 89 | ? P 90 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 91 | 92 | if (_m0.util.Long !== Long) { 93 | _m0.util.Long = Long as any; 94 | _m0.configure(); 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/staking/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Params } from "./params"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.staking.v1beta3"; 8 | 9 | /** GenesisState stores slice of genesis deployment instance */ 10 | export interface GenesisState { 11 | $type: "akash.staking.v1beta3.GenesisState"; 12 | params: Params | undefined; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.staking.v1beta3.GenesisState", params: undefined }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.staking.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.params !== undefined) { 24 | Params.encode(message.params, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.params = Params.decode(reader, reader.uint32()); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | params: isSet(object.params) ? Params.fromJSON(object.params) : undefined 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): GenesisState { 61 | const message = createBaseGenesisState(); 62 | message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/staking/v1beta3/params.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import * as _m0 from "protobufjs/minimal"; 5 | 6 | export const protobufPackage = "akash.staking.v1beta3"; 7 | 8 | /** Params extends the parameters for the x/staking module */ 9 | export interface Params { 10 | $type: "akash.staking.v1beta3.Params"; 11 | /** min_commission_rate is the chain-wide minimum commission rate that a validator can charge their delegators */ 12 | minCommissionRate: string; 13 | } 14 | 15 | function createBaseParams(): Params { 16 | return { $type: "akash.staking.v1beta3.Params", minCommissionRate: "" }; 17 | } 18 | 19 | export const Params = { 20 | $type: "akash.staking.v1beta3.Params" as const, 21 | 22 | encode(message: Params, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.minCommissionRate !== "") { 24 | writer.uint32(10).string(message.minCommissionRate); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): Params { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseParams(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.minCommissionRate = reader.string(); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): Params { 48 | return { 49 | $type: Params.$type, 50 | minCommissionRate: isSet(object.minCommissionRate) ? String(object.minCommissionRate) : "" 51 | }; 52 | }, 53 | 54 | toJSON(message: Params): unknown { 55 | const obj: any = {}; 56 | message.minCommissionRate !== undefined && (obj.minCommissionRate = message.minCommissionRate); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): Params { 61 | const message = createBaseParams(); 62 | message.minCommissionRate = object.minCommissionRate ?? ""; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(Params.$type, Params); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/take/v1beta3/genesis.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import { messageTypeRegistry } from "../../../typeRegistry"; 3 | import Long from "long"; 4 | import { Params } from "./params"; 5 | import * as _m0 from "protobufjs/minimal"; 6 | 7 | export const protobufPackage = "akash.take.v1beta3"; 8 | 9 | /** GenesisState stores slice of genesis deployment instance */ 10 | export interface GenesisState { 11 | $type: "akash.take.v1beta3.GenesisState"; 12 | params: Params | undefined; 13 | } 14 | 15 | function createBaseGenesisState(): GenesisState { 16 | return { $type: "akash.take.v1beta3.GenesisState", params: undefined }; 17 | } 18 | 19 | export const GenesisState = { 20 | $type: "akash.take.v1beta3.GenesisState" as const, 21 | 22 | encode(message: GenesisState, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { 23 | if (message.params !== undefined) { 24 | Params.encode(message.params, writer.uint32(10).fork()).ldelim(); 25 | } 26 | return writer; 27 | }, 28 | 29 | decode(input: _m0.Reader | Uint8Array, length?: number): GenesisState { 30 | const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); 31 | let end = length === undefined ? reader.len : reader.pos + length; 32 | const message = createBaseGenesisState(); 33 | while (reader.pos < end) { 34 | const tag = reader.uint32(); 35 | switch (tag >>> 3) { 36 | case 1: 37 | message.params = Params.decode(reader, reader.uint32()); 38 | break; 39 | default: 40 | reader.skipType(tag & 7); 41 | break; 42 | } 43 | } 44 | return message; 45 | }, 46 | 47 | fromJSON(object: any): GenesisState { 48 | return { 49 | $type: GenesisState.$type, 50 | params: isSet(object.params) ? Params.fromJSON(object.params) : undefined 51 | }; 52 | }, 53 | 54 | toJSON(message: GenesisState): unknown { 55 | const obj: any = {}; 56 | message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); 57 | return obj; 58 | }, 59 | 60 | fromPartial, I>>(object: I): GenesisState { 61 | const message = createBaseGenesisState(); 62 | message.params = object.params !== undefined && object.params !== null ? Params.fromPartial(object.params) : undefined; 63 | return message; 64 | } 65 | }; 66 | 67 | messageTypeRegistry.set(GenesisState.$type, GenesisState); 68 | 69 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 70 | 71 | export type DeepPartial = T extends Builtin 72 | ? T 73 | : T extends Long 74 | ? string | number | Long 75 | : T extends Array 76 | ? Array> 77 | : T extends ReadonlyArray 78 | ? ReadonlyArray> 79 | : T extends {} 80 | ? { [K in Exclude]?: DeepPartial } 81 | : Partial; 82 | 83 | type KeysOfUnion = T extends T ? keyof T : never; 84 | export type Exact = P extends Builtin 85 | ? P 86 | : P & { [K in keyof P]: Exact } & Record | "$type">, never>; 87 | 88 | if (_m0.util.Long !== Long) { 89 | _m0.util.Long = Long as any; 90 | _m0.configure(); 91 | } 92 | 93 | function isSet(value: any): boolean { 94 | return value !== null && value !== undefined; 95 | } 96 | -------------------------------------------------------------------------------- /src/protobuf/akash/take/v1beta3/query.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const protobufPackage = "akash.take.v1beta3"; 3 | 4 | /** Query defines the gRPC querier service */ 5 | export interface Query {} 6 | 7 | export class QueryClientImpl implements Query { 8 | private readonly rpc: Rpc; 9 | constructor(rpc: Rpc) { 10 | this.rpc = rpc; 11 | } 12 | } 13 | 14 | interface Rpc { 15 | request(service: string, method: string, data: Uint8Array): Promise; 16 | } 17 | -------------------------------------------------------------------------------- /src/protobuf/cosmos_proto/cosmos.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const protobufPackage = "cosmos_proto"; 3 | -------------------------------------------------------------------------------- /src/protobuf/gogoproto/gogo.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const protobufPackage = "gogoproto"; 3 | -------------------------------------------------------------------------------- /src/protobuf/google/api/annotations.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | export const protobufPackage = "google.api"; 3 | -------------------------------------------------------------------------------- /src/protobuf/typeRegistry.ts: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import * as _m0 from "protobufjs/minimal"; 3 | import Long from "long"; 4 | 5 | export interface MessageType { 6 | $type: Message["$type"]; 7 | encode(message: Message, writer?: _m0.Writer): _m0.Writer; 8 | decode(input: _m0.Reader | Uint8Array, length?: number): Message; 9 | fromJSON(object: any): Message; 10 | toJSON(message: Message): unknown; 11 | fromPartial(object: DeepPartial): Message; 12 | } 13 | 14 | export type UnknownMessage = { $type: string }; 15 | 16 | export const messageTypeRegistry = new Map(); 17 | 18 | type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; 19 | export type DeepPartial = T extends Builtin 20 | ? T 21 | : T extends Long 22 | ? string | number | Long 23 | : T extends Array 24 | ? Array> 25 | : T extends ReadonlyArray 26 | ? ReadonlyArray> 27 | : T extends {} 28 | ? { [K in Exclude]?: DeepPartial } 29 | : Partial; 30 | -------------------------------------------------------------------------------- /src/rpc/index.ts: -------------------------------------------------------------------------------- 1 | import { createProtobufRpcClient, GasPrice, QueryClient, SigningStargateClient, SigningStargateClientOptions } from "@cosmjs/stargate"; 2 | import { getAkashTypeRegistry } from "../stargate"; 3 | import { OfflineSigner, Registry } from "@cosmjs/proto-signing"; 4 | import { Tendermint34Client } from "@cosmjs/tendermint-rpc"; 5 | 6 | /** 7 | * Gets an RPC client for interacting with the Akash network 8 | * @param {string} endpoint - The RPC endpoint URL to connect to 9 | * @returns {Promise>} A protobuf RPC client instance 10 | * @throws {Error} If connection to the endpoint fails 11 | */ 12 | export async function getRpc(endpoint: string) { 13 | return getQueryClient(endpoint); 14 | } 15 | 16 | /** 17 | * Creates a query client for making read-only requests to the Akash network 18 | * @param {string} endpoint - The RPC endpoint URL to connect to 19 | * @returns {Promise>} A protobuf RPC client for queries 20 | * @throws {Error} If connection to the endpoint fails 21 | */ 22 | export async function getQueryClient(endpoint: string) { 23 | const tmClient = await Tendermint34Client.connect(endpoint); 24 | const queryClient = new QueryClient(tmClient); 25 | return createProtobufRpcClient(queryClient); 26 | } 27 | 28 | /** 29 | * Creates a message client for sending transactions to the Akash network 30 | * @param {string} endpoint - The RPC endpoint URL to connect to 31 | * @param {OfflineSigner} signer - The signer used to sign transactions 32 | * @returns {Promise} A client for signing and sending transactions 33 | * @throws {Error} If connection to the endpoint fails or if there are issues with the signer 34 | */ 35 | export async function getMsgClient(endpoint: string, signer: OfflineSigner) { 36 | const msgRegistry = new Registry(getAkashTypeRegistry()); 37 | const options: SigningStargateClientOptions = { 38 | registry: msgRegistry, 39 | gasPrice: GasPrice.fromString("0.025uakt") 40 | }; 41 | 42 | return SigningStargateClient.connectWithSigner(endpoint, signer, options); 43 | } 44 | -------------------------------------------------------------------------------- /src/sdl/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * SDL (Stack Definition Language) module exports 3 | * Provides functionality for parsing and validating Akash deployment manifests 4 | * 5 | * @example 6 | * ```ts 7 | * import { SDL } from './sdl'; 8 | * 9 | * const yaml = ` 10 | * version: "2.0" 11 | * services: 12 | * web: 13 | * image: nginx 14 | * expose: 15 | * - port: 80 16 | * as: 80 17 | * to: 18 | * - global: true 19 | * `; 20 | * 21 | * const sdl = SDL.fromString(yaml); 22 | * const manifest = sdl.manifest(); 23 | * ``` 24 | */ 25 | export * from "./SDL/SDL"; 26 | -------------------------------------------------------------------------------- /src/sdl/sizes.ts: -------------------------------------------------------------------------------- 1 | const prefixes = "kmgtpe".split(""); 2 | 3 | /** 4 | * Converts resource strings like "1k", "5gi", "10m" to their numeric values 5 | * @example 6 | * ```ts 7 | * convertResourceString("1k") // Returns 1000 8 | * convertResourceString("5gi") // Returns 5368709120 9 | * convertResourceString("10m") // Returns 10000000 10 | * ``` 11 | */ 12 | export function convertResourceString(resourceStr: string): number { 13 | const [value, prefix, unit] = parseSizeString(resourceStr.toLowerCase()); 14 | const power = prefixes.indexOf(prefix); 15 | const base = unit === "i" ? 1024 : 1000; 16 | 17 | return power !== -1 ? value * Math.pow(base, power + 1) : value; 18 | } 19 | 20 | /** 21 | * Converts CPU resource strings to their millicpu values 22 | * @example 23 | * ```ts 24 | * convertCpuResourceString("1") // Returns 1000 25 | * convertCpuResourceString("500m") // Returns 500 26 | * ``` 27 | */ 28 | export function convertCpuResourceString(resourceStr: string): number { 29 | const [value, unit] = parseCpuResourceString(resourceStr.toLowerCase()); 30 | 31 | if (unit === "m") { 32 | return value; 33 | } 34 | 35 | return value * 1000; 36 | } 37 | 38 | /** 39 | * Parses a size string into value and unit components 40 | * @internal 41 | */ 42 | function parseSizeString(size: string): [number, string, string] { 43 | const regex = /^([\d.]+)([a-zA-Z])([a-zA-Z]*)$/; 44 | const match = size.match(regex); 45 | 46 | if (match) { 47 | const [, value, unit1, unit2] = match; 48 | return [parseFloat(value), unit1.toLowerCase(), unit2.toLowerCase()]; 49 | } 50 | 51 | throw new Error(`Invalid size string: ${size}`); 52 | } 53 | 54 | /** 55 | * Parses a CPU resource string into value and unit components 56 | * @internal 57 | */ 58 | function parseCpuResourceString(size: string): [number, string] { 59 | const regex = /^([\d.]+)([a-zA-Z]*)$/; 60 | const match = size.match(regex); 61 | 62 | if (match) { 63 | const [, value, unit1] = match; 64 | return [parseFloat(value), unit1.toLowerCase()]; 65 | } 66 | 67 | throw new Error(`Invalid size string: ${size}`); 68 | } 69 | -------------------------------------------------------------------------------- /src/stargate/index.ts: -------------------------------------------------------------------------------- 1 | import { MessageType, messageTypeRegistry, UnknownMessage } from "@akashnetwork/akash-api/typeRegistry"; 2 | 3 | /** 4 | * Retrieves the Akash type registry. 5 | * @returns An array of tuples containing the type URL and the corresponding message type. 6 | */ 7 | export const getAkashTypeRegistry: () => [string, MessageType][] = () => 8 | Array.from(messageTypeRegistry).map(([path, type]) => [`/${path}`, type]); 9 | 10 | /** 11 | * Gets the type URL for a given message type. 12 | * @param type - The message type for which to get the URL. 13 | * @returns The URL string for the specified message type. 14 | */ 15 | export const getTypeUrl: (type: MessageType) => string = type => `/${type.$type}`; 16 | 17 | /** 18 | * Enum for Akash message types. 19 | * @enum {string} 20 | */ 21 | export enum Message { 22 | /** Message type for creating a certificate. */ 23 | MsgCreateCertificate = "/akash.cert.v1beta3.MsgCreateCertificate", 24 | /** Message type for revoking a certificate. */ 25 | MsgRevokeCertificate = "/akash.cert.v1beta3.MsgRevokeCertificate", 26 | /** Message type for creating a deployment. */ 27 | MsgCreateDeployment = "/akash.deployment.v1beta3.MsgCreateDeployment", 28 | /** Message type for closing a deployment. */ 29 | MsgCloseDeployment = "/akash.deployment.v1beta3.MsgCloseDeployment", 30 | /** Message type for depositing into a deployment. */ 31 | MsgDepositDeployment = "/akash.deployment.v1beta3.MsgDepositDeployment", 32 | /** Message type for updating a deployment. */ 33 | MsgUpdateDeployment = "/akash.deployment.v1beta3.MsgUpdateDeployment", 34 | /** Message type for closing a group. */ 35 | MsgCloseGroup = "/akash.deployment.v1beta3.MsgCloseGroup", 36 | /** Message type for pausing a group. */ 37 | MsgPauseGroup = "/akash.deployment.v1beta3.MsgPauseGroup", 38 | /** Message type for starting a group. */ 39 | MsgStartGroup = "/akash.deployment.v1beta3.MsgStartGroup", 40 | /** Message type for creating a lease. */ 41 | MsgCreateLease = "/akash.market.v1beta4.MsgCreateLease" 42 | } 43 | -------------------------------------------------------------------------------- /src/types/global.d.ts: -------------------------------------------------------------------------------- 1 | import { OfflineDirectSigner, OfflineSigner } from "@cosmjs/proto-signing"; 2 | 3 | export {}; 4 | 5 | declare global { 6 | /** 7 | * Extends the Window interface to include Keplr wallet integration methods. 8 | * @interface Window 9 | */ 10 | interface Window { 11 | /** 12 | * Gets an offline signer for automatic signing of transactions. 13 | * This method is injected by the Keplr wallet extension. 14 | * 15 | * @param {string} chainId - The chain ID of the network to connect to 16 | * @returns {Promise} A promise that resolves to either an OfflineSigner or OfflineDirectSigner 17 | * @throws {Error} If Keplr wallet is not installed or user rejects the connection 18 | * 19 | * @example 20 | * const signer = await window.getOfflineSignerAuto("cosmoshub-4"); 21 | */ 22 | getOfflineSignerAuto: (chainId: string) => Promise; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/types/network.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Type representing the mainnet network identifier. 3 | * Used for production environment connections. 4 | */ 5 | export type MainnetNetworkId = "mainnet"; 6 | 7 | /** 8 | * Type representing the testnet network identifier. 9 | * Used for testing and development purposes. 10 | */ 11 | export type TestnetNetworkId = "testnet"; 12 | 13 | /** 14 | * Type representing the sandbox network identifier. 15 | * Used for local development and testing. 16 | */ 17 | export type SandboxNetworkId = "sandbox"; 18 | 19 | /** 20 | * Union type combining all possible network identifiers. 21 | * Can be either "mainnet", "testnet", or "sandbox". 22 | * @typedef {MainnetNetworkId | TestnetNetworkId | SandboxNetworkId} NetworkId 23 | */ 24 | export type NetworkId = MainnetNetworkId | TestnetNetworkId | SandboxNetworkId; 25 | -------------------------------------------------------------------------------- /src/util.ts: -------------------------------------------------------------------------------- 1 | export const prop = (key: string) => (context: any) => context[key]; 2 | 3 | export const sortBy = (evalFn: (arg0: any) => any) => (xs: any[]) => xs.sort((a, b) => evalFn(a) - evalFn(b)); 4 | 5 | export const map = (fn: any) => (xs: any[]) => xs.map(fn); 6 | 7 | export const filter = (fn: any) => (xs: any[]) => xs.filter(fn); 8 | 9 | export const awaitAll = Promise.all.bind(Promise); 10 | -------------------------------------------------------------------------------- /src/wallet/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Wallet management functionality for Akash Network 3 | * @module wallet 4 | */ 5 | 6 | import { Secp256k1HdWallet } from "@cosmjs/launchpad"; 7 | import keytar from "keytar"; 8 | 9 | let wallet: any; 10 | 11 | /** 12 | * Creates a new wallet account 13 | * @returns {Promise<{mnemonic: string, address: string}>} The newly created wallet's mnemonic and address 14 | */ 15 | export async function createAccount() { 16 | wallet = await Secp256k1HdWallet.generate(undefined, { prefix: "akash" }); 17 | const [{ address }] = await wallet.getAccounts(); 18 | keytar.setPassword("AkashNetwork", address, wallet.mnemonic); 19 | return { 20 | mnemonic: wallet.mnemonic, 21 | address 22 | }; 23 | } 24 | 25 | /** 26 | * Imports an existing wallet using a mnemonic phrase 27 | * @param {string} mnemonic - The mnemonic phrase to import 28 | * @returns {Promise} The imported wallet accounts 29 | */ 30 | export async function importAccount(mnemonic: string) { 31 | wallet = await Secp256k1HdWallet.fromMnemonic(mnemonic); 32 | const accounts = await wallet.getAccounts(); 33 | return accounts; 34 | } 35 | 36 | /** 37 | * Retrieves a wallet account by address 38 | * @param {string} address - The address of the account to retrieve 39 | * @returns {Promise} The wallet accounts 40 | */ 41 | export async function getAccount(address: string) { 42 | const mnemonic: any = await keytar.getPassword("AkashNetwork", address); 43 | return importAccount(mnemonic); 44 | } 45 | 46 | /** 47 | * Gets the most recently loaded wallet 48 | * @returns {Promise} The last loaded wallet instance 49 | */ 50 | export async function getLastLoaded() { 51 | return wallet; 52 | } 53 | -------------------------------------------------------------------------------- /src/wallet/storage.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Browser storage implementation to replace keytar functionality 3 | * @module wallet/storage 4 | */ 5 | 6 | /** 7 | * Gets a stored password/mnemonic 8 | * @returns {Promise} The stored test mnemonic 9 | */ 10 | export async function getPassword() { 11 | console.log("keytar fill"); 12 | return "click harvest range include miss vessel permit kiss clarify now grocery assist"; 13 | } 14 | 15 | /** 16 | * Sets a password/mnemonic in storage 17 | * @returns {Promise} 18 | */ 19 | export async function setPassword() {} 20 | 21 | export default { 22 | getPassword, 23 | setPassword 24 | }; 25 | -------------------------------------------------------------------------------- /src/webpack/crypto.ts: -------------------------------------------------------------------------------- 1 | const crypto = window?.crypto; 2 | 3 | export default crypto; 4 | -------------------------------------------------------------------------------- /src/webpack/perf_hooks.ts: -------------------------------------------------------------------------------- 1 | const performance = window?.performance; 2 | 3 | export default performance; 4 | -------------------------------------------------------------------------------- /tap-snapshots/tests/test_sdl_gpu.ts.test.cjs: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`tests/test_sdl_gpu.ts TAP SDL: GPU Version > Manifest version matches expected result 1`] = ` 9 | Uint8Array [ 10 | 111, 11 | 250, 12 | 3, 13 | 51, 14 | 238, 15 | 33, 16 | 176, 17 | 251, 18 | 28, 19 | 239, 20 | 51, 21 | 143, 22 | 144, 23 | 183, 24 | 207, 25 | 220, 26 | 163, 27 | 146, 28 | 232, 29 | 250, 30 | 77, 31 | 2, 32 | 152, 33 | 132, 34 | 190, 35 | 248, 36 | 131, 37 | 169, 38 | 120, 39 | 12, 40 | 181, 41 | 208, 42 | ] 43 | ` 44 | -------------------------------------------------------------------------------- /tap-snapshots/tests/test_sdl_gpu_ram.ts.test.cjs: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`tests/test_sdl_gpu_ram.ts TAP SDL: GPU Version with ram > Manifest version matches expected result 1`] = ` 9 | Uint8Array [ 10 | 123, 11 | 116, 12 | 14, 13 | 51, 14 | 6, 15 | 102, 16 | 163, 17 | 189, 18 | 102, 19 | 39, 20 | 107, 21 | 0, 22 | 213, 23 | 171, 24 | 201, 25 | 136, 26 | 51, 27 | 16, 28 | 16, 29 | 241, 30 | 252, 31 | 98, 32 | 21, 33 | 229, 34 | 89, 35 | 194, 36 | 116, 37 | 63, 38 | 222, 39 | 235, 40 | 167, 41 | 21, 42 | ] 43 | ` 44 | -------------------------------------------------------------------------------- /tap-snapshots/tests/test_sdl_gpu_vendor_only.ts.test.cjs: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`tests/test_sdl_gpu_vendor_only.ts TAP SDL: GPU Manifest > Manifest matches expected result 1`] = ` 9 | Array [ 10 | Object { 11 | "name": "westcoast", 12 | "services": Array [ 13 | Object { 14 | "args": null, 15 | "command": null, 16 | "count": 2, 17 | "credentials": null, 18 | "env": null, 19 | "expose": Array [ 20 | Object { 21 | "endpointSequenceNumber": 0, 22 | "externalPort": 0, 23 | "global": true, 24 | "hosts": Array [ 25 | "ahostname.com", 26 | ], 27 | "httpOptions": Object { 28 | "maxBodySize": 1048576, 29 | "nextCases": Array [ 30 | "error", 31 | "timeout", 32 | ], 33 | "nextTimeout": 0, 34 | "nextTries": 3, 35 | "readTimeout": 60000, 36 | "sendTimeout": 60000, 37 | }, 38 | "ip": "", 39 | "port": 80, 40 | "proto": "TCP", 41 | "service": "", 42 | }, 43 | Object { 44 | "endpointSequenceNumber": 0, 45 | "externalPort": 0, 46 | "global": true, 47 | "hosts": null, 48 | "httpOptions": Object { 49 | "maxBodySize": 1048576, 50 | "nextCases": Array [ 51 | "error", 52 | "timeout", 53 | ], 54 | "nextTimeout": 0, 55 | "nextTries": 3, 56 | "readTimeout": 60000, 57 | "sendTimeout": 60000, 58 | }, 59 | "ip": "", 60 | "port": 12345, 61 | "proto": "UDP", 62 | "service": "", 63 | }, 64 | ], 65 | "image": "nginx", 66 | "name": "web", 67 | "params": null, 68 | "resources": Object { 69 | "cpu": Object { 70 | "units": Object { 71 | "val": "100", 72 | }, 73 | }, 74 | "endpoints": Array [ 75 | Object { 76 | "sequence_number": 0, 77 | }, 78 | Object { 79 | "kind": 1, 80 | "sequence_number": 0, 81 | }, 82 | ], 83 | "gpu": Object { 84 | "attributes": Array [ 85 | Object { 86 | "key": "vendor/nvidia/model/*", 87 | "value": "true", 88 | }, 89 | ], 90 | "units": Object { 91 | "val": 1, 92 | }, 93 | }, 94 | "id": 1, 95 | "memory": Object { 96 | "size": Object { 97 | "val": 134217728, 98 | }, 99 | }, 100 | "storage": Array [ 101 | Object { 102 | "name": "default", 103 | "size": Object { 104 | "val": 1073741824, 105 | }, 106 | }, 107 | ], 108 | }, 109 | }, 110 | ], 111 | }, 112 | ] 113 | ` 114 | 115 | exports[`tests/test_sdl_gpu_vendor_only.ts TAP SDL: GPU Version > Manifest version matches expected result 1`] = ` 116 | Uint8Array [ 117 | 79, 118 | 131, 119 | 204, 120 | 202, 121 | 111, 122 | 169, 123 | 0, 124 | 170, 125 | 30, 126 | 162, 127 | 78, 128 | 181, 129 | 13, 130 | 28, 131 | 54, 132 | 223, 133 | 45, 134 | 8, 135 | 100, 136 | 93, 137 | 19, 138 | 118, 139 | 61, 140 | 156, 141 | 163, 142 | 120, 143 | 168, 144 | 62, 145 | 173, 146 | 73, 147 | 142, 148 | 112, 149 | ] 150 | ` 151 | -------------------------------------------------------------------------------- /tap-snapshots/tests/test_sdl_ip_lease.ts.test.cjs: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`tests/test_sdl_ip_lease.ts TAP SDL: IP Lease Manifest > Manifest matches expected result 1`] = ` 9 | Array [ 10 | Object { 11 | "Name": "dcloud", 12 | "Services": Array [ 13 | Object { 14 | "Args": null, 15 | "Command": null, 16 | "Count": 1, 17 | "Env": null, 18 | "Expose": Array [ 19 | Object { 20 | "EndpointSequenceNumber": 1, 21 | "ExternalPort": 80, 22 | "Global": true, 23 | "Hosts": null, 24 | "HTTPOptions": Object { 25 | "MaxBodySize": 1048576, 26 | "NextCases": Array [ 27 | "error", 28 | "timeout", 29 | ], 30 | "NextTimeout": 0, 31 | "NextTries": 3, 32 | "ReadTimeout": 60000, 33 | "SendTimeout": 60000, 34 | }, 35 | "IP": "myendpoint", 36 | "Port": 3000, 37 | "Proto": "TCP", 38 | "Service": "", 39 | }, 40 | ], 41 | "Image": "akashlytics/hello-akash-world:0.2.0", 42 | "Name": "web", 43 | "Resources": Object { 44 | "cpu": Object { 45 | "units": Object { 46 | "val": "500", 47 | }, 48 | }, 49 | "endpoints": Array [ 50 | Object { 51 | "kind": 2, 52 | "sequence_number": 1, 53 | }, 54 | ], 55 | "memory": Object { 56 | "size": Object { 57 | "val": 536870912, 58 | }, 59 | }, 60 | "storage": Array [ 61 | Object { 62 | "name": "default", 63 | "size": Object { 64 | "val": 536870912, 65 | }, 66 | }, 67 | ], 68 | }, 69 | }, 70 | ], 71 | }, 72 | ] 73 | ` 74 | -------------------------------------------------------------------------------- /tap-snapshots/tests/test_sdl_v3_resources.ts.test.cjs: -------------------------------------------------------------------------------- 1 | /* IMPORTANT 2 | * This snapshot file is auto-generated, but designed for humans. 3 | * It should be checked into source control and tracked carefully. 4 | * Re-generate by setting TAP_SNAPSHOT=1 and running tests. 5 | * Make sure to inspect the output below. Do not ignore changes! 6 | */ 7 | 'use strict' 8 | exports[`tests/test_sdl_v3_resources.ts TAP SDL: Create v3 Resource Groups > Groups matches expected result 1`] = ` 9 | Array [ 10 | Object { 11 | "name": "westcoast", 12 | "requirements": Object { 13 | "attributes": Array [ 14 | Object { 15 | "key": "foo", 16 | "value": "bar", 17 | }, 18 | Object { 19 | "key": "region", 20 | "value": "us-west", 21 | }, 22 | ], 23 | "signedBy": Object { 24 | "allOf": Array [ 25 | 3, 26 | 4, 27 | ], 28 | "anyOf": Array [ 29 | 1, 30 | 2, 31 | ], 32 | }, 33 | }, 34 | "resources": Array [ 35 | Object { 36 | "count": 2, 37 | "price": Object { 38 | "amount": "50", 39 | "denom": "uakt", 40 | }, 41 | "resource": Object { 42 | "cpu": Object { 43 | "attributes": undefined, 44 | "units": Object { 45 | "val": Uint8Array [ 46 | 49, 47 | 48, 48 | 48, 49 | ], 50 | }, 51 | }, 52 | "endpoints": Array [ 53 | Object { 54 | "sequence_number": 0, 55 | }, 56 | Object { 57 | "kind": 1, 58 | "sequence_number": 0, 59 | }, 60 | ], 61 | "gpu": Object { 62 | "attributes": Array [ 63 | Object { 64 | "key": "vendor/nvidia/model/a100", 65 | "value": "true", 66 | }, 67 | ], 68 | "units": Object { 69 | "val": Uint8Array [ 70 | 49, 71 | ], 72 | }, 73 | }, 74 | "id": 1, 75 | "memory": Object { 76 | "attributes": undefined, 77 | "quantity": Object { 78 | "val": Uint8Array [ 79 | 49, 80 | 51, 81 | 52, 82 | 50, 83 | 49, 84 | 55, 85 | 55, 86 | 50, 87 | 56, 88 | ], 89 | }, 90 | }, 91 | "storage": Array [ 92 | Object { 93 | "attributes": undefined, 94 | "name": "default", 95 | "quantity": Object { 96 | "val": Uint8Array [ 97 | 49, 98 | 48, 99 | 55, 100 | 51, 101 | 55, 102 | 52, 103 | 49, 104 | 56, 105 | 50, 106 | 52, 107 | ], 108 | }, 109 | }, 110 | ], 111 | }, 112 | }, 113 | ], 114 | }, 115 | ] 116 | ` 117 | -------------------------------------------------------------------------------- /test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 9 |

10 | 11 | 12 | 13 | 14 | 67 | 68 | -------------------------------------------------------------------------------- /test/fixtures/groups-basic-snapshot.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "dcloud", 4 | "resources": [ 5 | { 6 | "resource": { 7 | "endpoints": [ 8 | { 9 | "sequence_number": 0 10 | } 11 | ], 12 | "cpu": { 13 | "units": { 14 | "val": { 15 | "0": 53, 16 | "1": 48, 17 | "2": 48 18 | } 19 | } 20 | }, 21 | "memory": { 22 | "quantity": { 23 | "val": { 24 | "0": 53, 25 | "1": 51, 26 | "2": 54, 27 | "3": 56, 28 | "4": 55, 29 | "5": 48, 30 | "6": 57, 31 | "7": 49, 32 | "8": 50 33 | } 34 | } 35 | }, 36 | "storage": [ 37 | { 38 | "name": "default", 39 | "quantity": { 40 | "val": { 41 | "0": 53, 42 | "1": 51, 43 | "2": 54, 44 | "3": 56, 45 | "4": 55, 46 | "5": 48, 47 | "6": 57, 48 | "7": 49, 49 | "8": 50 50 | } 51 | } 52 | } 53 | ], 54 | "gpu": { 55 | "units": { 56 | "val": { 57 | "0": 48 58 | } 59 | } 60 | }, 61 | "id": 1 62 | }, 63 | "price": { 64 | "denom": "uakt", 65 | "amount": "1000" 66 | }, 67 | "count": 1 68 | } 69 | ], 70 | "requirements": { 71 | "attributes": [], 72 | "signedBy": { 73 | "allOf": [], 74 | "anyOf": [] 75 | } 76 | } 77 | } 78 | ] 79 | -------------------------------------------------------------------------------- /test/fixtures/manifest-basic-snapshot.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "dcloud", 4 | "services": [ 5 | { 6 | "name": "web", 7 | "image": "akashlytics/hello-akash-world:0.2.0", 8 | "command": null, 9 | "args": null, 10 | "env": null, 11 | "resources": { 12 | "id": 1, 13 | "cpu": { 14 | "units": { 15 | "val": "500" 16 | } 17 | }, 18 | "memory": { 19 | "size": { 20 | "val": 536870912 21 | } 22 | }, 23 | "storage": [ 24 | { 25 | "name": "default", 26 | "size": { 27 | "val": 536870912 28 | } 29 | } 30 | ], 31 | "endpoints": [ 32 | { 33 | "sequence_number": 0 34 | } 35 | ], 36 | "gpu": { 37 | "units": { 38 | "val": 0 39 | } 40 | } 41 | }, 42 | "count": 1, 43 | "expose": [ 44 | { 45 | "port": 3000, 46 | "externalPort": 80, 47 | "proto": "TCP", 48 | "service": "", 49 | "global": true, 50 | "hosts": null, 51 | "httpOptions": { 52 | "maxBodySize": 1048576, 53 | "readTimeout": 60000, 54 | "sendTimeout": 60000, 55 | "nextTries": 3, 56 | "nextTimeout": 0, 57 | "nextCases": ["error", "timeout"] 58 | }, 59 | "ip": "", 60 | "endpointSequenceNumber": 0 61 | } 62 | ], 63 | "params": null, 64 | "credentials": null 65 | } 66 | ] 67 | } 68 | ] 69 | -------------------------------------------------------------------------------- /test/fixtures/sdl-basic.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0", 3 | "services": { 4 | "web": { 5 | "image": "akashlytics/hello-akash-world:0.2.0", 6 | "expose": [ 7 | { 8 | "port": 3000, 9 | "as": 80, 10 | "to": [ 11 | { 12 | "global": true 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | }, 19 | "profiles": { 20 | "compute": { 21 | "web": { 22 | "resources": { 23 | "cpu": { 24 | "units": 0.5 25 | }, 26 | "memory": { 27 | "size": "512Mi" 28 | }, 29 | "storage": { 30 | "size": "512Mi" 31 | } 32 | } 33 | } 34 | }, 35 | "placement": { 36 | "dcloud": { 37 | "pricing": { 38 | "web": { 39 | "denom": "uakt", 40 | "amount": 1000 41 | } 42 | } 43 | } 44 | } 45 | }, 46 | "deployment": { 47 | "web": { 48 | "dcloud": { 49 | "profile": "web", 50 | "count": 1 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /test/setup-unit-tests.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akash-network/akashjs/e65fd7a88e8af0341041bd6abfd3ec6a8ebfcf5a/test/setup-unit-tests.ts -------------------------------------------------------------------------------- /test/setup.ts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/akash-network/akashjs/e65fd7a88e8af0341041bd6abfd3ec6a8ebfcf5a/test/setup.ts -------------------------------------------------------------------------------- /test/templates.ts: -------------------------------------------------------------------------------- 1 | import { dump } from "js-yaml"; 2 | import update, { CustomCommands, Spec } from "immutability-helper"; 3 | import dot from "dot-object"; 4 | 5 | import groupsBasic from "./fixtures/groups-basic-snapshot.json"; 6 | import manifestBasic from "./fixtures/manifest-basic-snapshot.json"; 7 | import sdlBasic from "./fixtures/sdl-basic.json"; 8 | import { v2Sdl } from "../src/sdl/types"; 9 | 10 | type AnySpec = Spec>; 11 | 12 | export const createSdlJson = ($spec: AnySpec = {}): v2Sdl => { 13 | return update(sdlBasic, dot.object($spec)) as unknown as v2Sdl; 14 | }; 15 | 16 | export const createSdlYml = ($spec: AnySpec = {}): string => { 17 | return dump(createSdlJson($spec), { forceQuotes: true, quotingType: '"' }); 18 | }; 19 | 20 | export const createManifest = ($spec: AnySpec = {}) => { 21 | return update(manifestBasic, dot.object($spec) as AnySpec); 22 | }; 23 | 24 | export const createGroups = ($spec: AnySpec = {}) => { 25 | return update(groupsBasic, dot.object($spec) as AnySpec); 26 | }; 27 | -------------------------------------------------------------------------------- /tests/__snapshots__/sdl_gpu_ram_interface.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`test GPU with interface SDL: GPU Version with ram & interface (snapshot): Manifest version matches expected result 1`] = ` 4 | Uint8Array [ 5 | 162, 6 | 8, 7 | 51, 8 | 138, 9 | 226, 10 | 67, 11 | 148, 12 | 236, 13 | 175, 14 | 65, 15 | 207, 16 | 31, 17 | 215, 18 | 174, 19 | 241, 20 | 69, 21 | 120, 22 | 159, 23 | 139, 24 | 72, 25 | 2, 26 | 24, 27 | 7, 28 | 93, 29 | 95, 30 | 128, 31 | 162, 32 | 159, 33 | 210, 34 | 200, 35 | 56, 36 | 178, 37 | ] 38 | `; 39 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic.manifest.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "westcoast", 4 | "services": [ 5 | { 6 | "name": "web", 7 | "image": "nginx", 8 | "command": null, 9 | "args": null, 10 | "env": null, 11 | "resources": { 12 | "id": 1, 13 | "cpu": { 14 | "units": { 15 | "val": "100" 16 | } 17 | }, 18 | "memory": { 19 | "size": { 20 | "val": "134217728" 21 | } 22 | }, 23 | "storage": [ 24 | { 25 | "name": "default", 26 | "size": { 27 | "val": "1073741824" 28 | } 29 | } 30 | ], 31 | "gpu": { 32 | "units": { 33 | "val": "1" 34 | }, 35 | "attributes": [ 36 | { 37 | "key": "vendor/nvidia/model/a100", 38 | "value": "true" 39 | } 40 | ] 41 | }, 42 | "endpoints": [ 43 | { 44 | "sequence_number": 0 45 | }, 46 | { 47 | "kind": 1, 48 | "sequence_number": 0 49 | } 50 | ] 51 | }, 52 | "count": 2, 53 | "expose": [ 54 | { 55 | "port": 80, 56 | "externalPort": 0, 57 | "proto": "TCP", 58 | "service": "", 59 | "global": true, 60 | "hosts": ["ahostname.com"], 61 | "httpOptions": { 62 | "maxBodySize": 1048576, 63 | "readTimeout": 60000, 64 | "sendTimeout": 60000, 65 | "nextTries": 3, 66 | "nextTimeout": 0, 67 | "nextCases": ["error", "timeout"] 68 | }, 69 | "ip": "", 70 | "endpointSequenceNumber": 0 71 | }, 72 | { 73 | "port": 12345, 74 | "externalPort": 0, 75 | "proto": "UDP", 76 | "service": "", 77 | "global": true, 78 | "hosts": null, 79 | "httpOptions": { 80 | "maxBodySize": 1048576, 81 | "readTimeout": 60000, 82 | "sendTimeout": 60000, 83 | "nextTries": 3, 84 | "nextTimeout": 0, 85 | "nextCases": ["error", "timeout"] 86 | }, 87 | "ip": "", 88 | "endpointSequenceNumber": 0 89 | } 90 | ], 91 | "params": null, 92 | "credentials": null 93 | } 94 | ] 95 | } 96 | ] 97 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | nvidia: 26 | - model: a100 27 | memory: 28 | size: "128Mi" 29 | storage: 30 | - size: "1Gi" 31 | placement: 32 | westcoast: 33 | attributes: 34 | region: us-west 35 | foo: bar 36 | signedBy: 37 | anyOf: 38 | - 1 39 | - 2 40 | allOf: 41 | - 3 42 | - 4 43 | pricing: 44 | web: 45 | denom: uakt 46 | amount: 50 47 | deployment: 48 | web: 49 | westcoast: 50 | profile: web 51 | count: 2 52 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic_no_model.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | nvidia: 26 | memory: 27 | size: "128Mi" 28 | storage: 29 | - size: "1Gi" 30 | placement: 31 | westcoast: 32 | attributes: 33 | region: us-west 34 | foo: bar 35 | signedBy: 36 | anyOf: 37 | - 1 38 | - 2 39 | allOf: 40 | - 3 41 | - 4 42 | pricing: 43 | web: 44 | denom: uakt 45 | amount: 50 46 | deployment: 47 | web: 48 | westcoast: 49 | profile: web 50 | count: 2 51 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic_ram.manifest.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "westcoast", 4 | "services": [ 5 | { 6 | "name": "web", 7 | "image": "nginx", 8 | "command": null, 9 | "args": null, 10 | "env": null, 11 | "resources": { 12 | "id": 1, 13 | "cpu": { 14 | "units": { 15 | "val": "100" 16 | } 17 | }, 18 | "memory": { 19 | "size": { 20 | "val": "134217728" 21 | } 22 | }, 23 | "storage": [ 24 | { 25 | "name": "default", 26 | "size": { 27 | "val": "1073741824" 28 | } 29 | } 30 | ], 31 | "gpu": { 32 | "units": { 33 | "val": "1" 34 | }, 35 | "attributes": [ 36 | { 37 | "key": "vendor/nvidia/model/a100/ram/40Gi", 38 | "value": "true" 39 | } 40 | ] 41 | }, 42 | "endpoints": [ 43 | { 44 | "sequence_number": 0 45 | }, 46 | { 47 | "kind": 1, 48 | "sequence_number": 0 49 | } 50 | ] 51 | }, 52 | "count": 2, 53 | "expose": [ 54 | { 55 | "port": 80, 56 | "externalPort": 0, 57 | "proto": "TCP", 58 | "service": "", 59 | "global": true, 60 | "hosts": ["ahostname.com"], 61 | "httpOptions": { 62 | "maxBodySize": 1048576, 63 | "readTimeout": 60000, 64 | "sendTimeout": 60000, 65 | "nextTries": 3, 66 | "nextTimeout": 0, 67 | "nextCases": ["error", "timeout"] 68 | }, 69 | "ip": "", 70 | "endpointSequenceNumber": 0 71 | }, 72 | { 73 | "port": 12345, 74 | "externalPort": 0, 75 | "proto": "UDP", 76 | "service": "", 77 | "global": true, 78 | "hosts": null, 79 | "httpOptions": { 80 | "maxBodySize": 1048576, 81 | "readTimeout": 60000, 82 | "sendTimeout": 60000, 83 | "nextTries": 3, 84 | "nextTimeout": 0, 85 | "nextCases": ["error", "timeout"] 86 | }, 87 | "ip": "", 88 | "endpointSequenceNumber": 0 89 | } 90 | ], 91 | "params": null, 92 | "credentials": null 93 | } 94 | ] 95 | } 96 | ] 97 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic_ram.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | nvidia: 26 | - model: a100 27 | ram: 40Gi 28 | memory: 29 | size: "128Mi" 30 | storage: 31 | - size: "1Gi" 32 | placement: 33 | westcoast: 34 | attributes: 35 | region: us-west 36 | foo: bar 37 | signedBy: 38 | anyOf: 39 | - 1 40 | - 2 41 | allOf: 42 | - 3 43 | - 4 44 | pricing: 45 | web: 46 | denom: uakt 47 | amount: 50 48 | deployment: 49 | web: 50 | westcoast: 51 | profile: web 52 | count: 2 53 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic_ram_interface.manifest.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "westcoast", 4 | "services": [ 5 | { 6 | "name": "web", 7 | "image": "nginx", 8 | "command": null, 9 | "args": null, 10 | "env": null, 11 | "resources": { 12 | "id": 1, 13 | "cpu": { 14 | "units": { 15 | "val": "100" 16 | } 17 | }, 18 | "memory": { 19 | "size": { 20 | "val": 134217728 21 | } 22 | }, 23 | "storage": [ 24 | { 25 | "name": "default", 26 | "size": { 27 | "val": 1073741824 28 | } 29 | } 30 | ], 31 | "gpu": { 32 | "units": { 33 | "val": 1 34 | }, 35 | "attributes": [ 36 | { 37 | "key": "vendor/nvidia/model/a100/ram/40Gi/interface/pcie", 38 | "value": "true" 39 | } 40 | ] 41 | }, 42 | "endpoints": [ 43 | { 44 | "sequence_number": 0 45 | }, 46 | { 47 | "kind": 1, 48 | "sequence_number": 0 49 | } 50 | ] 51 | }, 52 | "count": 2, 53 | "expose": [ 54 | { 55 | "port": 80, 56 | "externalPort": 0, 57 | "proto": "TCP", 58 | "service": "", 59 | "global": true, 60 | "hosts": ["ahostname.com"], 61 | "httpOptions": { 62 | "maxBodySize": 1048576, 63 | "readTimeout": 60000, 64 | "sendTimeout": 60000, 65 | "nextTries": 3, 66 | "nextTimeout": 0, 67 | "nextCases": ["error", "timeout"] 68 | }, 69 | "ip": "", 70 | "endpointSequenceNumber": 0 71 | }, 72 | { 73 | "port": 12345, 74 | "externalPort": 0, 75 | "proto": "UDP", 76 | "service": "", 77 | "global": true, 78 | "hosts": null, 79 | "httpOptions": { 80 | "maxBodySize": 1048576, 81 | "readTimeout": 60000, 82 | "sendTimeout": 60000, 83 | "nextTries": 3, 84 | "nextTimeout": 0, 85 | "nextCases": ["error", "timeout"] 86 | }, 87 | "ip": "", 88 | "endpointSequenceNumber": 0 89 | } 90 | ], 91 | "params": null, 92 | "credentials": null 93 | } 94 | ] 95 | } 96 | ] 97 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_basic_ram_interface.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | nvidia: 26 | - model: a100 27 | ram: 40Gi 28 | interface: pcie 29 | memory: 30 | size: "128Mi" 31 | storage: 32 | - size: "1Gi" 33 | placement: 34 | westcoast: 35 | attributes: 36 | region: us-west 37 | foo: bar 38 | signedBy: 39 | anyOf: 40 | - 1 41 | - 2 42 | allOf: 43 | - 3 44 | - 4 45 | pricing: 46 | web: 47 | denom: uakt 48 | amount: 50 49 | deployment: 50 | web: 51 | westcoast: 52 | profile: web 53 | count: 2 54 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_invalid_interface.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | nvidia: 26 | - model: a100 27 | interface: sxm4 28 | memory: 29 | size: "128Mi" 30 | storage: 31 | - size: "1Gi" 32 | placement: 33 | westcoast: 34 | attributes: 35 | region: us-west 36 | blalbla: foo 37 | signedBy: 38 | anyOf: 39 | - 1 40 | - 2 41 | allOf: 42 | - 3 43 | - 4 44 | pricing: 45 | web: 46 | denom: uakt 47 | amount: 50 48 | deployment: 49 | web: 50 | westcoast: 51 | profile: web 52 | count: 2 53 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_invalid_no_attributes.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | memory: 24 | size: "128Mi" 25 | storage: 26 | - size: "1Gi" 27 | placement: 28 | westcoast: 29 | attributes: 30 | region: us-west 31 | blalbla: foo 32 | signedBy: 33 | anyOf: 34 | - 1 35 | - 2 36 | allOf: 37 | - 3 38 | - 4 39 | pricing: 40 | web: 41 | denom: uakt 42 | amount: 50 43 | deployment: 44 | web: 45 | westcoast: 46 | profile: web 47 | count: 2 48 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_invalid_no_vendor.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: {} 24 | memory: 25 | size: "128Mi" 26 | storage: 27 | - size: "1Gi" 28 | placement: 29 | westcoast: 30 | attributes: 31 | region: us-west 32 | blalbla: foo 33 | signedBy: 34 | anyOf: 35 | - 1 36 | - 2 37 | allOf: 38 | - 3 39 | - 4 40 | pricing: 41 | web: 42 | denom: uakt 43 | amount: 50 44 | deployment: 45 | web: 46 | westcoast: 47 | profile: web 48 | count: 2 49 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_invalid_no_vendor_name.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: {} 25 | memory: 26 | size: "128Mi" 27 | storage: 28 | - size: "1Gi" 29 | placement: 30 | westcoast: 31 | attributes: 32 | region: us-west 33 | blalbla: foo 34 | signedBy: 35 | anyOf: 36 | - 1 37 | - 2 38 | allOf: 39 | - 3 40 | - 4 41 | pricing: 42 | web: 43 | denom: uakt 44 | amount: 50 45 | deployment: 46 | web: 47 | westcoast: 48 | profile: web 49 | count: 2 50 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_invalid_vendor.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 1 23 | attributes: 24 | vendor: 25 | invalidvendor: 26 | memory: 27 | size: "128Mi" 28 | storage: 29 | - size: "1Gi" 30 | placement: 31 | westcoast: 32 | attributes: 33 | region: us-west 34 | foo: bar 35 | signedBy: 36 | anyOf: 37 | - 1 38 | - 2 39 | allOf: 40 | - 3 41 | - 4 42 | pricing: 43 | web: 44 | denom: uakt 45 | amount: 50 46 | deployment: 47 | web: 48 | westcoast: 49 | profile: web 50 | count: 2 51 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_no_gpu_invalid_has_attributes.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 0 23 | attributes: {} 24 | memory: 25 | size: "128Mi" 26 | storage: 27 | - size: "1Gi" 28 | placement: 29 | westcoast: 30 | attributes: 31 | region: us-west 32 | blalbla: foo 33 | signedBy: 34 | anyOf: 35 | - 1 36 | - 2 37 | allOf: 38 | - 3 39 | - 4 40 | pricing: 41 | web: 42 | denom: uakt 43 | amount: 50 44 | deployment: 45 | web: 46 | westcoast: 47 | profile: web 48 | count: 2 49 | -------------------------------------------------------------------------------- /tests/fixtures/gpu_no_gpu_valid.sdl.yml: -------------------------------------------------------------------------------- 1 | version: "2.0" 2 | services: 3 | web: 4 | image: nginx 5 | expose: 6 | - port: 80 7 | accept: 8 | - ahostname.com 9 | to: 10 | - global: true 11 | - port: 12345 12 | to: 13 | - global: true 14 | proto: udp 15 | profiles: 16 | compute: 17 | web: 18 | resources: 19 | cpu: 20 | units: "100m" 21 | gpu: 22 | units: 0 23 | memory: 24 | size: "128Mi" 25 | storage: 26 | - size: "1Gi" 27 | placement: 28 | westcoast: 29 | attributes: 30 | region: us-west 31 | blalbla: foo 32 | signedBy: 33 | anyOf: 34 | - 1 35 | - 2 36 | allOf: 37 | - 3 38 | - 4 39 | pricing: 40 | web: 41 | denom: uakt 42 | amount: 50 43 | deployment: 44 | web: 45 | westcoast: 46 | profile: web 47 | count: 2 48 | -------------------------------------------------------------------------------- /tests/fixtures/ip_lease_valid.sdl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | endpoints: 5 | myendpoint: 6 | kind: ip 7 | 8 | services: 9 | web: 10 | image: akashlytics/hello-akash-world:0.2.0 11 | expose: 12 | - port: 3000 13 | as: 80 14 | to: 15 | - global: true 16 | ip: "myendpoint" 17 | 18 | profiles: 19 | compute: 20 | web: 21 | resources: 22 | cpu: 23 | units: 0.5 24 | memory: 25 | size: 512Mi 26 | storage: 27 | size: 512Mi 28 | 29 | placement: 30 | dcloud: 31 | pricing: 32 | web: 33 | denom: uakt 34 | amount: 1000 35 | 36 | deployment: 37 | web: 38 | dcloud: 39 | profile: web 40 | count: 1 -------------------------------------------------------------------------------- /tests/fixtures/persistent_storage_invalid.sdl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: "2.0" 3 | 4 | services: 5 | grafana: 6 | image: grafana/grafana 7 | expose: 8 | - port: 3000 9 | as: 80 10 | to: 11 | - global: true 12 | accept: 13 | - webdistest.localhost 14 | params: 15 | storage: 16 | data: 17 | mount: /var/lib/grafana 18 | shm: 19 | mount: /dev/shm 20 | profiles: 21 | compute: 22 | grafana: 23 | resources: 24 | cpu: 25 | units: 1 26 | memory: 27 | size: 1Gi 28 | storage: 29 | - size: 512Mi 30 | - name: data 31 | size: 1Gi 32 | attributes: 33 | persistent: true 34 | class: beta2 35 | - name: shm 36 | size: 1Gi 37 | attributes: 38 | persistent: true 39 | class: ram 40 | placement: 41 | westcoast: 42 | attributes: 43 | region: us-west 44 | pricing: 45 | grafana: 46 | denom: uakt 47 | amount: 1000 48 | deployment: 49 | grafana: 50 | westcoast: 51 | profile: grafana 52 | count: 1 -------------------------------------------------------------------------------- /tests/fixtures/persistent_storage_valid.sdl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '2.0' 3 | services: 4 | wordpress: 5 | image: wordpress 6 | depends_on: 7 | - db 8 | expose: 9 | - port: 80 10 | http_options: 11 | max_body_size: 104857600 12 | # accept: 13 | # - "example.com" 14 | to: 15 | - global: true 16 | env: 17 | - WORDPRESS_DB_HOST=db 18 | - WORDPRESS_DB_USER=wordpress 19 | - WORDPRESS_DB_PASSWORD=testpass4you 20 | - WORDPRESS_DB_NAME=wordpress 21 | params: 22 | storage: 23 | wordpress-data: 24 | mount: /var/www/html 25 | readOnly: false 26 | db: 27 | # We use a mariadb image which supports both amd64 & arm64 architecture 28 | image: mariadb:10.6.4 29 | # If you really want to use MySQL, uncomment the following line 30 | #image: mysql:8.0.27 31 | expose: 32 | - port: 3306 33 | to: 34 | - service: wordpress 35 | - port: 33060 36 | to: 37 | - service: wordpress 38 | env: 39 | - MYSQL_RANDOM_ROOT_PASSWORD=1 40 | - MYSQL_DATABASE=wordpress 41 | - MYSQL_USER=wordpress 42 | - MYSQL_PASSWORD=testpass4you 43 | params: 44 | storage: 45 | wordpress-db: 46 | mount: /var/lib/mysql 47 | readOnly: false 48 | shm: 49 | mount: /dev/shm 50 | profiles: 51 | compute: 52 | wordpress: 53 | resources: 54 | cpu: 55 | units: 4 56 | memory: 57 | size: 4Gi 58 | storage: 59 | - size: 4Gi 60 | - name: wordpress-data 61 | size: 32Gi 62 | attributes: 63 | persistent: true 64 | class: beta3 65 | db: 66 | resources: 67 | cpu: 68 | units: 1 69 | memory: 70 | size: 1Gi 71 | storage: 72 | - size: 1Gi 73 | - name: wordpress-db 74 | size: 8Gi 75 | attributes: 76 | persistent: true 77 | class: beta3 78 | - name: shm 79 | size: 1Gi 80 | attributes: 81 | class: ram 82 | - name: shm2 83 | size: 1Gi 84 | attributes: 85 | class: ram 86 | persistent: false 87 | placement: 88 | akash: 89 | ####################################################### 90 | #Keep this section to deploy on trusted providers 91 | signedBy: 92 | anyOf: 93 | - "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63" 94 | - "akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4" 95 | ####################################################### 96 | #Remove this section to deploy on untrusted providers 97 | #Beware* You may have deployment, security, or other issues on untrusted providers 98 | #https://docs.akash.network/providers/akash-audited-attributes 99 | pricing: 100 | wordpress: 101 | denom: uakt 102 | amount: 10000 103 | db: 104 | denom: uakt 105 | amount: 10000 106 | deployment: 107 | wordpress: 108 | akash: 109 | profile: wordpress 110 | count: 1 111 | db: 112 | akash: 113 | profile: db 114 | count: 1 115 | -------------------------------------------------------------------------------- /tests/fixtures/wordpress.sdl.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '2.0' 3 | services: 4 | wordpress: 5 | image: wordpress 6 | depends_on: 7 | - db 8 | expose: 9 | - port: 80 10 | http_options: 11 | max_body_size: 104857600 12 | # accept: 13 | # - "example.com" 14 | to: 15 | - global: true 16 | env: 17 | - WORDPRESS_DB_HOST=db 18 | - WORDPRESS_DB_USER=wordpress 19 | - WORDPRESS_DB_PASSWORD=testpass4you 20 | - WORDPRESS_DB_NAME=wordpress 21 | params: 22 | storage: 23 | wordpress-data: 24 | mount: /var/www/html 25 | readOnly: false 26 | db: 27 | # We use a mariadb image which supports both amd64 & arm64 architecture 28 | image: mariadb:10.6.4 29 | # If you really want to use MySQL, uncomment the following line 30 | #image: mysql:8.0.27 31 | expose: 32 | - port: 3306 33 | to: 34 | - service: wordpress 35 | - port: 33060 36 | to: 37 | - service: wordpress 38 | env: 39 | - MYSQL_RANDOM_ROOT_PASSWORD=1 40 | - MYSQL_DATABASE=wordpress 41 | - MYSQL_USER=wordpress 42 | - MYSQL_PASSWORD=testpass4you 43 | params: 44 | storage: 45 | wordpress-db: 46 | mount: /var/lib/mysql 47 | readOnly: false 48 | profiles: 49 | compute: 50 | wordpress: 51 | resources: 52 | gpu: 53 | units: 0 54 | cpu: 55 | units: 4 56 | memory: 57 | size: 4Gi 58 | storage: 59 | - size: 4Gi 60 | - name: wordpress-data 61 | size: 32Gi 62 | attributes: 63 | persistent: true 64 | class: beta3 65 | db: 66 | resources: 67 | gpu: 68 | units: 0 69 | cpu: 70 | units: 1 71 | memory: 72 | size: 1Gi 73 | storage: 74 | - size: 1Gi 75 | - name: wordpress-db 76 | size: 8Gi 77 | attributes: 78 | persistent: true 79 | class: beta3 80 | placement: 81 | akash: 82 | ####################################################### 83 | #Keep this section to deploy on trusted providers 84 | signedBy: 85 | anyOf: 86 | - "akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63" 87 | - "akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4" 88 | ####################################################### 89 | #Remove this section to deploy on untrusted providers 90 | #Beware* You may have deployment, security, or other issues on untrusted providers 91 | #https://docs.akash.network/providers/akash-audited-attributes 92 | pricing: 93 | wordpress: 94 | denom: uakt 95 | amount: 10000 96 | db: 97 | denom: uakt 98 | amount: 10000 99 | deployment: 100 | wordpress: 101 | akash: 102 | profile: wordpress 103 | count: 1 104 | db: 105 | akash: 106 | profile: db 107 | count: 1 -------------------------------------------------------------------------------- /tests/sdl_gpu_invalid_vendor.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | describe("test sdl gpu invalid vendor", () => { 6 | it("SDL: GPU must throw if the vendor is invalid", () => { 7 | const invalidSDL = fs.readFileSync("./tests/fixtures/gpu_invalid_vendor.sdl.yml", "utf8"); 8 | 9 | const t = () => { 10 | SDL.fromString(invalidSDL, "beta3"); 11 | }; 12 | 13 | expect(t).toThrow(`GPU must be one of the supported vendors (nvidia,amd).`); 14 | }); 15 | 16 | it("SDL: GPU without vendor name should throw", () => { 17 | const invalidSDL = fs.readFileSync("./tests/fixtures/gpu_invalid_no_vendor_name.sdl.yml", "utf8"); 18 | 19 | const t = () => { 20 | SDL.fromString(invalidSDL, "beta3"); 21 | }; 22 | 23 | expect(t).toThrow(`GPU must be one of the supported vendors (nvidia,amd).`); 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /tests/sdl_gpu_ram_interface.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | const testSDL = fs.readFileSync("./tests/fixtures/gpu_basic_ram_interface.sdl.yml", "utf8"); 6 | 7 | const expectedManifest = JSON.parse(fs.readFileSync("./tests/fixtures/gpu_basic_ram_interface.manifest.json", "utf8")); 8 | 9 | describe("test GPU with interface", () => { 10 | it("SDL: GPU Manifest with ram & interface", () => { 11 | const sdl = SDL.fromString(testSDL, "beta3"); 12 | const result = sdl.manifest(); 13 | 14 | expect(result).toStrictEqual(expectedManifest); 15 | }); 16 | 17 | it("SDL: GPU Version with ram & interface (snapshot)", async () => { 18 | const sdl = SDL.fromString(testSDL, "beta3"); 19 | 20 | await expect(sdl.manifestVersion()).resolves.toMatchSnapshot("Manifest version matches expected result"); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /tests/sdl_persistent_storage_attributes.spec.ts: -------------------------------------------------------------------------------- 1 | import fs from "fs"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | describe("test sdl persistent storage", () => { 6 | it("SDL: Persistent Storage Manifest", () => { 7 | const validSDL = fs.readFileSync("./tests/fixtures/persistent_storage_valid.sdl.yml", "utf8"); 8 | 9 | const sdl = SDL.fromString(validSDL, "beta2"); 10 | const result = sdl.manifest(); 11 | 12 | expect(result).toMatchSnapshot("SDL: Persistent Storage Manifest"); 13 | }); 14 | }); 15 | -------------------------------------------------------------------------------- /tests/test_deployments.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | 3 | import { testSnap } from "./util"; 4 | 5 | import { getRpc } from "../src/rpc"; 6 | import { 7 | QueryClientImpl, 8 | QueryDeploymentRequest, 9 | QueryDeploymentResponse, 10 | QueryDeploymentsRequest, 11 | QueryDeploymentsResponse 12 | } from "@akashnetwork/akash-api/akash/deployment/v1beta3/query"; 13 | 14 | tap.test("Deployments: query deployment list with owner filter", async t => { 15 | t.plan(1); 16 | 17 | const client = new QueryClientImpl(await getRpc("https://rpc.akashnet.net")); 18 | const request = QueryDeploymentsRequest.fromJSON({ 19 | filters: { 20 | owner: "akash1qqzwc5d7hynl67nsmn9jukvwqp3vzdl6j2t7lk" 21 | } 22 | }); 23 | 24 | const res = await client.Deployments(request); 25 | testSnap(t)("Deployments query matches expected result")(QueryDeploymentsResponse.toJSON(res)); 26 | }); 27 | 28 | tap.test("Deployments: query deployment with owner and dseq", async t => { 29 | t.plan(1); 30 | 31 | const client = new QueryClientImpl(await getRpc("https://rpc.akashnet.net")); 32 | const request = QueryDeploymentRequest.fromJSON({ 33 | id: { 34 | owner: "akash1qqzwc5d7hynl67nsmn9jukvwqp3vzdl6j2t7lk", 35 | dseq: "1027706" 36 | } 37 | }); 38 | 39 | const res = await client.Deployment(request); 40 | testSnap(t)("Deployments query matches expected result")(QueryDeploymentResponse.toJSON(res)); 41 | }); 42 | -------------------------------------------------------------------------------- /tests/test_sdl_basic_beta3.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | const testSDL = `version: '2.0' 6 | services: 7 | tetris: 8 | image: bsord/tetris 9 | expose: 10 | - port: 80 11 | as: 80 12 | to: 13 | - global: true 14 | profiles: 15 | compute: 16 | tetris: 17 | resources: 18 | cpu: 19 | units: 1 20 | gpu: 21 | units: 0 22 | memory: 23 | size: 512Mi 24 | storage: 25 | - size: 512Mi 26 | placement: 27 | akash: 28 | attributes: 29 | host: akash 30 | signedBy: 31 | anyOf: 32 | - akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63 33 | - akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4 34 | pricing: 35 | tetris: 36 | denom: uakt 37 | amount: 10000 38 | deployment: 39 | tetris: 40 | akash: 41 | profile: tetris 42 | count: 1 43 | `; 44 | 45 | const expectedGroups = [ 46 | { 47 | name: "akash", 48 | requirements: { 49 | attributes: [ 50 | { 51 | key: "host", 52 | value: "akash" 53 | } 54 | ], 55 | signedBy: { 56 | allOf: [], 57 | anyOf: ["akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63", "akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4"] 58 | } 59 | }, 60 | resources: [ 61 | { 62 | resource: { 63 | cpu: { 64 | units: { 65 | val: new Uint8Array([49, 48, 48, 48]) 66 | }, 67 | attributes: undefined 68 | }, 69 | memory: { 70 | quantity: { 71 | val: new Uint8Array([53, 51, 54, 56, 55, 48, 57, 49, 50]) 72 | }, 73 | attributes: undefined 74 | }, 75 | storage: [ 76 | { 77 | name: "default", 78 | quantity: { 79 | val: new Uint8Array([53, 51, 54, 56, 55, 48, 57, 49, 50]) 80 | }, 81 | attributes: undefined 82 | } 83 | ], 84 | gpu: { 85 | units: { 86 | val: new Uint8Array([48]) 87 | }, 88 | attributes: undefined 89 | }, 90 | endpoints: [ 91 | { 92 | sequence_number: 0 93 | } 94 | ], 95 | id: 1 96 | }, 97 | price: { 98 | denom: "uakt", 99 | amount: "10000" 100 | }, 101 | count: 1 102 | } 103 | ] 104 | } 105 | ]; 106 | 107 | tap.test("SDL: fromString", async t => { 108 | t.plan(2); 109 | 110 | const sdl = SDL.fromString(testSDL, "beta3"); 111 | 112 | t.ok(sdl instanceof SDL, "Default SDL is not undefined"); 113 | t.ok(sdl.data !== null, "SDL has data object"); 114 | }); 115 | 116 | tap.test("SDL: DeploymentGroups", async t => { 117 | t.plan(1); 118 | 119 | const sdl = SDL.fromString(testSDL, "beta3"); 120 | const result = sdl.groups(); 121 | const expected = expectedGroups; 122 | 123 | t.same(result, expected, "Deployment groups matches expected result"); 124 | }); 125 | -------------------------------------------------------------------------------- /tests/test_sdl_env.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | const testSDL = `version: '2.0' 6 | services: 7 | tetris: 8 | image: bsord/tetris 9 | env: 10 | - EMPTY= 11 | - ENV1=test1 12 | - ENV2=test2 13 | expose: 14 | - port: 80 15 | as: 80 16 | to: 17 | - global: true 18 | profiles: 19 | compute: 20 | tetris: 21 | resources: 22 | cpu: 23 | units: 1 24 | memory: 25 | size: 512Mi 26 | storage: 27 | - size: 512Mi 28 | placement: 29 | akash: 30 | attributes: 31 | host: akash 32 | signedBy: 33 | anyOf: 34 | - akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63 35 | - akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4 36 | pricing: 37 | tetris: 38 | denom: uakt 39 | amount: 10000 40 | deployment: 41 | tetris: 42 | akash: 43 | profile: tetris 44 | count: 1 45 | `; 46 | 47 | const testManifest = [ 48 | { 49 | Name: "akash", 50 | Services: [ 51 | { 52 | Name: "tetris", 53 | Image: "bsord/tetris", 54 | Command: null, 55 | Args: null, 56 | Env: ["EMPTY=", "ENV1=test1", "ENV2=test2"], 57 | Resources: { 58 | cpu: { 59 | units: { 60 | val: "1000" 61 | } 62 | }, 63 | memory: { 64 | size: { 65 | val: "536870912" 66 | } 67 | }, 68 | storage: [ 69 | { 70 | name: "default", 71 | size: { 72 | val: "536870912" 73 | } 74 | } 75 | ], 76 | endpoints: null 77 | }, 78 | Count: 1, 79 | Expose: [ 80 | { 81 | Port: 80, 82 | ExternalPort: 80, 83 | Proto: "TCP", 84 | Service: "", 85 | Global: true, 86 | Hosts: null, 87 | HTTPOptions: { 88 | MaxBodySize: 1048576, 89 | ReadTimeout: 60000, 90 | SendTimeout: 60000, 91 | NextTries: 3, 92 | NextTimeout: 0, 93 | NextCases: ["error", "timeout"] 94 | }, 95 | IP: "", 96 | EndpointSequenceNumber: 0 97 | } 98 | ] 99 | } 100 | ] 101 | } 102 | ]; 103 | 104 | tap.test("SDL: Manifest w/ env", async t => { 105 | t.plan(1); 106 | 107 | const sdl = SDL.fromString(testSDL); 108 | const result = sdl.manifest(); 109 | const expected = testManifest; 110 | 111 | t.same(result, expected, "Manifest matches expected result"); 112 | }); 113 | -------------------------------------------------------------------------------- /tests/test_sdl_gpu.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | const testSDL = fs.readFileSync("./tests/fixtures/gpu_basic.sdl.yml", "utf8"); 7 | 8 | const expectedManifest = JSON.parse(fs.readFileSync("./tests/fixtures/gpu_basic.manifest.json", "utf8")); 9 | 10 | tap.test("SDL: GPU Manifest", t => { 11 | t.plan(1); 12 | 13 | const sdl = SDL.fromString(testSDL, "beta3"); 14 | const result = sdl.manifest(); 15 | 16 | t.same(result, expectedManifest, "Manifest matches expected result"); 17 | }); 18 | 19 | tap.test("SDL: GPU Version", async t => { 20 | t.plan(1); 21 | 22 | const sdl = SDL.fromString(testSDL, "beta3"); 23 | const result = await sdl.manifestVersion(); 24 | 25 | t.matchSnapshot(result, "Manifest version matches expected result"); 26 | }); 27 | -------------------------------------------------------------------------------- /tests/test_sdl_gpu_attributes.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | tap.test("SDL: fromString", async t => { 7 | t.plan(4); 8 | 9 | const validSDL = fs.readFileSync("./tests/fixtures/gpu_no_gpu_valid.sdl.yml", "utf8"); 10 | const hasAttrSDL = fs.readFileSync("./tests/fixtures/gpu_no_gpu_invalid_has_attributes.sdl.yml", "utf8"); 11 | const noVendorSdl = fs.readFileSync("./tests/fixtures/gpu_invalid_no_vendor.sdl.yml", "utf8"); 12 | const invalidIntefaceSdl = fs.readFileSync("./tests/fixtures/gpu_invalid_interface.sdl.yml", "utf8"); 13 | 14 | t.doesNotThrow(() => SDL.fromString(validSDL, "beta3"), "accept if GPU units is 0, and no attributes are present"); 15 | 16 | t.throws( 17 | () => SDL.fromString(hasAttrSDL, "beta3"), 18 | new Error("GPU must not have attributes if units is 0"), 19 | "throw an error if GPU units is not 0, and the are no attributes present" 20 | ); 21 | 22 | t.throws( 23 | () => SDL.fromString(noVendorSdl, "beta3"), 24 | new Error("GPU must specify a vendor if units is not 0"), 25 | "throw an error if GPU units is not 0, and the vendor is not present" 26 | ); 27 | 28 | t.throws( 29 | () => SDL.fromString(invalidIntefaceSdl, "beta3"), 30 | new Error("GPU interface must be one of the supported interfaces (pcie,sxm)"), 31 | "throw an error if GPU interface is not supported" 32 | ); 33 | }); 34 | -------------------------------------------------------------------------------- /tests/test_sdl_gpu_ram.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | const testSDL = fs.readFileSync("./tests/fixtures/gpu_basic_ram.sdl.yml", "utf8"); 7 | 8 | const expectedManifest = JSON.parse(fs.readFileSync("./tests/fixtures/gpu_basic_ram.manifest.json", "utf8")); 9 | 10 | tap.test("SDL: GPU Manifest with ram", async t => { 11 | t.plan(1); 12 | 13 | const sdl = SDL.fromString(testSDL, "beta3"); 14 | const result = sdl.manifest(); 15 | 16 | t.same(result, expectedManifest, "Manifest matches expected result"); 17 | }); 18 | 19 | tap.test("SDL: GPU Version with ram", async t => { 20 | t.plan(1); 21 | 22 | const sdl = SDL.fromString(testSDL, "beta3"); 23 | const result = await sdl.manifestVersion(); 24 | 25 | t.matchSnapshot(result, "Manifest version matches expected result"); 26 | }); 27 | -------------------------------------------------------------------------------- /tests/test_sdl_gpu_vendor_only.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | const testSDL = `version: "2.0" 6 | services: 7 | web: 8 | image: nginx 9 | expose: 10 | - port: 80 11 | accept: 12 | - ahostname.com 13 | to: 14 | - global: true 15 | - port: 12345 16 | to: 17 | - global: true 18 | proto: udp 19 | profiles: 20 | compute: 21 | web: 22 | resources: 23 | cpu: 24 | units: "100m" 25 | gpu: 26 | units: 1 27 | attributes: 28 | vendor: 29 | nvidia: 30 | memory: 31 | size: "128Mi" 32 | storage: 33 | - size: "1Gi" 34 | placement: 35 | westcoast: 36 | attributes: 37 | region: us-west 38 | blalbla: foo 39 | signedBy: 40 | anyOf: 41 | - 1 42 | - 2 43 | allOf: 44 | - 3 45 | - 4 46 | pricing: 47 | web: 48 | denom: uakt 49 | amount: 50 50 | deployment: 51 | web: 52 | westcoast: 53 | profile: web 54 | count: 2 55 | `; 56 | 57 | tap.test("SDL: GPU Manifest", async t => { 58 | t.plan(1); 59 | 60 | const sdl = SDL.fromString(testSDL, "beta3"); 61 | const result = sdl.manifest(); 62 | 63 | t.matchSnapshot(result, "Manifest matches expected result"); 64 | }); 65 | 66 | tap.test("SDL: GPU Version", async t => { 67 | t.plan(1); 68 | 69 | const sdl = SDL.fromString(testSDL, "beta3"); 70 | const result = await sdl.manifestVersion(); 71 | 72 | t.matchSnapshot(result, "Manifest version matches expected result"); 73 | }); 74 | -------------------------------------------------------------------------------- /tests/test_sdl_httpopts.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | 3 | import { SDL } from "../src/sdl"; 4 | 5 | const testSDL = `version: '2.0' 6 | services: 7 | tetris: 8 | image: bsord/tetris 9 | expose: 10 | - port: 80 11 | http_options: 12 | max_body_size: 104857600 13 | read_timeout: 50 14 | send_timeout: 100 15 | next_tries: 24 16 | next_timeout: 48 17 | next_cases: 18 | - "500" 19 | as: 80 20 | to: 21 | - global: true 22 | profiles: 23 | compute: 24 | tetris: 25 | resources: 26 | cpu: 27 | units: 1 28 | memory: 29 | size: 512Mi 30 | storage: 31 | - size: 512Mi 32 | placement: 33 | akash: 34 | attributes: 35 | host: akash 36 | signedBy: 37 | anyOf: 38 | - akash1365yvmc4s7awdyj3n2sav7xfx76adc6dnmlx63 39 | - akash18qa2a2ltfyvkyj0ggj3hkvuj6twzyumuaru9s4 40 | pricing: 41 | tetris: 42 | denom: uakt 43 | amount: 10000 44 | deployment: 45 | tetris: 46 | akash: 47 | profile: tetris 48 | count: 1`; 49 | 50 | const testManifest = [ 51 | { 52 | Name: "akash", 53 | Services: [ 54 | { 55 | Name: "tetris", 56 | Image: "bsord/tetris", 57 | Command: null, 58 | Args: null, 59 | Env: null, 60 | Resources: { 61 | cpu: { 62 | units: { 63 | val: "1000" 64 | } 65 | }, 66 | memory: { 67 | size: { 68 | val: "536870912" 69 | } 70 | }, 71 | storage: [ 72 | { 73 | name: "default", 74 | size: { 75 | val: "536870912" 76 | } 77 | } 78 | ], 79 | endpoints: null 80 | }, 81 | Count: 1, 82 | Expose: [ 83 | { 84 | Port: 80, 85 | ExternalPort: 80, 86 | Proto: "TCP", 87 | Service: "", 88 | Global: true, 89 | Hosts: null, 90 | HTTPOptions: { 91 | MaxBodySize: 104857600, 92 | ReadTimeout: 50, 93 | SendTimeout: 100, 94 | NextTries: 24, 95 | NextTimeout: 48, 96 | NextCases: ["500"] 97 | }, 98 | IP: "", 99 | EndpointSequenceNumber: 0 100 | } 101 | ] 102 | } 103 | ] 104 | } 105 | ]; 106 | 107 | tap.test("SDL: Manifest w/ HTTP options", async t => { 108 | t.plan(1); 109 | 110 | const sdl = SDL.fromString(testSDL); 111 | const result = sdl.manifest(); 112 | const expected = testManifest; 113 | 114 | t.same(result, expected, "Manifest matches expected result"); 115 | }); 116 | -------------------------------------------------------------------------------- /tests/test_sdl_ip_lease.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | tap.test("SDL: IP Lease Manifest", async t => { 7 | t.plan(1); 8 | 9 | const validSDL = fs.readFileSync("./tests/fixtures/ip_lease_valid.sdl.yml", "utf8"); 10 | 11 | const sdl = SDL.fromString(validSDL, "beta2"); 12 | const result = sdl.manifest(); 13 | 14 | t.matchSnapshot(result, "Manifest matches expected result"); 15 | }); 16 | -------------------------------------------------------------------------------- /tests/test_sdl_v3_resources.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | tap.test("SDL: Create v3 Resource Groups", async t => { 7 | t.plan(1); 8 | 9 | const testSDL = fs.readFileSync("./tests/fixtures/gpu_basic.sdl.yml", "utf8"); 10 | const sdl = SDL.fromString(testSDL, "beta3"); 11 | 12 | t.matchSnapshot(sdl.groups(), "Groups matches expected result"); 13 | }); 14 | -------------------------------------------------------------------------------- /tests/test_sdl_wordpress.ts: -------------------------------------------------------------------------------- 1 | import tap from "tap"; 2 | import fs from "fs"; 3 | 4 | import { SDL } from "../src/sdl"; 5 | 6 | const testSDL = fs.readFileSync("./tests/fixtures/wordpress.sdl.yml", "utf8"); 7 | 8 | const expectedManifest = JSON.parse(fs.readFileSync("./tests/fixtures/wordpress.manifest.json", "utf8")); 9 | 10 | tap.test("SDL: Wordpress Manifest", async t => { 11 | t.plan(1); 12 | 13 | const sdl = SDL.fromString(testSDL, "beta3"); 14 | const result = sdl.manifestSorted(); 15 | 16 | t.same(result, expectedManifest, "Manifest matches expected result"); 17 | }); 18 | 19 | tap.test("SDL: Wordpress Deployment Groups", async t => { 20 | t.plan(1); 21 | 22 | const sdl = SDL.fromString(testSDL, "beta3"); 23 | const result = sdl.groups(); 24 | 25 | t.matchSnapshot(result, "Groups matches expected result"); 26 | }); 27 | 28 | tap.test("SDL: Wordpress Version", async t => { 29 | t.plan(1); 30 | 31 | const sdl = SDL.fromString(testSDL, "beta3"); 32 | const result = await sdl.manifestVersion(); 33 | 34 | t.matchSnapshot(result, "Manifest version matches expected result"); 35 | }); 36 | -------------------------------------------------------------------------------- /tests/util.ts: -------------------------------------------------------------------------------- 1 | export const testSnap = (test: Tap.Test) => (message: string) => (value: any) => test.matchSnapshot(value, message); 2 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.build.json", 3 | "include": ["./src/**/*"], 4 | "exclude": ["./examples", "./tests", "./test", "./src/**/*.spec.ts"] 5 | } 6 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const NodePolyfillPlugin = require("node-polyfill-webpack-plugin"); 2 | const path = require("path"); 3 | 4 | module.exports = { 5 | entry: "./src/index.ts", 6 | externals: { 7 | "node:crypto": "src/webpack/crypto" 8 | }, 9 | resolve: { 10 | alias: { 11 | // add as many aliases as you like! 12 | keytar: path.resolve(__dirname, "src/wallet/storage.ts"), 13 | perf_hooks: path.resolve(__dirname, "src/webpack/perf_hooks.ts") 14 | }, 15 | extensions: [".wasm", ".mjs", ".js", ".json", ".jsx", ".ts"], 16 | fallback: { 17 | http: require.resolve("stream-http") 18 | } 19 | }, 20 | module: { 21 | rules: [ 22 | { 23 | test: /\.tsx?$/, 24 | use: "ts-loader" 25 | } 26 | ] 27 | }, 28 | plugins: [new NodePolyfillPlugin()], 29 | output: { 30 | filename: "akashjs.js", 31 | path: path.resolve(__dirname, "umd"), 32 | library: { 33 | type: "umd", 34 | name: "akjs" 35 | }, 36 | // prevent error: `Uncaught ReferenceError: self is not define` 37 | globalObject: "this" 38 | } 39 | }; 40 | --------------------------------------------------------------------------------