Skip to content

Commit

Permalink
upgrade stellar-sdk to v11.0.0-beta.6
Browse files Browse the repository at this point in the history
  • Loading branch information
acharb committed Dec 4, 2023
1 parent 064cf2c commit ed04623
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 52 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/walletSdk/Anchor/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/walletSdk/Exceptions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
18 changes: 10 additions & 8 deletions src/walletSdk/Horizon/AccountService.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -17,7 +17,7 @@ import { OperationsLimitExceededError } from "../Exceptions";
* @class
*/
export class AccountService {
private server: Server;
private server: Horizon.Server;
private network: Networks;

/**
Expand Down Expand Up @@ -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<ServerApi.AccountRecord>} Account information.
* @param {Horizon.HorizonApi.Server} [params.serverInstance=this.server] - Horizon server instance when default doesn't work.
* @returns {Promise<Horizon.ServerApi.AccountRecord>} Account information.
*/
async getInfo({
accountAddress,
serverInstance = this.server,
}: {
accountAddress: string;
serverInstance?: Server;
}): Promise<ServerApi.AccountRecord> {
serverInstance?: Horizon.Server;
}): Promise<Horizon.ServerApi.AccountRecord> {
return serverInstance.accounts().accountId(accountAddress).call();
}

Expand All @@ -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<ServerApi.CollectionPage<ServerApi.OperationRecord>>} A list of operations.
* @returns {Promise<Horizon.ServerApi.CollectionPage<Horizon.ServerApi.OperationRecord>>} A list of operations.
* @throws {OperationsLimitExceededError} when maximum limit of 200 is exceeded.
*/
async getHistory({
Expand All @@ -89,7 +89,9 @@ export class AccountService {
order?: HORIZON_ORDER;
cursor?: string;
includeFailed?: boolean;
}): Promise<ServerApi.CollectionPage<ServerApi.OperationRecord>> {
}): Promise<
Horizon.ServerApi.CollectionPage<Horizon.ServerApi.OperationRecord>
> {
if (limit > HORIZON_LIMIT_MAX) {
throw new OperationsLimitExceededError(HORIZON_LIMIT_MAX);
}
Expand Down
8 changes: 4 additions & 4 deletions src/walletSdk/Horizon/Stellar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {
Account as StellarAccount,
Server,
Horizon,
Transaction,
TransactionBuilder as StellarTransactionBuilder,
FeeBumpTransaction,
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/walletSdk/Horizon/Transaction/TransactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import StellarSdk, {
TransactionBuilder as StellarTransactionBuilder,
Account as StellarAccount,
Transaction,
Server,
Horizon,
Memo,
xdr,
} from "stellar-sdk";
Expand Down Expand Up @@ -41,14 +41,14 @@ export class TransactionBuilder extends CommonTransactionBuilder<TransactionBuil
* @param {StellarAccount} sourceAccount - The source account for the transaction.
* @param {number} [baseFee] - The base fee for the transaction. If not given will use the config base fee.
* @param {Memo} [memo] - The memo for the transaction.
* @param {Server.Timebounds} [timebounds] - The timebounds for the transaction. If not given will use the config timebounds.
* @param {Horizon.Server.Timebounds} [timebounds] - The timebounds for the transaction. If not given will use the config timebounds.
*/
constructor(
cfg: Config,
sourceAccount: StellarAccount,
baseFee?: number,
memo?: Memo,
timebounds?: Server.Timebounds,
timebounds?: Horizon.Server.Timebounds,
) {
super(sourceAccount.accountId(), []);
this.builder = new StellarTransactionBuilder(sourceAccount, {
Expand Down
11 changes: 5 additions & 6 deletions src/walletSdk/Recovery/AccountRecover.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { AxiosInstance } from "axios";
import { ServerApi, Transaction } from "stellar-sdk";
import { AccountRecordSigners } from "stellar-sdk/lib/types/account";
import { Horizon, Transaction } from "stellar-sdk";

import {
RecoveryServer,
Expand Down Expand Up @@ -156,16 +155,16 @@ export abstract class AccountRecover {
* 2. All signers in [serverAuth] have the same weight, and the potential signer is
* the only one with a different weight.
* @private
* @param {ServerApi.AccountRecord} stellarAccount - The Stellar account to lookup existing signers on account.
* @param {Horizon.ServerApi.AccountRecord} stellarAccount - The Stellar account to lookup existing signers on account.
* @param {RecoveryServerSigningMap} serverAuth - A map of recovery servers to use.
* @returns {AccountRecordSigners} The deduced account signer.
* @returns {Horizon.ServerApi.AccountRecordSigners} The deduced account signer.
* @throws {NoDeviceKeyForAccountError} When no existing ("lost") device key is found.
* @throws {UnableToDeduceKeyError} When no criteria match.
*/
private deduceKey(
stellarAccount: ServerApi.AccountRecord,
stellarAccount: Horizon.ServerApi.AccountRecord,
serverAuth: RecoveryServerSigningMap,
): AccountRecordSigners {
): Horizon.ServerApi.AccountRecordSigners {
// Recovery servers addresses
const recoveryAddresses = Object.values(serverAuth).map(
({ signerAddress }) => signerAddress,
Expand Down
4 changes: 2 additions & 2 deletions src/walletSdk/Types/horizon.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions src/walletSdk/Utils/toml.ts
Original file line number Diff line number Diff line change
@@ -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"],
Expand Down
6 changes: 3 additions & 3 deletions src/walletSdk/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -125,7 +125,7 @@ export class Config {
}

export class StellarConfiguration {
server: Server;
server: Horizon.Server;
network: Networks;
horizonUrl: string;
baseFee: number;
Expand Down Expand Up @@ -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);
}
}

Expand Down
9 changes: 6 additions & 3 deletions test/accountService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down Expand Up @@ -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();
});
Expand Down
4 changes: 2 additions & 2 deletions test/stellar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion test/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},
);
Expand Down
28 changes: 14 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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==
[email protected].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"
Expand All @@ -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"

Expand Down

0 comments on commit ed04623

Please sign in to comment.