diff --git a/package.json b/package.json index 13137d9..98e5a1f 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "jws": "^4.0.0", "lodash": "^4.17.21", "query-string": "^7.1.3", - "stellar-sdk": "^11.0.0-beta.3", + "stellar-sdk": "^11.0.0-beta.6", "stream-http": "^3.2.0", "url": "^0.11.0", "util": "^0.12.5", diff --git a/src/walletSdk/Anchor/index.ts b/src/walletSdk/Anchor/index.ts index 4611e22..27d7b3b 100644 --- a/src/walletSdk/Anchor/index.ts +++ b/src/walletSdk/Anchor/index.ts @@ -1,5 +1,5 @@ import { AxiosInstance } from "axios"; -import { StellarTomlResolver } from "stellar-sdk"; +import { StellarToml } from "stellar-sdk"; import { Config } from "walletSdk"; import { Sep10 } from "../Auth"; @@ -70,7 +70,7 @@ export class Anchor { } // fetch fresh TOML values from Anchor domain - const stellarToml = await StellarTomlResolver.resolve(this.homeDomain); + const stellarToml = await StellarToml.Resolver.resolve(this.homeDomain); const parsedToml = parseToml(stellarToml); this.toml = parsedToml; return parsedToml; diff --git a/src/walletSdk/Exceptions/index.ts b/src/walletSdk/Exceptions/index.ts index 34e970f..e9160eb 100644 --- a/src/walletSdk/Exceptions/index.ts +++ b/src/walletSdk/Exceptions/index.ts @@ -68,7 +68,7 @@ export class AccountDoesNotExistError extends Error { } export class TransactionSubmitFailedError extends Error { - constructor(response: Horizon.SubmitTransactionResponse) { + constructor(response: Horizon.HorizonApi.SubmitTransactionResponse) { super(`Submit transaction failed ${JSON.stringify(response)}`); Object.setPrototypeOf(this, TransactionSubmitFailedError.prototype); } diff --git a/src/walletSdk/Horizon/AccountService.ts b/src/walletSdk/Horizon/AccountService.ts index 6db2ca8..b84d51c 100644 --- a/src/walletSdk/Horizon/AccountService.ts +++ b/src/walletSdk/Horizon/AccountService.ts @@ -1,4 +1,4 @@ -import { Keypair, Networks, Server, ServerApi } from "stellar-sdk"; +import { Keypair, Networks, Horizon } from "stellar-sdk"; import { Config } from "walletSdk"; import { SigningKeypair } from "./Account"; @@ -17,7 +17,7 @@ import { OperationsLimitExceededError } from "../Exceptions"; * @class */ export class AccountService { - private server: Server; + private server: Horizon.Server; private network: Networks; /** @@ -53,16 +53,16 @@ export class AccountService { * Get account information from the Stellar network. * @param {object} params - The parameters for retrieving account information. * @param {string} params.accountAddress - Stellar address of the account. - * @param {Server} [params.serverInstance=this.server] - Horizon server instance when default doesn't work. - * @returns {Promise} Account information. + * @param {Horizon.HorizonApi.Server} [params.serverInstance=this.server] - Horizon server instance when default doesn't work. + * @returns {Promise} Account information. */ async getInfo({ accountAddress, serverInstance = this.server, }: { accountAddress: string; - serverInstance?: Server; - }): Promise { + serverInstance?: Horizon.Server; + }): Promise { return serverInstance.accounts().accountId(accountAddress).call(); } @@ -74,7 +74,7 @@ export class AccountService { * @param {HORIZON_ORDER} [params.order=HORIZON_ORDER.DESC] - Data order, ascending or descending, defaults to descending * @param {string} [params.cursor] - Cursor to specify a starting point * @param {boolean} [params.includeFailed=false] - Flag to include failed operations. - * @returns {Promise>} A list of operations. + * @returns {Promise>} A list of operations. * @throws {OperationsLimitExceededError} when maximum limit of 200 is exceeded. */ async getHistory({ @@ -89,7 +89,9 @@ export class AccountService { order?: HORIZON_ORDER; cursor?: string; includeFailed?: boolean; - }): Promise> { + }): Promise< + Horizon.ServerApi.CollectionPage + > { if (limit > HORIZON_LIMIT_MAX) { throw new OperationsLimitExceededError(HORIZON_LIMIT_MAX); } diff --git a/src/walletSdk/Horizon/Stellar.ts b/src/walletSdk/Horizon/Stellar.ts index a7e299d..069938f 100644 --- a/src/walletSdk/Horizon/Stellar.ts +++ b/src/walletSdk/Horizon/Stellar.ts @@ -1,6 +1,6 @@ import { Account as StellarAccount, - Server, + Horizon, Transaction, TransactionBuilder as StellarTransactionBuilder, FeeBumpTransaction, @@ -30,7 +30,7 @@ import { SigningKeypair } from "./Account"; */ export class Stellar { private cfg: Config; - server: Server; + server: Horizon.Server; /** * Creates a new instance of the Stellar class. @@ -54,7 +54,7 @@ export class Stellar { * Construct a Stellar transaction. * @param {TransactionParams} params - The Transaction params. * @param {AccountKeypair} params.sourceAddress - The source account keypair. - * @param {Server.Timebounds | number} [params.timebounds] - The timebounds for the transaction. + * @param {Horizon.Server.Timebounds | number} [params.timebounds] - The timebounds for the transaction. * If a number is given, then timebounds constructed from now to now + number in seconds. * @param {number} [params.baseFee] - The base fee for the transaction. Defaults to the config base fee. * @param {Memo} [params.memo] - The memo for the transaction. @@ -76,7 +76,7 @@ export class Stellar { throw new AccountDoesNotExistError(this.cfg.stellar.network); } - let formattedTimebounds: Server.Timebounds | undefined; + let formattedTimebounds: Horizon.Server.Timebounds | undefined; if (typeof timebounds === "number") { formattedTimebounds = { minTime: 0, diff --git a/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts b/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts index 52ed0e0..09762dc 100644 --- a/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts +++ b/src/walletSdk/Horizon/Transaction/TransactionBuilder.ts @@ -2,7 +2,7 @@ import StellarSdk, { TransactionBuilder as StellarTransactionBuilder, Account as StellarAccount, Transaction, - Server, + Horizon, Memo, xdr, } from "stellar-sdk"; @@ -41,14 +41,14 @@ export class TransactionBuilder extends CommonTransactionBuilder signerAddress, diff --git a/src/walletSdk/Types/horizon.ts b/src/walletSdk/Types/horizon.ts index 3aaa820..54cd93c 100644 --- a/src/walletSdk/Types/horizon.ts +++ b/src/walletSdk/Types/horizon.ts @@ -1,4 +1,4 @@ -import { Memo, Server, Transaction } from "stellar-sdk"; +import { Memo, Horizon, Transaction } from "stellar-sdk"; import { AccountKeypair } from "../Horizon/Account"; import { SponsoringBuilder, TransactionBuilder } from "walletSdk/Horizon"; import { StellarAssetId } from "../Asset"; @@ -12,7 +12,7 @@ export type TransactionParams = { sourceAddress: AccountKeypair; baseFee?: number; memo?: Memo; - timebounds?: Server.Timebounds | number; + timebounds?: Horizon.Server.Timebounds | number; }; export type FeeBumpTransactionParams = { diff --git a/src/walletSdk/Utils/toml.ts b/src/walletSdk/Utils/toml.ts index 71a32c7..085e2ba 100644 --- a/src/walletSdk/Utils/toml.ts +++ b/src/walletSdk/Utils/toml.ts @@ -1,8 +1,8 @@ -import { StellarTomlResolver } from "stellar-sdk"; +import { StellarToml } from "stellar-sdk"; import { TomlInfo } from "../Types"; -export const parseToml = (toml: StellarTomlResolver.StellarToml): TomlInfo => { +export const parseToml = (toml: StellarToml.Api.StellarToml): TomlInfo => { const tomlDocumentation = toml["DOCUMENTATION"]; const documentation = { orgName: tomlDocumentation["ORG_NAME"], diff --git a/src/walletSdk/index.ts b/src/walletSdk/index.ts index 3191d3c..f08d1a6 100644 --- a/src/walletSdk/index.ts +++ b/src/walletSdk/index.ts @@ -1,5 +1,5 @@ import axios, { AxiosInstance } from "axios"; -import { Networks, Server } from "stellar-sdk"; +import { Networks, Horizon } from "stellar-sdk"; import { Anchor } from "./Anchor"; import { DefaultSigner, WalletSigner } from "./Auth"; @@ -125,7 +125,7 @@ export class Config { } export class StellarConfiguration { - server: Server; + server: Horizon.Server; network: Networks; horizonUrl: string; baseFee: number; @@ -155,7 +155,7 @@ export class StellarConfiguration { this.horizonUrl = horizonUrl; this.baseFee = baseFee; this.defaultTimeout = defaultTimeout; - this.server = new Server(horizonUrl); + this.server = new Horizon.Server(horizonUrl); } } diff --git a/test/accountService.test.ts b/test/accountService.test.ts index ee9ed3a..7b6b168 100644 --- a/test/accountService.test.ts +++ b/test/accountService.test.ts @@ -83,7 +83,8 @@ describe("Horizon", () => { expect( response.balances.some( (balance) => - (balance as Horizon.BalanceLineAsset).asset_code === "USDC", + (balance as Horizon.HorizonApi.BalanceLineAsset).asset_code === + "USDC", ), ).toBeTruthy(); }); @@ -112,12 +113,14 @@ describe("Horizon", () => { expect(response.records[0]).toHaveProperty("created_at"); expect( response.records.some( - ({ type }) => type === Horizon.OperationResponseType.createAccount, + ({ type }) => + type === Horizon.HorizonApi.OperationResponseType.createAccount, ), ).toBeTruthy(); expect( response.records.some( - ({ type }) => type === Horizon.OperationResponseType.changeTrust, + ({ type }) => + type === Horizon.HorizonApi.OperationResponseType.changeTrust, ), ).toBeTruthy(); }); diff --git a/test/stellar.test.ts b/test/stellar.test.ts index 584acd7..79fa0a3 100644 --- a/test/stellar.test.ts +++ b/test/stellar.test.ts @@ -167,7 +167,7 @@ describe("Stellar", () => { let acc = await stellar.server.loadAccount(kp.publicKey); let balance = acc.balances.find( - (b) => (b as Horizon.BalanceLineAsset).asset_code === "USDC", + (b) => (b as Horizon.HorizonApi.BalanceLineAsset).asset_code === "USDC", ); expect(balance).toBeTruthy(); @@ -177,7 +177,7 @@ describe("Stellar", () => { acc = await stellar.server.loadAccount(kp.publicKey); balance = acc.balances.find( - (b) => (b as Horizon.BalanceLineAsset).asset_code === "USDC", + (b) => (b as Horizon.HorizonApi.BalanceLineAsset).asset_code === "USDC", ); expect(balance).toBeFalsy(); }, 20000); diff --git a/test/transaction.test.ts b/test/transaction.test.ts index c02b9ce..a858fcb 100644 --- a/test/transaction.test.ts +++ b/test/transaction.test.ts @@ -41,7 +41,7 @@ describe("Muxed Transactions", () => { const tswtAssetBalance = receivingAccountInfo.balances.find( (balanceLine) => { const { asset_code, balance } = - balanceLine as Horizon.BalanceLineAsset; + balanceLine as Horizon.HorizonApi.BalanceLineAsset; return asset_code === testingAsset.code && Number(balance) > 1000; }, ); diff --git a/yarn.lock b/yarn.lock index a1a6c83..4687f27 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1961,10 +1961,10 @@ axios@^1.4.0: form-data "^4.0.0" proxy-from-env "^1.1.0" -axios@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/axios/-/axios-1.5.0.tgz#f02e4af823e2e46a9768cfc74691fdd0517ea267" - integrity sha512-D4DdjDo5CY50Qms0qGQTTw6Q44jl7zRwY7bthds06pUGfChBCTcQs+N743eFWGEd6pRTMd6A+I87aWyFV5wiZQ== +axios@^1.6.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-1.6.2.tgz#de67d42c755b571d3e698df1b6504cde9b0ee9f2" + integrity sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A== dependencies: follow-redirects "^1.15.0" form-data "^4.0.0" @@ -5194,10 +5194,10 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -stellar-base@^10.0.0-beta.1: - version "10.0.0-soroban.8" - resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-10.0.0-soroban.8.tgz#8c5671f9d5a183aeb3077746db56e65b0b5c05da" - integrity sha512-mtj+4EcCnp4ZyH2FzRl62/DAstTXOddHVRZdzFQ94WgyQz2yVNzt+ANDS1D/7ku4d2mIzoJIj9l0/H0A5nRgXQ== +stellar-base@10.0.0-beta.4: + version "10.0.0-beta.4" + resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-10.0.0-beta.4.tgz#818d3b5dd702a7d18f1db47a72837cec80616716" + integrity sha512-3EXDFHSahVDMTHrHiFOO8kFf5KN+AL4x5kd5rxjElElPG+385cyWDbO83GrNmDGU/u9/XiVL+riJjz5gQTv6RQ== dependencies: base32.js "^0.1.0" bignumber.js "^9.1.2" @@ -5208,16 +5208,16 @@ stellar-base@^10.0.0-beta.1: optionalDependencies: sodium-native "^4.0.1" -stellar-sdk@^11.0.0-beta.3: - version "11.0.0-beta.3" - resolved "https://registry.yarnpkg.com/stellar-sdk/-/stellar-sdk-11.0.0-beta.3.tgz#fbdc115d3775adad338658613df2ed97468efa0a" - integrity sha512-obdiB4f9bK978twh2l7EA6K3p6i3+67Vf4Bp8vrGTqDG+1iTTDHftt98uBLFVaLjB2B9hq/wXk/Mqttl+hRGHQ== +stellar-sdk@^11.0.0-beta.6: + version "11.0.0-beta.6" + resolved "https://registry.yarnpkg.com/stellar-sdk/-/stellar-sdk-11.0.0-beta.6.tgz#3db48994fab841f09b31411290fc1ec9accdba38" + integrity sha512-bO1E+xSal+iUFKg9A/CoJylqkOayr58kS/qm6N/BLsKmOaYzWwGTVaRZC0cDI/ZY/bN6uDXGL/H7+W/qbgkmVA== dependencies: - axios "^1.5.0" + axios "^1.6.0" bignumber.js "^9.1.2" eventsource "^2.0.2" randombytes "^2.1.0" - stellar-base "^10.0.0-beta.1" + stellar-base "10.0.0-beta.4" toml "^3.0.0" urijs "^1.19.1"