[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
This commit is contained in:
Paul Selden
2018-10-11 13:46:24 -04:00
committed by Andy
parent 7325705819
commit 1df7a9325c
2 changed files with 7 additions and 5 deletions

View File

@@ -10,7 +10,7 @@
/// <reference types="node" />
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<EffectRecord>;
offers: CallCollectionFunction<OfferRecord>;
operations: CallCollectionFunction<OperationRecord>;
@@ -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<T extends Operation.Operation> extends XDRStruct { }
class Asset extends XDRStruct { }

View File

@@ -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"))