symbol-sdk-typescript-javascript icon indicating copy to clipboard operation
symbol-sdk-typescript-javascript copied to clipboard

CreateTransactionFromDTO is not a function

Open keiyow opened this issue 4 years ago • 0 comments

  1. Expected behavior and actual behavior.

  2. Steps to reproduce the problem.

When I use symbol-sdk in Vue3 + vite, I get an error and it does not work properly. If you use getTransactionsById getTransaction after build, i will get an error.

Uncaught (in promise) TypeError: transaction_2.CreateTransactionFromDTO is not a function
    getTransaction(transactionId, transactionGroup) {
        return this.call(this.getTransactionByGroup(transactionId, transactionGroup), (body) => transaction_2.CreateTransactionFromDTO(body));
    }
    /**
     * Gets an array of transactions for different transaction ids
     * @param transactionIds - Array of transactions id and/or hash.
     * @param transactionGroup - Transaction group.
     * @returns Observable<Transaction[]>
     */
    getTransactionsById(transactionIds, transactionGroup) {
        const transactionIdsBody = {
            transactionIds,
        };
        switch (transactionGroup) {
            case TransactionGroup_1.TransactionGroup.Confirmed:
                return this.call(this.transactionRoutesApi.getConfirmedTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => {
                    return transaction_2.CreateTransactionFromDTO(transactionDTO);
                }));
            case TransactionGroup_1.TransactionGroup.Unconfirmed:
                return this.call(this.transactionRoutesApi.getUnconfirmedTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => {
                    return transaction_2.CreateTransactionFromDTO(transactionDTO);
                }));
            case TransactionGroup_1.TransactionGroup.Partial:
                return this.call(this.transactionRoutesApi.getPartialTransactions(transactionIdsBody), (body) => body.map((transactionDTO) => {
                    return transaction_2.CreateTransactionFromDTO(transactionDTO);
                }));
        }
    }

tsconfig

{
  "compilerOptions": {
    "target": "esnext",
    "module": "esnext",
    "moduleResolution": "node",
    "strict": true,
    "jsx": "preserve",
    "sourceMap": true,
    "resolveJsonModule": true,
    "esModuleInterop": true,
    "lib": ["esnext", "dom"],
    "baseUrl": "./",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"]
}

vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
  server: {
    host: '0.0.0.0',
    port: 80,
    strictPort: true,
  },
  plugins: [vue()],
  resolve: {
    mainFields: ['browser', 'module', 'jsnext:main', 'jsnext'],
    alias: [{
      find: '@/',
      replacement: '/src/',
    }],
  },
  build: {
    target: "es2020",
  },
})
  1. Specifications like the version of the project, operating system, or hardware.
    "buffer": "^6.0.3",
    "events": "^3.3.0",
    "pug": "^3.0.2",
    "rxjs": "^7.1.0",
    "symbol-sdk": "^1.0.3",
    "vue": "^3.2.6",
    "vue-loading-overlay": "^4.0",
    "vue-router": "^4.0.11"

keiyow avatar Nov 18 '21 05:11 keiyow