From bfa3fb14360b57b763fd3a0c3ac6f59409533058 Mon Sep 17 00:00:00 2001 From: pselden Date: Fri, 29 Jun 2018 01:02:45 -0400 Subject: [PATCH] Fix StellarSdk memo types --- types/stellar-sdk/index.d.ts | 15 +++++++++++---- types/stellar-sdk/stellar-sdk-tests.ts | 1 + 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/types/stellar-sdk/index.d.ts b/types/stellar-sdk/index.d.ts index f7eb20af73..bc2a113334 100644 --- a/types/stellar-sdk/index.d.ts +++ b/types/stellar-sdk/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/stellar/js-stellar-sdk // Definitions by: Carl Foster // Triston Jones +// Paul Selden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 @@ -505,16 +506,22 @@ export class Memo { static return(hash: string): Memo; static text(text: string): Memo; - constructor(type: 'MemoNone') - constructor(type: 'MemoID' | 'MemoText', value: string) - constructor(type: 'MemoHash' | 'MemoReturn', value: Buffer) + constructor(type: 'none'); + constructor(type: 'id' | 'text' | 'hash' | 'return', value: string) + constructor(type: 'hash' | 'return', value: Buffer) - type: 'MemoNone' | 'MemoID' | 'MemoText' | 'MemoHash' | 'MemoReturn'; + type: string; value: null | string | Buffer; toXDRObject(): xdr.Memo; } +export const MemoNone = 'none'; +export const MemoID = 'id'; +export const MemoText = 'text'; +export const MemoHash = 'hash'; +export const MemoReturn = 'return'; + export enum Networks { PUBLIC = 'Public Global Stellar Network ; September 2015', TESTNET = 'Test SDF Network ; September 2015', diff --git a/types/stellar-sdk/stellar-sdk-tests.ts b/types/stellar-sdk/stellar-sdk-tests.ts index 4bd84ccc33..dabf4f2b45 100644 --- a/types/stellar-sdk/stellar-sdk-tests.ts +++ b/types/stellar-sdk/stellar-sdk-tests.ts @@ -5,5 +5,6 @@ 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