From 1df7a9325cd62c7196deacb724e6636cdbf10d8e Mon Sep 17 00:00:00 2001 From: Paul Selden Date: Thu, 11 Oct 2018 13:46:24 -0400 Subject: [PATCH] [stellar-sdk]: Fix AccountRecord.data and add data_attr (#29632) * [stellar-sdk]: Fix AccountRecord.data and data_attr data is a function to call the /accounts/{id}/data/{key} endpoint, while data_attr is an object bag containing data for the account. * [stellar-sdk] Add overload to toXDR() which accepts a string encoding --- types/stellar-sdk/index.d.ts | 10 ++++++---- types/stellar-sdk/stellar-sdk-tests.ts | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/types/stellar-sdk/index.d.ts b/types/stellar-sdk/index.d.ts index 581523ccb6..68ad432585 100644 --- a/types/stellar-sdk/index.d.ts +++ b/types/stellar-sdk/index.d.ts @@ -10,7 +10,7 @@ /// export class Account { - constructor(accountId: string, sequence: string | number) + constructor(accountId: string, sequence: string) accountId(): string; sequenceNumber(): string; incrementSequenceNumber(): void; @@ -98,10 +98,10 @@ export interface AccountRecord extends Record { weight: number } >; - data: { + data: (options: {value: string}) => Promise<{value: string}>; + data_attr: { [key: string]: string }; - effects: CallCollectionFunction; offers: CallCollectionFunction; operations: CallCollectionFunction; @@ -437,7 +437,8 @@ export class AccountResponse implements AccountRecord { weight: number } >; - data: { + data: (options: {value: string}) => Promise<{value: string}>; + data_attr: { [key: string]: string }; @@ -894,6 +895,7 @@ export namespace xdr { static fromXDR(xdr: Buffer): XDRStruct; toXDR(): Buffer; + toXDR(encoding: string): string; } class Operation extends XDRStruct { } class Asset extends XDRStruct { } diff --git a/types/stellar-sdk/stellar-sdk-tests.ts b/types/stellar-sdk/stellar-sdk-tests.ts index 8ff71d7fb6..fe72b84a66 100644 --- a/types/stellar-sdk/stellar-sdk-tests.ts +++ b/types/stellar-sdk/stellar-sdk-tests.ts @@ -2,7 +2,7 @@ import * as StellarSdk from 'stellar-sdk'; const sourceKey = StellarSdk.Keypair.random(); // $ExpectType Keypair const destKey = StellarSdk.Keypair.random(); -const account = new StellarSdk.Account(sourceKey.publicKey(), 1); +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"))