当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript stellar-sdk.Memo类代码示例

本文整理汇总了TypeScript中stellar-sdk.Memo的典型用法代码示例。如果您正苦于以下问题:TypeScript Memo类的具体用法?TypeScript Memo怎么用?TypeScript Memo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Memo类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: isValidMemoId

  /**
   * Return boolean indicating whether a memo id is valid
   *
   * @param memoId {String} memo id
   * @returns {boolean} true if memo id is valid
   */
  isValidMemoId(memoId) {
    try {
      stellar.Memo.id(memoId); // throws if the value is not valid memo id
      memoId = new BigNumber(memoId);
    } catch (e) {
      return false;
    }

    return (memoId.gte(0) && memoId.lt(maxMemoId));
  }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:16,代码来源:xlm.ts

示例2: isValidMemo

 /**
  * Evaluates whether a memo is valid
  *
  * @param value {String} value of the memo
  * @param type {String} type of the memo
  * @returns {Boolean} true if value and type are a valid
  */
 isValidMemo({ value, type }) {
   if (!value || !type) {
     return false;
   }
   try {
     // throws if the value is not valid for the type
     // valid types are: 'id', 'text', 'hash', 'return'
     // See https://www.stellar.org/developers/guides/concepts/transactions.html#memo
     stellar.Memo[type](value);
   } catch (e) {
     return false;
   }
   return true;
 }
开发者ID:BitGo,项目名称:BitGoJS,代码行数:21,代码来源:xlm.ts

示例3:

const sourceKey = StellarSdk.Keypair.random(); // $ExpectType Keypair
const destKey = StellarSdk.Keypair.random();
const account = new StellarSdk.Account(sourceKey.publicKey(), '1');
const transaction = new StellarSdk.TransactionBuilder(account)
    .addOperation(StellarSdk.Operation.accountMerge({destination: destKey.publicKey()}))
    .addMemo(new StellarSdk.Memo(StellarSdk.MemoText, "memo"))
    .build(); // $ExpectType () => Transaction
transaction; // $ExpectType Transaction

StellarSdk.StellarTomlResolver.resolve("example.com", {allowHttp: true, timeout: 100})
    .then(toml => toml.FEDERATION_SERVER);

const sig = StellarSdk.xdr.DecoratedSignature.fromXDR(Buffer.of(1, 2)); // $ExpectType DecoratedSignature
sig.hint(); // $ExpectType Buffer
sig.signature(); // $ExpectType Buffer

StellarSdk.Memo.none(); // $ExpectType Memo<"none">
StellarSdk.Memo.text('asdf'); // $ExpectType Memo<"text">
StellarSdk.Memo.id('asdf'); // $ExpectType Memo<"id">
StellarSdk.Memo.return('asdf'); // $ExpectType Memo<"return">
StellarSdk.Memo.hash('asdf'); // $ExpectType Memo<"hash">
StellarSdk.Memo.none().value; // $ExpectType null
StellarSdk.Memo.id('asdf').value; // $ExpectType string
StellarSdk.Memo.text('asdf').value; // $ExpectType string
StellarSdk.Memo.return('asdf').value; // $ExpectType Buffer
StellarSdk.Memo.hash('asdf').value; // $ExpectType Buffer

// P.S. don't use Memo constructor
(new StellarSdk.Memo(StellarSdk.MemoHash, 'asdf')).value; // $ExpectType AnyValue
(new StellarSdk.Memo(StellarSdk.MemoHash, 'asdf')).type; // $ExpectType AnyType
开发者ID:,项目名称:,代码行数:30,代码来源:


注:本文中的stellar-sdk.Memo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。