What causes the occurrence of [Object object] instead of a memo being displayed when the memo is included in the transaction building process in Stellar

Having trouble adding a memo to a wallet generated on the Stellar network, encountering an XDR write error in the SDK.

Error stack trace:

TypeError: XDR Write Error: [object Object] is not a Memo
    at Function.write (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/union.js:85:1)
    at Function.write (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/struct.js:31:1)
    at Function.write (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/union.js:88:1)
    at Function.write (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/struct.js:31:1)
    at Function.toXDR (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/xdr-type.js:57:1)
    at ChildStruct.toXDR (webpack://WalletSDK/node_modules/@stellar/js-xdr/src/xdr-type.js:12:1)
    at Transaction.signatureBase (webpack://WalletSDK/node_modules/@stellar/stellar-base/lib/transaction.js:293:1)
    at Transaction.hash (webpack://WalletSDK/node_modules/@stellar/stellar-base/lib/transaction_base.js:224:1)
    at Transaction.sign (webpack://WalletSDK/node_modules/@stellar/stellar-base/lib/transaction_base.js:88:1)
    at SigningKeypair.__webpack_modules__../src/walletSdk/Horizon/Account.ts.exports.SigningKeypair.SigningKeypair.sign (webpack://WalletSDK/src/walletSdk/Horizon/Account.ts:64:1)

Code:

    const createTxn = txBuilder
      .createAccount(createdAccountKeyPair)
      .setMemo(new Memo(MemoText, 'test-memo'))
      .build();

    const signed = sponsorSigningKeyPair.sign(createTxn);

Imports used:

import { Memo, xdr, MemoText } from '@stellar/stellar-sdk';
import {
  StellarConfiguration,
  Wallet,
  Keypair,
  AccountKeypair,
  IssuedAssetId,
  PublicKeypair,
  SigningKeypair,
  NativeAssetId,
} from '@stellar/typescript-wallet-sdk';

Versions:

    "@stellar/stellar-sdk": "^12.1.0",
    "@stellar/typescript-wallet-sdk": "^1.7.0",

Input provided:

    const createTxn = txBuilder
      .createAccount(createdAccountKeyPair)
      .setMemo(new Memo(MemoText, 'test-memo'))
      .build();

    const signed = sponsorSigningKeyPair.sign(createTxn);

Answer №1

To properly execute the task, follow these steps:

setMemo(new Memo("text", "Memo string"))

Using MemoText as the initial parameter is incorrect; it should be a string as per the guidelines provided in the documentation.

During the construction of the error message, it appears that MemoText.toString() is being executed, resulting in the printing of [Object object].

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Experimenting with a VSCode extension that requires the act of launching a folder/workspace

Currently, I am developing a custom VSCode extension that considers the path of the file being opened within the workspace. To create a reproducible test scenario, I want to open the test folder itself in VSCode and then proceed to open the test file with ...

Issues with Angular 4 Rxjs subject subscription functionality

My application consists of a shared service named data.service.ts, which contains the following code: public pauseProjectTask$: Subject<any> = new Subject<any>(); pauseTaskProject(taskData, type){ this.pauseProjectTask$.next(taskData); ...

The import of my library using package.json exports is failing due to TypeScript compilation errors

I am currently developing a JavaScript library that I want to make importable via script tags, ES6 imports, and traditional Node requires, with or without TypeScript or any build systems. However, I am facing challenges in achieving this. Within my packag ...

What is the best way to integrate environment-specific configuration options into an AngularJS and Typescript project?

Currently, I am working on a project using AngularJS, Typescript, and VisualStudio. One of the key requirements for this project is to have a configuration file containing constants that control various settings such as REST API URLs and environment names. ...

The declaration file for the module 'tailwind-scrollbar' could not be located

Currently, I am in the process of utilizing Tailwind packages for a Next.js application, however, I have encountered an issue that has proved to be quite challenging to resolve. Every time I attempt to add a "require" statement to my tailwind.config.js fil ...

How can we effectively test arrow functions in unit tests for Angular development?

this.function = () => { -- code statements go here -- } I am looking to write jasmine unit tests in Angular for the function above. Any suggestions on how to achieve this? it("should call service",()=>{ // I want to invoke the arrow funct ...

What is the most efficient way to update data multiple times by mapping over an array of keys in a react hook?

My question might not be articulated correctly. I'm facing an issue with dynamically translating my webpage using Microsoft's Cognitive Services Translator. I created a react hook for the translator, which works well when I need to translate a si ...

Switch from using getElementById to useRef in React components

There is a requirement to update a functional component that currently uses getElementById to instead utilize the useRef hook. The original code snippet is as follows: import React, { useState, useEffect, useRef } from 'react'; import { createPo ...

TypeScript: identifying the specific error type within a catch block

I am currently working on a project using typescript in combination with VueJS Despite my efforts, I encountered a type error in my code I tried using type assertation to resolve the issue However, the error persists catch (err) { const msg = (er ...

Implementing pagination within an Angular 11 Mat-table with grouping feature

Encountering an interesting issue with MatTable pagination and grouping simultaneously. I have two components each with a Mat-table featuring Pagination+Grouping. ComponentOne functions smoothly without any issues. When choosing to display 5 elements pe ...

Convert a JavaScript variable to a TypeScript interface

In my JavaScript project, I am utilizing TypeScript and JSDOC for code validation against the TS compiler. When analyzing my code, the TS compiler identifies an error in the following snippet: interface IBox { idx: number; } interface IBoxes { ...

Is it Possible for Angular Layout Components to Render Content Correctly even with Deeply Nested ng-container Elements?

Within my Angular application, I have designed a layout component featuring two columns using CSS. Within this setup, placeholders for the aside and main content are defined utilizing ng-content. The data for both the aside and main sections is fetched fr ...

What causes the typescript error in my code: The argument being passed is either a string, an array of FilterData, an array of numbers, or an array of Moments, which is not compatible with a parameter of type 'string'?

When writing my code, I have the need to utilize various types for different scenarios. Depending on the situation, the type may be a string, number[], FilterData[] (a custom type), or Moment[]. To address this requirement, I defined the type as: export ty ...

Leveraging a Derived-Class Object Within the Base-Class to Invoke a Base-Class Function with Derived-Class Information

I have a situation where I need to access a method from a derived class in my base generic component that returns data specific to the derived class. The first issue I encountered is that I am unable to define the method as static in the abstract class! ...

The use of BaseJQueryEventObject and JQueryEventObject is no longer recommended. What is the alternative to replace them?

Transitioning from jQuery v2 to jQuery v3, the interfaces such as BaseJQueryEventObject in type definitions are now deprecated. What should be used as a replacement in the code? For instance, when working with angularjs, functions may look like this: pu ...

I'm trying to figure out how to access the array field of an object in TypeScript. It seems like the type 'unknown' is required to have a '[Symbol.iterator]()' method that returns an iterator

I'm currently tackling an issue with my helper function that updates a form field based on the fieldname. For example, if it's the name field, then form.name will be updated. If it's user[0].name, then the name at index 0 of form.users will ...

Unable to incorporate node-vibrant into Angular 7 project

Currently facing some challenges while attempting to integrate node-vibrant into my Angular 7 project: -Successfully imported with import * as Vibrant from 'node-vibrant';, but encountering a warning in VS Code: Module '"/Users/xxxx/Docume ...

Creating a specialized TypeScript interface by extending a generic one

Create a customized interface using TypeScript that inherits from a generic interface by excluding the first parameter from all functions. Starting with the following generic interface: interface GenericRepository { insertOne<E>(entity: Type<E& ...

Can an entire object be bound to a model in an Angular controller function?

In TypeScript, I have defined the following Interface: interface Person { Id: number; FirstName: string; LastName: string; Age: number; } Within a .html partial file, there is an Angular directive ng-submit="submit()" on a form element. A ...

Exporting enums within types in React Typescript

Here are the files I have: VehicleBrands.ts: export enum VehicleBrands { FORD = "ford", HONDA = "honda" } VehicleBrand.ts: import {VehicleBrands} from "./VehicleBrands"; export type VehicleBrand = VehicleBrands.FORD | V ...