@stellar/stellar-base 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +1262 -0
  2. package/LICENSE +202 -0
  3. package/README.md +198 -0
  4. package/dist/stellar-base.js +30777 -0
  5. package/dist/stellar-base.min.js +2 -0
  6. package/lib/account.js +80 -0
  7. package/lib/address.js +169 -0
  8. package/lib/asset.js +323 -0
  9. package/lib/auth.js +253 -0
  10. package/lib/claimant.js +193 -0
  11. package/lib/contract.js +113 -0
  12. package/lib/events.js +42 -0
  13. package/lib/fee_bump_transaction.js +134 -0
  14. package/lib/generated/curr_generated.js +8315 -0
  15. package/lib/generated/next_generated.js +8315 -0
  16. package/lib/get_liquidity_pool_id.js +57 -0
  17. package/lib/hashing.js +12 -0
  18. package/lib/index.js +385 -0
  19. package/lib/invocation.js +195 -0
  20. package/lib/keypair.js +308 -0
  21. package/lib/liquidity_pool_asset.js +126 -0
  22. package/lib/liquidity_pool_id.js +101 -0
  23. package/lib/memo.js +270 -0
  24. package/lib/muxed_account.js +159 -0
  25. package/lib/network.js +22 -0
  26. package/lib/numbers/index.js +85 -0
  27. package/lib/numbers/int128.js +50 -0
  28. package/lib/numbers/int256.js +50 -0
  29. package/lib/numbers/sc_int.js +134 -0
  30. package/lib/numbers/uint128.js +50 -0
  31. package/lib/numbers/uint256.js +50 -0
  32. package/lib/numbers/xdr_large_int.js +267 -0
  33. package/lib/operation.js +715 -0
  34. package/lib/operations/account_merge.js +32 -0
  35. package/lib/operations/allow_trust.js +57 -0
  36. package/lib/operations/begin_sponsoring_future_reserves.js +38 -0
  37. package/lib/operations/bump_sequence.js +37 -0
  38. package/lib/operations/change_trust.js +52 -0
  39. package/lib/operations/claim_claimable_balance.js +40 -0
  40. package/lib/operations/clawback.js +46 -0
  41. package/lib/operations/clawback_claimable_balance.js +39 -0
  42. package/lib/operations/create_account.js +37 -0
  43. package/lib/operations/create_claimable_balance.js +65 -0
  44. package/lib/operations/create_passive_sell_offer.js +44 -0
  45. package/lib/operations/end_sponsoring_future_reserves.js +27 -0
  46. package/lib/operations/extend_footprint_ttl.js +45 -0
  47. package/lib/operations/index.js +254 -0
  48. package/lib/operations/inflation.js +23 -0
  49. package/lib/operations/invoke_host_function.js +219 -0
  50. package/lib/operations/liquidity_pool_deposit.js +64 -0
  51. package/lib/operations/liquidity_pool_withdraw.js +50 -0
  52. package/lib/operations/manage_buy_offer.js +50 -0
  53. package/lib/operations/manage_data.js +41 -0
  54. package/lib/operations/manage_sell_offer.js +50 -0
  55. package/lib/operations/path_payment_strict_receive.js +68 -0
  56. package/lib/operations/path_payment_strict_send.js +68 -0
  57. package/lib/operations/payment.js +47 -0
  58. package/lib/operations/restore_footprint.js +38 -0
  59. package/lib/operations/revoke_sponsorship.js +301 -0
  60. package/lib/operations/set_options.js +135 -0
  61. package/lib/operations/set_trustline_flags.js +84 -0
  62. package/lib/scval.js +369 -0
  63. package/lib/signerkey.js +103 -0
  64. package/lib/signing.js +96 -0
  65. package/lib/soroban.js +96 -0
  66. package/lib/sorobandata_builder.js +218 -0
  67. package/lib/strkey.js +400 -0
  68. package/lib/transaction.js +369 -0
  69. package/lib/transaction_base.js +248 -0
  70. package/lib/transaction_builder.js +753 -0
  71. package/lib/util/checksum.js +20 -0
  72. package/lib/util/continued_fraction.js +58 -0
  73. package/lib/util/decode_encode_muxed_account.js +116 -0
  74. package/lib/util/util.js +14 -0
  75. package/lib/xdr.js +9 -0
  76. package/package.json +133 -0
  77. package/types/curr.d.ts +14078 -0
  78. package/types/index.d.ts +1270 -0
  79. package/types/next.d.ts +14078 -0
  80. package/types/xdr.d.ts +1 -0
@@ -0,0 +1,1270 @@
1
+ // TypeScript Version: 2.9
2
+
3
+ /// <reference types="node" />
4
+ import { xdr } from './xdr';
5
+
6
+ export { xdr };
7
+
8
+ export class Account {
9
+ constructor(accountId: string, sequence: string);
10
+ accountId(): string;
11
+ sequenceNumber(): string;
12
+ incrementSequenceNumber(): void;
13
+ }
14
+
15
+ export class Address {
16
+ constructor(address: string);
17
+ static fromString(address: string): Address;
18
+ static account(buffer: Buffer): Address;
19
+ static contract(buffer: Buffer): Address;
20
+ static fromScVal(scVal: xdr.ScVal): Address;
21
+ static fromScAddress(scAddress: xdr.ScAddress): Address;
22
+ toString(): string;
23
+ toScVal(): xdr.ScVal;
24
+ toScAddress(): xdr.ScAddress;
25
+ toBuffer(): Buffer;
26
+ }
27
+
28
+ export class Contract {
29
+ constructor(contractId: string);
30
+ call(method: string, ...params: xdr.ScVal[]): xdr.Operation<Operation.InvokeHostFunction>;
31
+ contractId(): string;
32
+ address(): Address;
33
+ getFootprint(): xdr.LedgerKey;
34
+
35
+ toString(): string;
36
+ }
37
+
38
+ export class MuxedAccount {
39
+ constructor(account: Account, sequence: string);
40
+ static fromAddress(mAddress: string, sequenceNum: string): MuxedAccount;
41
+ static parseBaseAddress(mAddress: string): string;
42
+
43
+ /* Modeled after Account, above */
44
+ accountId(): string;
45
+ sequenceNumber(): string;
46
+ incrementSequenceNumber(): void;
47
+
48
+ baseAccount(): Account;
49
+ id(): string;
50
+ setId(id: string): MuxedAccount;
51
+ toXDRObject(): xdr.MuxedAccount;
52
+ equals(otherMuxedAccount: MuxedAccount): boolean;
53
+ }
54
+
55
+ export namespace AssetType {
56
+ type native = 'native';
57
+ type credit4 = 'credit_alphanum4';
58
+ type credit12 = 'credit_alphanum12';
59
+ type liquidityPoolShares = 'liquidity_pool_shares';
60
+ }
61
+ export type AssetType =
62
+ | AssetType.native
63
+ | AssetType.credit4
64
+ | AssetType.credit12
65
+ | AssetType.liquidityPoolShares;
66
+
67
+ export class Asset {
68
+ static native(): Asset;
69
+ static fromOperation(xdr: xdr.Asset): Asset;
70
+ static compare(assetA: Asset, assetB: Asset): -1 | 0 | 1;
71
+
72
+ constructor(code: string, issuer?: string);
73
+
74
+ getCode(): string;
75
+ getIssuer(): string;
76
+ getAssetType(): AssetType;
77
+ isNative(): boolean;
78
+ equals(other: Asset): boolean;
79
+ toXDRObject(): xdr.Asset;
80
+ toChangeTrustXDRObject(): xdr.ChangeTrustAsset;
81
+ toTrustLineXDRObject(): xdr.TrustLineAsset;
82
+ contractId(): string;
83
+
84
+ code: string;
85
+ issuer: string;
86
+ }
87
+
88
+ export class LiquidityPoolAsset {
89
+ constructor(assetA: Asset, assetB: Asset, fee: number);
90
+
91
+ static fromOperation(xdr: xdr.ChangeTrustAsset): LiquidityPoolAsset;
92
+
93
+ toXDRObject(): xdr.ChangeTrustAsset;
94
+ getLiquidityPoolParameters(): LiquidityPoolParameters;
95
+ getAssetType(): AssetType.liquidityPoolShares;
96
+ equals(other: LiquidityPoolAsset): boolean;
97
+
98
+ assetA: Asset;
99
+ assetB: Asset;
100
+ fee: number;
101
+ }
102
+
103
+ export class LiquidityPoolId {
104
+ constructor(liquidityPoolId: string);
105
+
106
+ static fromOperation(xdr: xdr.TrustLineAsset): LiquidityPoolId;
107
+
108
+ toXDRObject(): xdr.TrustLineAsset;
109
+ getLiquidityPoolId(): string;
110
+ equals(other: LiquidityPoolId): boolean;
111
+
112
+ liquidityPoolId: string;
113
+ }
114
+
115
+ export class Claimant {
116
+ readonly destination: string;
117
+ readonly predicate: xdr.ClaimPredicate;
118
+ constructor(destination: string, predicate?: xdr.ClaimPredicate);
119
+
120
+ toXDRObject(): xdr.Claimant;
121
+
122
+ static fromXDR(claimantXdr: xdr.Claimant): Claimant;
123
+ static predicateUnconditional(): xdr.ClaimPredicate;
124
+ static predicateAnd(left: xdr.ClaimPredicate, right: xdr.ClaimPredicate): xdr.ClaimPredicate;
125
+ static predicateOr(left: xdr.ClaimPredicate, right: xdr.ClaimPredicate): xdr.ClaimPredicate;
126
+ static predicateNot(predicate: xdr.ClaimPredicate): xdr.ClaimPredicate;
127
+ static predicateBeforeAbsoluteTime(absBefore: string): xdr.ClaimPredicate;
128
+ static predicateBeforeRelativeTime(seconds: string): xdr.ClaimPredicate;
129
+ }
130
+
131
+ export const FastSigning: boolean;
132
+
133
+ export type KeypairType = 'ed25519';
134
+
135
+ export class Keypair {
136
+ static fromRawEd25519Seed(secretSeed: Buffer): Keypair;
137
+ static fromSecret(secretKey: string): Keypair;
138
+ static master(networkPassphrase: string): Keypair;
139
+ static fromPublicKey(publicKey: string): Keypair;
140
+ static random(): Keypair;
141
+
142
+ constructor(
143
+ keys:
144
+ | {
145
+ type: KeypairType;
146
+ secretKey: string | Buffer;
147
+ publicKey?: string | Buffer
148
+ }
149
+ | {
150
+ type: KeypairType;
151
+ publicKey: string | Buffer
152
+ }
153
+ );
154
+
155
+ readonly type: KeypairType;
156
+ publicKey(): string;
157
+ secret(): string;
158
+ rawPublicKey(): Buffer;
159
+ rawSecretKey(): Buffer;
160
+ canSign(): boolean;
161
+ sign(data: Buffer): Buffer;
162
+ signDecorated(data: Buffer): xdr.DecoratedSignature;
163
+ signPayloadDecorated(data: Buffer): xdr.DecoratedSignature;
164
+ signatureHint(): Buffer;
165
+ verify(data: Buffer, signature: Buffer): boolean;
166
+
167
+ xdrAccountId(): xdr.AccountId;
168
+ xdrPublicKey(): xdr.PublicKey;
169
+ xdrMuxedAccount(id: string): xdr.MuxedAccount;
170
+ }
171
+
172
+ export const LiquidityPoolFeeV18 = 30;
173
+
174
+ export function getLiquidityPoolId(liquidityPoolType: LiquidityPoolType, liquidityPoolParameters: LiquidityPoolParameters): Buffer;
175
+
176
+ export namespace LiquidityPoolParameters {
177
+ interface ConstantProduct {
178
+ assetA: Asset;
179
+ assetB: Asset;
180
+ fee: number;
181
+ }
182
+ }
183
+ export type LiquidityPoolParameters =
184
+ | LiquidityPoolParameters.ConstantProduct;
185
+
186
+ export namespace LiquidityPoolType {
187
+ type constantProduct = 'constant_product';
188
+ }
189
+ export type LiquidityPoolType =
190
+ | LiquidityPoolType.constantProduct;
191
+
192
+ export const MemoNone = 'none';
193
+ export const MemoID = 'id';
194
+ export const MemoText = 'text';
195
+ export const MemoHash = 'hash';
196
+ export const MemoReturn = 'return';
197
+ export namespace MemoType {
198
+ type None = typeof MemoNone;
199
+ type ID = typeof MemoID;
200
+ type Text = typeof MemoText;
201
+ type Hash = typeof MemoHash;
202
+ type Return = typeof MemoReturn;
203
+ }
204
+ export type MemoType =
205
+ | MemoType.None
206
+ | MemoType.ID
207
+ | MemoType.Text
208
+ | MemoType.Hash
209
+ | MemoType.Return;
210
+ export type MemoValue = null | string | Buffer;
211
+
212
+ export class Memo<T extends MemoType = MemoType> {
213
+ static fromXDRObject(memo: xdr.Memo): Memo;
214
+ static hash(hash: string | Buffer): Memo<MemoType.Hash>;
215
+ static id(id: string): Memo<MemoType.ID>;
216
+ static none(): Memo<MemoType.None>;
217
+ static return(hash: string): Memo<MemoType.Return>;
218
+ static text(text: string): Memo<MemoType.Text>;
219
+
220
+ constructor(type: MemoType.None, value?: null);
221
+ constructor(type: MemoType.Hash | MemoType.Return, value: Buffer);
222
+ constructor(
223
+ type: MemoType.Hash | MemoType.Return | MemoType.ID | MemoType.Text,
224
+ value: string
225
+ );
226
+ constructor(type: T, value: MemoValue);
227
+
228
+ type: T;
229
+ value: T extends MemoType.None
230
+ ? null
231
+ : T extends MemoType.ID
232
+ ? string
233
+ : T extends MemoType.Text
234
+ ? string | Buffer // github.com/stellar/js-stellar-base/issues/152
235
+ : T extends MemoType.Hash
236
+ ? Buffer
237
+ : T extends MemoType.Return
238
+ ? Buffer
239
+ : MemoValue;
240
+
241
+ toXDRObject(): xdr.Memo;
242
+ }
243
+
244
+ export enum Networks {
245
+ PUBLIC = 'Public Global Stellar Network ; September 2015',
246
+ TESTNET = 'Test SDF Network ; September 2015',
247
+ FUTURENET = 'Test SDF Future Network ; October 2022',
248
+ SANDBOX = 'Local Sandbox Stellar Network ; September 2022',
249
+ STANDALONE = 'Standalone Network ; February 2017'
250
+ }
251
+
252
+ export const AuthRequiredFlag: 1;
253
+ export const AuthRevocableFlag: 2;
254
+ export const AuthImmutableFlag: 4;
255
+ export const AuthClawbackEnabledFlag: 8;
256
+ export namespace AuthFlag {
257
+ type immutable = typeof AuthImmutableFlag;
258
+ type required = typeof AuthRequiredFlag;
259
+ type revocable = typeof AuthRevocableFlag;
260
+ type clawbackEnabled = typeof AuthClawbackEnabledFlag;
261
+ }
262
+ export type AuthFlag =
263
+ | AuthFlag.required
264
+ | AuthFlag.immutable
265
+ | AuthFlag.revocable
266
+ | AuthFlag.clawbackEnabled;
267
+
268
+ export namespace TrustLineFlag {
269
+ type deauthorize = 0;
270
+ type authorize = 1;
271
+ type authorizeToMaintainLiabilities = 2;
272
+ }
273
+ export type TrustLineFlag =
274
+ | TrustLineFlag.deauthorize
275
+ | TrustLineFlag.authorize
276
+ | TrustLineFlag.authorizeToMaintainLiabilities;
277
+
278
+ export namespace Signer {
279
+ interface Ed25519PublicKey {
280
+ ed25519PublicKey: string;
281
+ weight: number | undefined;
282
+ }
283
+ interface Sha256Hash {
284
+ sha256Hash: Buffer;
285
+ weight: number | undefined;
286
+ }
287
+ interface PreAuthTx {
288
+ preAuthTx: Buffer;
289
+ weight: number | undefined;
290
+ }
291
+ interface Ed25519SignedPayload {
292
+ ed25519SignedPayload: string;
293
+ weight?: number | string;
294
+ }
295
+ }
296
+ export namespace SignerKeyOptions {
297
+ interface Ed25519PublicKey {
298
+ ed25519PublicKey: string;
299
+ }
300
+ interface Sha256Hash {
301
+ sha256Hash: Buffer | string;
302
+ }
303
+ interface PreAuthTx {
304
+ preAuthTx: Buffer | string;
305
+ }
306
+ interface Ed25519SignedPayload {
307
+ ed25519SignedPayload: string;
308
+ }
309
+ }
310
+ export type Signer =
311
+ | Signer.Ed25519PublicKey
312
+ | Signer.Sha256Hash
313
+ | Signer.PreAuthTx
314
+ | Signer.Ed25519SignedPayload;
315
+
316
+ export type SignerKeyOptions =
317
+ | SignerKeyOptions.Ed25519PublicKey
318
+ | SignerKeyOptions.Sha256Hash
319
+ | SignerKeyOptions.PreAuthTx
320
+ | SignerKeyOptions.Ed25519SignedPayload;
321
+
322
+ export namespace SignerOptions {
323
+ interface Ed25519PublicKey {
324
+ ed25519PublicKey: string;
325
+ weight?: number | string;
326
+ }
327
+ interface Sha256Hash {
328
+ sha256Hash: Buffer | string;
329
+ weight?: number | string;
330
+ }
331
+ interface PreAuthTx {
332
+ preAuthTx: Buffer | string;
333
+ weight?: number | string;
334
+ }
335
+ interface Ed25519SignedPayload {
336
+ ed25519SignedPayload: string;
337
+ weight?: number | string;
338
+ }
339
+ }
340
+ export type SignerOptions =
341
+ | SignerOptions.Ed25519PublicKey
342
+ | SignerOptions.Sha256Hash
343
+ | SignerOptions.PreAuthTx
344
+ | SignerOptions.Ed25519SignedPayload;
345
+
346
+ export namespace OperationType {
347
+ type CreateAccount = 'createAccount';
348
+ type Payment = 'payment';
349
+ type PathPaymentStrictReceive = 'pathPaymentStrictReceive';
350
+ type PathPaymentStrictSend = 'pathPaymentStrictSend';
351
+ type CreatePassiveSellOffer = 'createPassiveSellOffer';
352
+ type ManageSellOffer = 'manageSellOffer';
353
+ type ManageBuyOffer = 'manageBuyOffer';
354
+ type SetOptions = 'setOptions';
355
+ type ChangeTrust = 'changeTrust';
356
+ type AllowTrust = 'allowTrust';
357
+ type AccountMerge = 'accountMerge';
358
+ type Inflation = 'inflation';
359
+ type ManageData = 'manageData';
360
+ type BumpSequence = 'bumpSequence';
361
+ type CreateClaimableBalance = 'createClaimableBalance';
362
+ type ClaimClaimableBalance = 'claimClaimableBalance';
363
+ type BeginSponsoringFutureReserves = 'beginSponsoringFutureReserves';
364
+ type EndSponsoringFutureReserves = 'endSponsoringFutureReserves';
365
+ type RevokeSponsorship = 'revokeSponsorship';
366
+ type Clawback = 'clawback';
367
+ type ClawbackClaimableBalance = 'clawbackClaimableBalance';
368
+ type SetTrustLineFlags = 'setTrustLineFlags';
369
+ type LiquidityPoolDeposit = 'liquidityPoolDeposit';
370
+ type LiquidityPoolWithdraw = 'liquidityPoolWithdraw';
371
+ type InvokeHostFunction = 'invokeHostFunction';
372
+ type ExtendFootprintTTL = 'extendFootprintTtl';
373
+ type RestoreFootprint = 'restoreFootprint';
374
+ }
375
+ export type OperationType =
376
+ | OperationType.CreateAccount
377
+ | OperationType.Payment
378
+ | OperationType.PathPaymentStrictReceive
379
+ | OperationType.PathPaymentStrictSend
380
+ | OperationType.CreatePassiveSellOffer
381
+ | OperationType.ManageSellOffer
382
+ | OperationType.ManageBuyOffer
383
+ | OperationType.SetOptions
384
+ | OperationType.ChangeTrust
385
+ | OperationType.AllowTrust
386
+ | OperationType.AccountMerge
387
+ | OperationType.Inflation
388
+ | OperationType.ManageData
389
+ | OperationType.BumpSequence
390
+ | OperationType.CreateClaimableBalance
391
+ | OperationType.ClaimClaimableBalance
392
+ | OperationType.BeginSponsoringFutureReserves
393
+ | OperationType.EndSponsoringFutureReserves
394
+ | OperationType.RevokeSponsorship
395
+ | OperationType.Clawback
396
+ | OperationType.ClawbackClaimableBalance
397
+ | OperationType.SetTrustLineFlags
398
+ | OperationType.LiquidityPoolDeposit
399
+ | OperationType.LiquidityPoolWithdraw
400
+ | OperationType.InvokeHostFunction
401
+ | OperationType.ExtendFootprintTTL
402
+ | OperationType.RestoreFootprint;
403
+
404
+ export namespace OperationOptions {
405
+ interface BaseOptions {
406
+ source?: string;
407
+ }
408
+ interface AccountMerge extends BaseOptions {
409
+ destination: string;
410
+ }
411
+ interface AllowTrust extends BaseOptions {
412
+ trustor: string;
413
+ assetCode: string;
414
+ authorize?: boolean | TrustLineFlag;
415
+ }
416
+ interface ChangeTrust extends BaseOptions {
417
+ asset: Asset | LiquidityPoolAsset;
418
+ limit?: string;
419
+ }
420
+ interface CreateAccount extends BaseOptions {
421
+ destination: string;
422
+ startingBalance: string;
423
+ }
424
+ interface CreatePassiveSellOffer extends BaseOptions {
425
+ selling: Asset;
426
+ buying: Asset;
427
+ amount: string;
428
+ price: number | string | object /* bignumber.js */;
429
+ }
430
+ interface ManageSellOffer extends CreatePassiveSellOffer {
431
+ offerId?: number | string;
432
+ }
433
+ interface ManageBuyOffer extends BaseOptions {
434
+ selling: Asset;
435
+ buying: Asset;
436
+ buyAmount: string;
437
+ price: number | string | object /* bignumber.js */;
438
+ offerId?: number | string;
439
+ }
440
+ // tslint:disable-next-line
441
+ interface Inflation extends BaseOptions {
442
+ // tslint:disable-line
443
+ }
444
+ interface ManageData extends BaseOptions {
445
+ name: string;
446
+ value: string | Buffer | null;
447
+ }
448
+ interface PathPaymentStrictReceive extends BaseOptions {
449
+ sendAsset: Asset;
450
+ sendMax: string;
451
+ destination: string;
452
+ destAsset: Asset;
453
+ destAmount: string;
454
+ path?: Asset[];
455
+ }
456
+ interface PathPaymentStrictSend extends BaseOptions {
457
+ sendAsset: Asset;
458
+ sendAmount: string;
459
+ destination: string;
460
+ destAsset: Asset;
461
+ destMin: string;
462
+ path?: Asset[];
463
+ }
464
+ interface Payment extends BaseOptions {
465
+ amount: string;
466
+ asset: Asset;
467
+ destination: string;
468
+ }
469
+ interface SetOptions<T extends SignerOptions = never> extends BaseOptions {
470
+ inflationDest?: string;
471
+ clearFlags?: AuthFlag;
472
+ setFlags?: AuthFlag;
473
+ masterWeight?: number | string;
474
+ lowThreshold?: number | string;
475
+ medThreshold?: number | string;
476
+ highThreshold?: number | string;
477
+ homeDomain?: string;
478
+ signer?: T;
479
+ }
480
+ interface BumpSequence extends BaseOptions {
481
+ bumpTo: string;
482
+ }
483
+ interface CreateClaimableBalance extends BaseOptions {
484
+ asset: Asset;
485
+ amount: string;
486
+ claimants: Claimant[];
487
+ }
488
+ interface ClaimClaimableBalance extends BaseOptions {
489
+ balanceId: string;
490
+ }
491
+ interface BeginSponsoringFutureReserves extends BaseOptions {
492
+ sponsoredId: string;
493
+ }
494
+ interface RevokeAccountSponsorship extends BaseOptions {
495
+ account: string;
496
+ }
497
+ interface RevokeTrustlineSponsorship extends BaseOptions {
498
+ account: string;
499
+ asset: Asset | LiquidityPoolId;
500
+ }
501
+ interface RevokeOfferSponsorship extends BaseOptions {
502
+ seller: string;
503
+ offerId: string;
504
+ }
505
+ interface RevokeDataSponsorship extends BaseOptions {
506
+ account: string;
507
+ name: string;
508
+ }
509
+ interface RevokeClaimableBalanceSponsorship extends BaseOptions {
510
+ balanceId: string;
511
+ }
512
+ interface RevokeLiquidityPoolSponsorship extends BaseOptions {
513
+ liquidityPoolId: string;
514
+ }
515
+ interface RevokeSignerSponsorship extends BaseOptions {
516
+ account: string;
517
+ signer: SignerKeyOptions;
518
+ }
519
+ interface Clawback extends BaseOptions {
520
+ asset: Asset;
521
+ amount: string;
522
+ from: string;
523
+ }
524
+ interface ClawbackClaimableBalance extends BaseOptions {
525
+ balanceId: string;
526
+ }
527
+ interface SetTrustLineFlags extends BaseOptions {
528
+ trustor: string;
529
+ asset: Asset;
530
+ flags: {
531
+ authorized?: boolean;
532
+ authorizedToMaintainLiabilities?: boolean;
533
+ clawbackEnabled?: boolean;
534
+ };
535
+ }
536
+ interface LiquidityPoolDeposit extends BaseOptions {
537
+ liquidityPoolId: string;
538
+ maxAmountA: string;
539
+ maxAmountB: string;
540
+ minPrice: number | string | object /* bignumber.js */;
541
+ maxPrice: number | string | object /* bignumber.js */;
542
+ }
543
+ interface LiquidityPoolWithdraw extends BaseOptions {
544
+ liquidityPoolId: string;
545
+ amount: string;
546
+ minAmountA: string;
547
+ minAmountB: string;
548
+ }
549
+
550
+ interface BaseInvocationOptions extends BaseOptions {
551
+ auth?: xdr.SorobanAuthorizationEntry[];
552
+ }
553
+ interface InvokeHostFunction extends BaseInvocationOptions {
554
+ func: xdr.HostFunction;
555
+ }
556
+ interface InvokeContractFunction extends BaseInvocationOptions {
557
+ contract: string;
558
+ function: string;
559
+ args: xdr.ScVal[];
560
+ }
561
+ interface CreateCustomContract extends BaseInvocationOptions {
562
+ address: Address;
563
+ wasmHash: Buffer | Uint8Array;
564
+ salt?: Buffer | Uint8Array;
565
+ }
566
+ interface CreateStellarAssetContract extends BaseOptions {
567
+ asset: Asset | string;
568
+ }
569
+ interface UploadContractWasm extends BaseOptions {
570
+ wasm: Buffer | Uint8Array;
571
+ }
572
+
573
+ interface ExtendFootprintTTL extends BaseOptions {
574
+ extendTo: number;
575
+ }
576
+ type RestoreFootprint = BaseOptions;
577
+ }
578
+ export type OperationOptions =
579
+ | OperationOptions.CreateAccount
580
+ | OperationOptions.Payment
581
+ | OperationOptions.PathPaymentStrictReceive
582
+ | OperationOptions.PathPaymentStrictSend
583
+ | OperationOptions.CreatePassiveSellOffer
584
+ | OperationOptions.ManageSellOffer
585
+ | OperationOptions.ManageBuyOffer
586
+ | OperationOptions.SetOptions
587
+ | OperationOptions.ChangeTrust
588
+ | OperationOptions.AllowTrust
589
+ | OperationOptions.AccountMerge
590
+ | OperationOptions.Inflation
591
+ | OperationOptions.ManageData
592
+ | OperationOptions.BumpSequence
593
+ | OperationOptions.CreateClaimableBalance
594
+ | OperationOptions.ClaimClaimableBalance
595
+ | OperationOptions.BeginSponsoringFutureReserves
596
+ | OperationOptions.RevokeAccountSponsorship
597
+ | OperationOptions.RevokeTrustlineSponsorship
598
+ | OperationOptions.RevokeOfferSponsorship
599
+ | OperationOptions.RevokeDataSponsorship
600
+ | OperationOptions.RevokeClaimableBalanceSponsorship
601
+ | OperationOptions.RevokeLiquidityPoolSponsorship
602
+ | OperationOptions.RevokeSignerSponsorship
603
+ | OperationOptions.Clawback
604
+ | OperationOptions.ClawbackClaimableBalance
605
+ | OperationOptions.SetTrustLineFlags
606
+ | OperationOptions.LiquidityPoolDeposit
607
+ | OperationOptions.LiquidityPoolWithdraw
608
+ | OperationOptions.InvokeHostFunction
609
+ | OperationOptions.ExtendFootprintTTL
610
+ | OperationOptions.RestoreFootprint
611
+ | OperationOptions.CreateCustomContract
612
+ | OperationOptions.CreateStellarAssetContract
613
+ | OperationOptions.InvokeContractFunction
614
+ | OperationOptions.UploadContractWasm;
615
+
616
+ export namespace Operation {
617
+ interface BaseOperation<T extends OperationType = OperationType> {
618
+ type: T;
619
+ source?: string;
620
+ }
621
+
622
+ interface AccountMerge extends BaseOperation<OperationType.AccountMerge> {
623
+ destination: string;
624
+ }
625
+ function accountMerge(
626
+ options: OperationOptions.AccountMerge
627
+ ): xdr.Operation<AccountMerge>;
628
+
629
+ interface AllowTrust extends BaseOperation<OperationType.AllowTrust> {
630
+ trustor: string;
631
+ assetCode: string;
632
+ // this is a boolean or a number so that it can support protocol 12 or 13
633
+ authorize: boolean | TrustLineFlag | undefined;
634
+ }
635
+ function allowTrust(
636
+ options: OperationOptions.AllowTrust
637
+ ): xdr.Operation<AllowTrust>;
638
+
639
+ interface ChangeTrust extends BaseOperation<OperationType.ChangeTrust> {
640
+ line: Asset | LiquidityPoolAsset;
641
+ limit: string;
642
+ }
643
+ function changeTrust(
644
+ options: OperationOptions.ChangeTrust
645
+ ): xdr.Operation<ChangeTrust>;
646
+
647
+ interface CreateAccount extends BaseOperation<OperationType.CreateAccount> {
648
+ destination: string;
649
+ startingBalance: string;
650
+ }
651
+ function createAccount(
652
+ options: OperationOptions.CreateAccount
653
+ ): xdr.Operation<CreateAccount>;
654
+
655
+ interface CreatePassiveSellOffer
656
+ extends BaseOperation<OperationType.CreatePassiveSellOffer> {
657
+ selling: Asset;
658
+ buying: Asset;
659
+ amount: string;
660
+ price: string;
661
+ }
662
+ function createPassiveSellOffer(
663
+ options: OperationOptions.CreatePassiveSellOffer
664
+ ): xdr.Operation<CreatePassiveSellOffer>;
665
+
666
+ interface Inflation extends BaseOperation<OperationType.Inflation> {}
667
+ function inflation(
668
+ options: OperationOptions.Inflation
669
+ ): xdr.Operation<Inflation>;
670
+
671
+ interface ManageData extends BaseOperation<OperationType.ManageData> {
672
+ name: string;
673
+ value?: Buffer;
674
+ }
675
+ function manageData(
676
+ options: OperationOptions.ManageData
677
+ ): xdr.Operation<ManageData>;
678
+
679
+ interface ManageSellOffer
680
+ extends BaseOperation<OperationType.ManageSellOffer> {
681
+ selling: Asset;
682
+ buying: Asset;
683
+ amount: string;
684
+ price: string;
685
+ offerId: string;
686
+ }
687
+ function manageSellOffer(
688
+ options: OperationOptions.ManageSellOffer
689
+ ): xdr.Operation<ManageSellOffer>;
690
+
691
+ interface ManageBuyOffer extends BaseOperation<OperationType.ManageBuyOffer> {
692
+ selling: Asset;
693
+ buying: Asset;
694
+ buyAmount: string;
695
+ price: string;
696
+ offerId: string;
697
+ }
698
+ function manageBuyOffer(
699
+ options: OperationOptions.ManageBuyOffer
700
+ ): xdr.Operation<ManageBuyOffer>;
701
+
702
+ interface PathPaymentStrictReceive
703
+ extends BaseOperation<OperationType.PathPaymentStrictReceive> {
704
+ sendAsset: Asset;
705
+ sendMax: string;
706
+ destination: string;
707
+ destAsset: Asset;
708
+ destAmount: string;
709
+ path: Asset[];
710
+ }
711
+ function pathPaymentStrictReceive(
712
+ options: OperationOptions.PathPaymentStrictReceive
713
+ ): xdr.Operation<PathPaymentStrictReceive>;
714
+
715
+ interface PathPaymentStrictSend
716
+ extends BaseOperation<OperationType.PathPaymentStrictSend> {
717
+ sendAsset: Asset;
718
+ sendAmount: string;
719
+ destination: string;
720
+ destAsset: Asset;
721
+ destMin: string;
722
+ path: Asset[];
723
+ }
724
+ function pathPaymentStrictSend(
725
+ options: OperationOptions.PathPaymentStrictSend
726
+ ): xdr.Operation<PathPaymentStrictSend>;
727
+
728
+ interface Payment extends BaseOperation<OperationType.Payment> {
729
+ amount: string;
730
+ asset: Asset;
731
+ destination: string;
732
+ }
733
+ function payment(options: OperationOptions.Payment): xdr.Operation<Payment>;
734
+
735
+ interface SetOptions<T extends SignerOptions = SignerOptions>
736
+ extends BaseOperation<OperationType.SetOptions> {
737
+ inflationDest?: string;
738
+ clearFlags?: AuthFlag;
739
+ setFlags?: AuthFlag;
740
+ masterWeight?: number;
741
+ lowThreshold?: number;
742
+ medThreshold?: number;
743
+ highThreshold?: number;
744
+ homeDomain?: string;
745
+ signer: T extends { ed25519PublicKey: any }
746
+ ? Signer.Ed25519PublicKey
747
+ : T extends { sha256Hash: any }
748
+ ? Signer.Sha256Hash
749
+ : T extends { preAuthTx: any }
750
+ ? Signer.PreAuthTx
751
+ : T extends { ed25519SignedPayload: any }
752
+ ? Signer.Ed25519SignedPayload
753
+ : never;
754
+ }
755
+ function setOptions<T extends SignerOptions = never>(
756
+ options: OperationOptions.SetOptions<T>
757
+ ): xdr.Operation<SetOptions<T>>;
758
+
759
+ interface BumpSequence extends BaseOperation<OperationType.BumpSequence> {
760
+ bumpTo: string;
761
+ }
762
+ function bumpSequence(
763
+ options: OperationOptions.BumpSequence
764
+ ): xdr.Operation<BumpSequence>;
765
+
766
+ interface CreateClaimableBalance extends BaseOperation<OperationType.CreateClaimableBalance> {
767
+ amount: string;
768
+ asset: Asset;
769
+ claimants: Claimant[];
770
+ }
771
+ function createClaimableBalance(
772
+ options: OperationOptions.CreateClaimableBalance
773
+ ): xdr.Operation<CreateClaimableBalance>;
774
+
775
+ interface ClaimClaimableBalance extends BaseOperation<OperationType.ClaimClaimableBalance> {
776
+ balanceId: string;
777
+ }
778
+ function claimClaimableBalance(
779
+ options: OperationOptions.ClaimClaimableBalance
780
+ ): xdr.Operation<ClaimClaimableBalance>;
781
+
782
+ interface BeginSponsoringFutureReserves extends BaseOperation<OperationType.BeginSponsoringFutureReserves> {
783
+ sponsoredId: string;
784
+ }
785
+ function beginSponsoringFutureReserves(
786
+ options: OperationOptions.BeginSponsoringFutureReserves
787
+ ): xdr.Operation<BeginSponsoringFutureReserves>;
788
+
789
+ interface EndSponsoringFutureReserves extends BaseOperation<OperationType.EndSponsoringFutureReserves> {
790
+ }
791
+ function endSponsoringFutureReserves(
792
+ options: OperationOptions.BaseOptions
793
+ ): xdr.Operation<EndSponsoringFutureReserves>;
794
+
795
+ interface RevokeAccountSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
796
+ account: string;
797
+ }
798
+ function revokeAccountSponsorship(
799
+ options: OperationOptions.RevokeAccountSponsorship
800
+ ): xdr.Operation<RevokeAccountSponsorship>;
801
+
802
+ interface RevokeTrustlineSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
803
+ account: string;
804
+ asset: Asset | LiquidityPoolId;
805
+ }
806
+ function revokeTrustlineSponsorship(
807
+ options: OperationOptions.RevokeTrustlineSponsorship
808
+ ): xdr.Operation<RevokeTrustlineSponsorship>;
809
+
810
+ interface RevokeOfferSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
811
+ seller: string;
812
+ offerId: string;
813
+ }
814
+ function revokeOfferSponsorship(
815
+ options: OperationOptions.RevokeOfferSponsorship
816
+ ): xdr.Operation<RevokeOfferSponsorship>;
817
+
818
+ interface RevokeDataSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
819
+ account: string;
820
+ name: string;
821
+ }
822
+ function revokeDataSponsorship(
823
+ options: OperationOptions.RevokeDataSponsorship
824
+ ): xdr.Operation<RevokeDataSponsorship>;
825
+
826
+ interface RevokeClaimableBalanceSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
827
+ balanceId: string;
828
+ }
829
+ function revokeClaimableBalanceSponsorship(
830
+ options: OperationOptions.RevokeClaimableBalanceSponsorship
831
+ ): xdr.Operation<RevokeClaimableBalanceSponsorship>;
832
+
833
+ interface RevokeLiquidityPoolSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
834
+ liquidityPoolId: string;
835
+ }
836
+ function revokeLiquidityPoolSponsorship(
837
+ options: OperationOptions.RevokeLiquidityPoolSponsorship
838
+ ): xdr.Operation<RevokeLiquidityPoolSponsorship>;
839
+
840
+ interface RevokeSignerSponsorship extends BaseOperation<OperationType.RevokeSponsorship> {
841
+ account: string;
842
+ signer: SignerKeyOptions;
843
+ }
844
+ function revokeSignerSponsorship(
845
+ options: OperationOptions.RevokeSignerSponsorship
846
+ ): xdr.Operation<RevokeSignerSponsorship>;
847
+
848
+ interface Clawback extends BaseOperation<OperationType.Clawback> {
849
+ asset: Asset;
850
+ amount: string;
851
+ from: string;
852
+ }
853
+ function clawback(
854
+ options: OperationOptions.Clawback
855
+ ): xdr.Operation<Clawback>;
856
+
857
+ interface ClawbackClaimableBalance extends BaseOperation<OperationType.ClawbackClaimableBalance> {
858
+ balanceId: string;
859
+ }
860
+ function clawbackClaimableBalance(
861
+ options: OperationOptions.ClawbackClaimableBalance
862
+ ): xdr.Operation<ClawbackClaimableBalance>;
863
+
864
+ interface SetTrustLineFlags extends BaseOperation<OperationType.SetTrustLineFlags> {
865
+ trustor: string;
866
+ asset: Asset;
867
+ flags: {
868
+ authorized?: boolean;
869
+ authorizedToMaintainLiabilities?: boolean;
870
+ clawbackEnabled?: boolean;
871
+ };
872
+ }
873
+ function setTrustLineFlags(
874
+ options: OperationOptions.SetTrustLineFlags
875
+ ): xdr.Operation<SetTrustLineFlags>;
876
+ interface LiquidityPoolDeposit extends BaseOperation<OperationType.LiquidityPoolDeposit> {
877
+ liquidityPoolId: string;
878
+ maxAmountA: string;
879
+ maxAmountB: string;
880
+ minPrice: string;
881
+ maxPrice: string;
882
+ }
883
+ function liquidityPoolDeposit(
884
+ options: OperationOptions.LiquidityPoolDeposit
885
+ ): xdr.Operation<LiquidityPoolDeposit>;
886
+ interface LiquidityPoolWithdraw extends BaseOperation<OperationType.LiquidityPoolWithdraw> {
887
+ liquidityPoolId: string;
888
+ amount: string;
889
+ minAmountA: string;
890
+ minAmountB: string;
891
+ }
892
+ function liquidityPoolWithdraw(
893
+ options: OperationOptions.LiquidityPoolWithdraw
894
+ ): xdr.Operation<LiquidityPoolWithdraw>;
895
+ interface InvokeHostFunction extends BaseOperation<OperationType.InvokeHostFunction> {
896
+ func: xdr.HostFunction;
897
+ auth?: xdr.SorobanAuthorizationEntry[];
898
+ }
899
+ function invokeHostFunction(
900
+ options: OperationOptions.InvokeHostFunction
901
+ ): xdr.Operation<InvokeHostFunction>;
902
+
903
+ function extendFootprintTtl(
904
+ options: OperationOptions.ExtendFootprintTTL
905
+ ): xdr.Operation<ExtendFootprintTTL>;
906
+ interface ExtendFootprintTTL extends BaseOperation<OperationType.ExtendFootprintTTL> {
907
+ extendTo: number;
908
+ }
909
+
910
+ function restoreFootprint(options: OperationOptions.RestoreFootprint):
911
+ xdr.Operation<RestoreFootprint>;
912
+ interface RestoreFootprint extends BaseOperation<OperationType.RestoreFootprint> {}
913
+
914
+ function createCustomContract(
915
+ opts: OperationOptions.CreateCustomContract
916
+ ): xdr.Operation<InvokeHostFunction>;
917
+ function createStellarAssetContract(
918
+ opts: OperationOptions.CreateStellarAssetContract
919
+ ): xdr.Operation<InvokeHostFunction>;
920
+ function invokeContractFunction(
921
+ opts: OperationOptions.InvokeContractFunction
922
+ ): xdr.Operation<InvokeHostFunction>;
923
+ function uploadContractWasm(
924
+ opts: OperationOptions.UploadContractWasm
925
+ ): xdr.Operation<InvokeHostFunction>;
926
+
927
+ function fromXDRObject<T extends Operation = Operation>(
928
+ xdrOperation: xdr.Operation<T>
929
+ ): T;
930
+ }
931
+ export type Operation =
932
+ | Operation.CreateAccount
933
+ | Operation.Payment
934
+ | Operation.PathPaymentStrictReceive
935
+ | Operation.PathPaymentStrictSend
936
+ | Operation.CreatePassiveSellOffer
937
+ | Operation.ManageSellOffer
938
+ | Operation.ManageBuyOffer
939
+ | Operation.SetOptions
940
+ | Operation.ChangeTrust
941
+ | Operation.AllowTrust
942
+ | Operation.AccountMerge
943
+ | Operation.Inflation
944
+ | Operation.ManageData
945
+ | Operation.BumpSequence
946
+ | Operation.CreateClaimableBalance
947
+ | Operation.ClaimClaimableBalance
948
+ | Operation.BeginSponsoringFutureReserves
949
+ | Operation.EndSponsoringFutureReserves
950
+ | Operation.RevokeAccountSponsorship
951
+ | Operation.RevokeTrustlineSponsorship
952
+ | Operation.RevokeOfferSponsorship
953
+ | Operation.RevokeDataSponsorship
954
+ | Operation.RevokeClaimableBalanceSponsorship
955
+ | Operation.RevokeLiquidityPoolSponsorship
956
+ | Operation.RevokeSignerSponsorship
957
+ | Operation.Clawback
958
+ | Operation.ClawbackClaimableBalance
959
+ | Operation.SetTrustLineFlags
960
+ | Operation.LiquidityPoolDeposit
961
+ | Operation.LiquidityPoolWithdraw
962
+ | Operation.InvokeHostFunction
963
+ | Operation.ExtendFootprintTTL
964
+ | Operation.RestoreFootprint;
965
+
966
+ export namespace StrKey {
967
+ function encodeEd25519PublicKey(data: Buffer): string;
968
+ function decodeEd25519PublicKey(address: string): Buffer;
969
+ function isValidEd25519PublicKey(Key: string): boolean;
970
+
971
+ function encodeEd25519SecretSeed(data: Buffer): string;
972
+ function decodeEd25519SecretSeed(address: string): Buffer;
973
+ function isValidEd25519SecretSeed(seed: string): boolean;
974
+
975
+ function encodeMed25519PublicKey(data: Buffer): string;
976
+ function decodeMed25519PublicKey(address: string): Buffer;
977
+ function isValidMed25519PublicKey(publicKey: string): boolean;
978
+
979
+ function encodeSignedPayload(data: Buffer): string;
980
+ function decodeSignedPayload(address: string): Buffer;
981
+ function isValidSignedPayload(address: string): boolean;
982
+
983
+ function encodePreAuthTx(data: Buffer): string;
984
+ function decodePreAuthTx(address: string): Buffer;
985
+
986
+ function encodeSha256Hash(data: Buffer): string;
987
+ function decodeSha256Hash(address: string): Buffer;
988
+
989
+ function encodeContract(data: Buffer): string;
990
+ function decodeContract(address: string): Buffer;
991
+ }
992
+
993
+ export namespace SignerKey {
994
+ function decodeAddress(address: string): xdr.SignerKey;
995
+ function encodeSignerKey(signerKey: xdr.SignerKey): string;
996
+ }
997
+
998
+ export class TransactionI {
999
+ addSignature(publicKey: string, signature: string): void;
1000
+ addDecoratedSignature(signature: xdr.DecoratedSignature): void;
1001
+
1002
+ fee: string;
1003
+ getKeypairSignature(keypair: Keypair): string;
1004
+ hash(): Buffer;
1005
+ networkPassphrase: string;
1006
+ sign(...keypairs: Keypair[]): void;
1007
+ signatureBase(): Buffer;
1008
+ signatures: xdr.DecoratedSignature[];
1009
+ signHashX(preimage: Buffer | string): void;
1010
+ toEnvelope(): xdr.TransactionEnvelope;
1011
+ toXDR(): string;
1012
+ }
1013
+
1014
+ export class FeeBumpTransaction extends TransactionI {
1015
+ constructor(
1016
+ envelope: string | xdr.TransactionEnvelope,
1017
+ networkPassphrase: string
1018
+ );
1019
+ feeSource: string;
1020
+ innerTransaction: Transaction;
1021
+ }
1022
+
1023
+ export class Transaction<
1024
+ TMemo extends Memo = Memo,
1025
+ TOps extends Operation[] = Operation[]
1026
+ > extends TransactionI {
1027
+ constructor(
1028
+ envelope: string | xdr.TransactionEnvelope,
1029
+ networkPassphrase: string
1030
+ );
1031
+ memo: TMemo;
1032
+ operations: TOps;
1033
+ sequence: string;
1034
+ source: string;
1035
+ timeBounds?: {
1036
+ minTime: string;
1037
+ maxTime: string;
1038
+ };
1039
+ ledgerBounds?: {
1040
+ minLedger: number;
1041
+ maxLedger: number;
1042
+ };
1043
+ minAccountSequence?: string;
1044
+ minAccountSequenceAge?: number;
1045
+ minAccountSequenceLedgerGap?: number;
1046
+ extraSigners?: string[];
1047
+
1048
+ getClaimableBalanceId(opIndex: number): string;
1049
+ }
1050
+
1051
+ export const BASE_FEE = '100';
1052
+ export const TimeoutInfinite = 0;
1053
+
1054
+ export class TransactionBuilder {
1055
+ constructor(
1056
+ sourceAccount: Account,
1057
+ options?: TransactionBuilder.TransactionBuilderOptions
1058
+ );
1059
+ addOperation(operation: xdr.Operation): this;
1060
+ clearOperations(): this;
1061
+ addMemo(memo: Memo): this;
1062
+ setTimeout(timeoutInSeconds: number): this;
1063
+ setTimebounds(min: Date | number, max: Date | number): this;
1064
+ setLedgerbounds(minLedger: number, maxLedger: number): this;
1065
+ setMinAccountSequence(minAccountSequence: string): this;
1066
+ setMinAccountSequenceAge(durationInSeconds: number): this;
1067
+ setMinAccountSequenceLedgerGap(gap: number): this;
1068
+ setExtraSigners(extraSigners: string[]): this;
1069
+ setSorobanData(sorobanData: string | xdr.SorobanTransactionData): this;
1070
+ build(): Transaction;
1071
+ setNetworkPassphrase(networkPassphrase: string): this;
1072
+
1073
+ static cloneFrom(
1074
+ tx: Transaction,
1075
+ optionOverrides?: TransactionBuilder.TransactionBuilderOptions
1076
+ ): TransactionBuilder;
1077
+ static buildFeeBumpTransaction(
1078
+ feeSource: Keypair | string,
1079
+ baseFee: string,
1080
+ innerTx: Transaction,
1081
+ networkPassphrase: string
1082
+ ): FeeBumpTransaction;
1083
+ static fromXDR(
1084
+ envelope: string | xdr.TransactionEnvelope,
1085
+ networkPassphrase: string
1086
+ ): Transaction | FeeBumpTransaction;
1087
+ }
1088
+
1089
+ export namespace TransactionBuilder {
1090
+ interface TransactionBuilderOptions {
1091
+ fee: string;
1092
+ memo?: Memo;
1093
+ networkPassphrase?: string;
1094
+ // preconditions:
1095
+ timebounds?: {
1096
+ minTime?: Date | number | string;
1097
+ maxTime?: Date | number | string;
1098
+ };
1099
+ ledgerbounds?: {
1100
+ minLedger?: number;
1101
+ maxLedger?: number;
1102
+ };
1103
+ minAccountSequence?: string;
1104
+ minAccountSequenceAge?: number;
1105
+ minAccountSequenceLedgerGap?: number;
1106
+ extraSigners?: string[];
1107
+ sorobanData?: string | xdr.SorobanTransactionData;
1108
+ }
1109
+ }
1110
+
1111
+ export function hash(data: Buffer): Buffer;
1112
+ export function sign(data: Buffer, rawSecret: Buffer): Buffer;
1113
+ export function verify(
1114
+ data: Buffer,
1115
+ signature: Buffer,
1116
+ rawPublicKey: Buffer
1117
+ ): boolean;
1118
+
1119
+ export function decodeAddressToMuxedAccount(address: string, supportMuxing: boolean): xdr.MuxedAccount;
1120
+ export function encodeMuxedAccountToAddress(account: xdr.MuxedAccount, supportMuxing: boolean): string;
1121
+ export function encodeMuxedAccount(gAddress: string, id: string): xdr.MuxedAccount;
1122
+ export function extractBaseAddress(address: string): string;
1123
+
1124
+ export type IntLike = string | number | bigint;
1125
+ export type ScIntType =
1126
+ | 'i64'
1127
+ | 'u64'
1128
+ | 'i128'
1129
+ | 'u128'
1130
+ | 'i256'
1131
+ | 'u256';
1132
+
1133
+ export class XdrLargeInt {
1134
+ constructor(
1135
+ type: ScIntType,
1136
+ values: IntLike | IntLike[]
1137
+ );
1138
+
1139
+ toNumber(): number;
1140
+ toBigInt(): bigint;
1141
+
1142
+ toI64(): xdr.ScVal;
1143
+ toU64(): xdr.ScVal;
1144
+ toI128(): xdr.ScVal;
1145
+ toU128(): xdr.ScVal;
1146
+ toI256(): xdr.ScVal;
1147
+ toU256(): xdr.ScVal;
1148
+ toScVal(): xdr.ScVal;
1149
+
1150
+ valueOf(): any; // FIXME
1151
+ toString(): string;
1152
+ toJSON(): {
1153
+ value: string;
1154
+ type: ScIntType;
1155
+ };
1156
+
1157
+ static isType(t: string): t is ScIntType;
1158
+ static getType(scvType: string): ScIntType;
1159
+ }
1160
+
1161
+ export class ScInt extends XdrLargeInt {
1162
+ constructor(value: IntLike, opts?: { type: ScIntType });
1163
+ }
1164
+
1165
+ export function scValToBigInt(scv: xdr.ScVal): bigint;
1166
+ export function nativeToScVal(val: any, opts?: { type: any }): xdr.ScVal;
1167
+ export function scValToNative(scv: xdr.ScVal): any;
1168
+
1169
+ interface SorobanEvent {
1170
+ type: 'system'|'contract'|'diagnostic'; // xdr.ContractEventType.name
1171
+ contractId?: string; // C... encoded strkey
1172
+
1173
+ topics: any[]; // essentially a call of map(event.body.topics, scValToNative)
1174
+ data: any; // similarly, scValToNative(rawEvent.data);
1175
+ }
1176
+
1177
+ export function humanizeEvents(
1178
+ events: xdr.DiagnosticEvent[] | xdr.ContractEvent[]
1179
+ ): SorobanEvent[];
1180
+
1181
+ export class SorobanDataBuilder {
1182
+ constructor(data?: string | Uint8Array | Buffer | xdr.SorobanTransactionData);
1183
+ static fromXDR(data: Uint8Array | Buffer | string): SorobanDataBuilder;
1184
+
1185
+ setResourceFee(fee: IntLike): SorobanDataBuilder;
1186
+ setResources(
1187
+ cpuInstrs: number,
1188
+ readBytes: number,
1189
+ writeBytes: number
1190
+ ): SorobanDataBuilder;
1191
+
1192
+ setFootprint(
1193
+ readOnly?: xdr.LedgerKey[] | null,
1194
+ readWrite?: xdr.LedgerKey[] | null
1195
+ ): SorobanDataBuilder;
1196
+ appendFootprint(
1197
+ readOnly: xdr.LedgerKey[],
1198
+ readWrite: xdr.LedgerKey[]
1199
+ ): SorobanDataBuilder;
1200
+
1201
+ setReadOnly(keys: xdr.LedgerKey[]): SorobanDataBuilder;
1202
+ setReadWrite(keys: xdr.LedgerKey[]): SorobanDataBuilder;
1203
+
1204
+ getFootprint(): xdr.LedgerFootprint;
1205
+ getReadOnly(): xdr.LedgerKey[];
1206
+ getReadWrite(): xdr.LedgerKey[];
1207
+
1208
+ build(): xdr.SorobanTransactionData;
1209
+ }
1210
+
1211
+ export type SigningCallback = (
1212
+ preimage: xdr.HashIdPreimage
1213
+ ) => Promise<Buffer | Uint8Array | ArrayBuffer /* Buffer-like */>;
1214
+
1215
+ export function authorizeInvocation(
1216
+ signer: Keypair | SigningCallback,
1217
+ validUntil: number,
1218
+ invocation: xdr.SorobanAuthorizedInvocation,
1219
+ publicKey?: string,
1220
+ networkPassphrase?: string
1221
+ ): Promise<xdr.SorobanAuthorizationEntry>;
1222
+
1223
+ export function authorizeEntry(
1224
+ entry: xdr.SorobanAuthorizationEntry,
1225
+ signer: Keypair | SigningCallback,
1226
+ validUntilLedgerSeq: number,
1227
+ networkPassphrase?: string
1228
+ ): Promise<xdr.SorobanAuthorizationEntry>;
1229
+
1230
+ export interface CreateInvocation {
1231
+ type: 'wasm' | 'sac';
1232
+ token?: string;
1233
+ wasm?: {
1234
+ hash: string;
1235
+ address: string;
1236
+ salt: string;
1237
+ };
1238
+ }
1239
+
1240
+ export interface ExecuteInvocation {
1241
+ source: string;
1242
+ function: string;
1243
+ args: any[];
1244
+ }
1245
+
1246
+ export interface InvocationTree {
1247
+ type: 'execute' | 'create';
1248
+ args: CreateInvocation | ExecuteInvocation;
1249
+ invocations: InvocationTree[];
1250
+ }
1251
+
1252
+ export function buildInvocationTree(
1253
+ root: xdr.SorobanAuthorizedInvocation
1254
+ ): InvocationTree;
1255
+
1256
+ export type InvocationWalker = (
1257
+ node: xdr.SorobanAuthorizedInvocation,
1258
+ depth: number,
1259
+ parent?: any
1260
+ ) => boolean|null;
1261
+
1262
+ export function walkInvocationTree(
1263
+ root: xdr.SorobanAuthorizedInvocation,
1264
+ callback: InvocationWalker
1265
+ ): void;
1266
+
1267
+ export namespace Soroban {
1268
+ function formatTokenAmount(address: string, decimals: number): string;
1269
+ function parseTokenAmount(value: string, decimals: number): string;
1270
+ }