From 20134d9e89ea942497edd5d8e1448ca025e857be Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Fri, 4 Aug 2023 15:28:35 -0700 Subject: [PATCH 01/14] WIP: Just copy-pasting the files --- src/soroban/src/.eslintrc.js | 42 ++ src/soroban/src/axios.ts | 81 ++++ src/soroban/src/browser.ts | 9 + src/soroban/src/friendbot.ts | 6 + src/soroban/src/index.ts | 25 ++ src/soroban/src/jsonrpc.ts | 75 ++++ src/soroban/src/server.ts | 714 +++++++++++++++++++++++++++++++++ src/soroban/src/soroban_rpc.ts | 141 +++++++ src/soroban/src/transaction.ts | 120 ++++++ src/soroban/src/utils.ts | 8 + 10 files changed, 1221 insertions(+) create mode 100644 src/soroban/src/.eslintrc.js create mode 100644 src/soroban/src/axios.ts create mode 100644 src/soroban/src/browser.ts create mode 100644 src/soroban/src/friendbot.ts create mode 100644 src/soroban/src/index.ts create mode 100644 src/soroban/src/jsonrpc.ts create mode 100644 src/soroban/src/server.ts create mode 100644 src/soroban/src/soroban_rpc.ts create mode 100644 src/soroban/src/transaction.ts create mode 100644 src/soroban/src/utils.ts diff --git a/src/soroban/src/.eslintrc.js b/src/soroban/src/.eslintrc.js new file mode 100644 index 000000000..2dff00d7b --- /dev/null +++ b/src/soroban/src/.eslintrc.js @@ -0,0 +1,42 @@ +module.exports = { + env: { + es6: true, + }, + parser: "@babel/eslint-parser", + extends: ["airbnb-base", "prettier"], + plugins: ["prettier", "prefer-import"], + rules: { + // OFF + "import/prefer-default-export": 0, + "node/no-unsupported-features/es-syntax": 0, + "node/no-unsupported-features/es-builtins": 0, + camelcase: 0, + "class-methods-use-this": 0, + "linebreak-style": 0, + "new-cap": 0, + "no-param-reassign": 0, + "no-underscore-dangle": 0, + "no-use-before-define": 0, + "prefer-destructuring": 0, + "lines-between-class-members": 0, + + // WARN + "prefer-import/prefer-import-over-require": [1], + "no-console": ["warn", { allow: ["assert"] }], + "no-debugger": 1, + "no-unused-vars": 1, + "arrow-body-style": 1, + "valid-jsdoc": [ + 1, + { + requireReturnDescription: false, + }, + ], + "prefer-const": 1, + "object-shorthand": 1, + "require-await": 1, + + // ERROR + "no-unused-expressions": [2, { allowTaggedTemplates: true }], + }, +}; diff --git a/src/soroban/src/axios.ts b/src/soroban/src/axios.ts new file mode 100644 index 000000000..384015a4c --- /dev/null +++ b/src/soroban/src/axios.ts @@ -0,0 +1,81 @@ +import axios, { AxiosResponse } from "axios"; +import URI from "urijs"; + +/* tslint:disable-next-line:no-var-requires */ +const version = require("../package.json").version; + +export interface ServerTime { + serverTime: number; + localTimeRecorded: number; +} + +/** + * keep a local map of server times + * (export this purely for testing purposes) + * + * each entry will map the server domain to the last-known time and the local + * time it was recorded, ex: + * + * "localhost:8000": { + * serverTime: 1552513039, + * localTimeRecorded: 1552513052 + * } + */ +export const SERVER_TIME_MAP: Record = {}; + +const AxiosClient = axios.create({ + headers: { + "X-Client-Name": "js-soroban-client", + "X-Client-Version": version, + }, +}); + +function _toSeconds(ms: number): number { + return Math.floor(ms / 1000); +} + +AxiosClient.interceptors.response.use(function interceptorHorizonResponse( + response: AxiosResponse, +) { + const hostname = URI(response.config.url!).hostname(); + const serverTime = _toSeconds(Date.parse(response.headers.date)); + const localTimeRecorded = _toSeconds(new Date().getTime()); + + if (!isNaN(serverTime)) { + SERVER_TIME_MAP[hostname] = { + serverTime, + localTimeRecorded, + }; + } + + return response; +}); + +export default AxiosClient; + +/** + * Given a hostname, get the current time of that server (i.e., use the last- + * recorded server time and offset it by the time since then.) If there IS no + * recorded server time, or it's been 5 minutes since the last, return null. + * @param {string} hostname Hostname of a Soroban-RPC server. + * @returns {number} The UNIX timestamp (in seconds, not milliseconds) + * representing the current time on that server, or `null` if we don't have + * a record of that time. + */ +export function getCurrentServerTime(hostname: string): number | null { + const entry = SERVER_TIME_MAP[hostname]; + + if (!entry || !entry.localTimeRecorded || !entry.serverTime) { + return null; + } + + const { serverTime, localTimeRecorded } = entry; + const currentTime = _toSeconds(new Date().getTime()); + + // if it's been more than 5 minutes from the last time, then null it out + if (currentTime - localTimeRecorded > 60 * 5) { + return null; + } + + return currentTime - localTimeRecorded + serverTime; +} diff --git a/src/soroban/src/browser.ts b/src/soroban/src/browser.ts new file mode 100644 index 000000000..03027026b --- /dev/null +++ b/src/soroban/src/browser.ts @@ -0,0 +1,9 @@ +/* tslint:disable:no-var-requires */ + +export * from "./index"; +export * as StellarBase from "stellar-base"; + +import axios from "axios"; // idk why axios is weird +export { axios }; + +export default module.exports; diff --git a/src/soroban/src/friendbot.ts b/src/soroban/src/friendbot.ts new file mode 100644 index 000000000..fe346d69e --- /dev/null +++ b/src/soroban/src/friendbot.ts @@ -0,0 +1,6 @@ +export namespace Friendbot { + // Just the fields we are interested in + export interface Response { + result_meta_xdr: string; + } +} diff --git a/src/soroban/src/index.ts b/src/soroban/src/index.ts new file mode 100644 index 000000000..6d0f82f79 --- /dev/null +++ b/src/soroban/src/index.ts @@ -0,0 +1,25 @@ +// tslint:disable-next-line: no-reference +/// + +/* tslint:disable:no-var-requires */ +require("es6-promise").polyfill(); +const version = require("../package.json").version; + +// Expose all types +export * from "./soroban_rpc"; + +// stellar-sdk classes to expose +export { Server } from "./server"; +export { + default as AxiosClient, + SERVER_TIME_MAP, + getCurrentServerTime, +} from "./axios"; +export * from "./transaction"; + +// expose classes and functions from stellar-base +export * from "stellar-base"; + +export { version }; + +export default module.exports; diff --git a/src/soroban/src/jsonrpc.ts b/src/soroban/src/jsonrpc.ts new file mode 100644 index 000000000..a1e1ea3a2 --- /dev/null +++ b/src/soroban/src/jsonrpc.ts @@ -0,0 +1,75 @@ +import axios from "./axios"; +import { hasOwnProperty } from "./utils"; + +export type Id = string | number; + +export interface Request { + jsonrpc: "2.0"; + id: Id; + method: string; + params: T; +} + +export interface Notification { + jsonrpc: "2.0"; + method: string; + params?: T; +} + +export type Response = { + jsonrpc: "2.0"; + id: Id; +} & ({ error: Error } | { result: T }); + +export interface Error { + code: number; + message?: string; + data?: E; +} + +/** + * Sends the jsonrpc 'params' as an array. + */ +export async function post( + url: string, + method: string, + ...params: any +): Promise { + if (params && params.length < 1) { + params = null; + } + const response = await axios.post>(url, { + jsonrpc: "2.0", + // TODO: Generate a unique request id + id: 1, + method, + params, + }); + if (hasOwnProperty(response.data, "error")) { + throw response.data.error; + } else { + return response.data?.result; + } +} + +/** + * Sends the jsonrpc 'params' as the single 'param' obj, no array wrapper is applied. + */ +export async function postObject( + url: string, + method: string, + param: any, +): Promise { + const response = await axios.post>(url, { + jsonrpc: "2.0", + // TODO: Generate a unique request id + id: 1, + method, + params: param, + }); + if (hasOwnProperty(response.data, "error")) { + throw response.data.error; + } else { + return response.data?.result; + } +} diff --git a/src/soroban/src/server.ts b/src/soroban/src/server.ts new file mode 100644 index 000000000..518d029f4 --- /dev/null +++ b/src/soroban/src/server.ts @@ -0,0 +1,714 @@ +/* tslint:disable:variable-name no-namespace */ + +import isEmpty from "lodash/isEmpty"; +import merge from "lodash/merge"; +import { + Account, + Address, + Contract, + FeeBumpTransaction, + StrKey, + Transaction, + xdr, +} from "stellar-base"; +import URI from "urijs"; + +import AxiosClient from "./axios"; +import { Friendbot } from "./friendbot"; +import * as jsonrpc from "./jsonrpc"; +import { SorobanRpc } from "./soroban_rpc"; +import { assembleTransaction } from "./transaction"; + +export const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; + +export interface GetEventsRequest { + startLedger?: number; + filters: SorobanRpc.EventFilter[]; + cursor?: string; + limit?: number; +} + +/** + * Specifies the durability namespace of contract-related ledger entries. + */ +export enum Durability { + Temporary = 'temporary', + Persistent = 'persistent', +} + +/** + * Server handles the network connection to a + * [Soroban-RPC](https://soroban.stellar.org/docs) instance and exposes an + * interface for requests to that instance. + * + * @constructor + * + * @param {string} serverURL Soroban-RPC Server URL (ex. + * `http://localhost:8000/soroban/rpc`). + * @param {object} [opts] Options object + * @param {boolean} [opts.allowHttp] - Allow connecting to http servers, + * default: `false`. This must be set to false in production deployments! You + * can also use {@link Config} class to set this globally. + * @param {string} [opts.appName] - Allow set custom header `X-App-Name` + * @param {string} [opts.appVersion] - Allow set custom header `X-App-Version` + */ +export class Server { + /** + * Soroban-RPC Server URL (ex. `http://localhost:8000/soroban/rpc`). + */ + public readonly serverURL: URI; + + constructor(serverURL: string, opts: Server.Options = {}) { + this.serverURL = URI(serverURL); + + const customHeaders: any = {}; + + if (opts.appName) { + customHeaders["X-App-Name"] = opts.appName; + } + if (opts.appVersion) { + customHeaders["X-App-Version"] = opts.appVersion; + } + if (!isEmpty(customHeaders)) { + AxiosClient.interceptors.request.use((config: any) => { + // merge the custom headers with an existing headers + config.headers = merge(customHeaders, config.headers); + + return config; + }); + } + + if (this.serverURL.protocol() !== "https" && !opts.allowHttp) { + throw new Error("Cannot connect to insecure soroban-rpc server"); + } + } + + /** + * Fetch a minimal set of current info about a Stellar account. + * + * Needed to get the current sequence number for the account so you can build + * a successful transaction with {@link TransactionBuilder}. + * + * @example + * server.getAccount("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4").then(account => { + * console.log("sequence:", account.sequence); + * }); + * + * @param {string} address - The public address of the account to load. + * @returns {Promise} Returns a promise to the {@link Account} object with populated sequence number. + */ + public async getAccount(address: string): Promise { + const ledgerKey = xdr.LedgerKey.account( + new xdr.LedgerKeyAccount({ + accountId: xdr.PublicKey.publicKeyTypeEd25519( + StrKey.decodeEd25519PublicKey(address), + ), + }), + ).toXDR("base64"); + const data: SorobanRpc.GetLedgerEntriesResponse = await jsonrpc.post( + this.serverURL.toString(), + "getLedgerEntries", + [ledgerKey], + ); + const ledgerEntries = data.entries ?? []; + if (ledgerEntries.length === 0) { + return Promise.reject({ + code: 404, + message: `Account not found: ${address}`, + }); + } + const ledgerEntryData = ledgerEntries[0].xdr; + const accountEntry = xdr.LedgerEntryData.fromXDR( + ledgerEntryData, + "base64", + ).account(); + const { high, low } = accountEntry.seqNum(); + const sequence = BigInt(high) * BigInt(4294967296) + BigInt(low); + return new Account(address, sequence.toString()); + } + + /** + * General node health check. + * + * @example + * server.getHealth().then(health => { + * console.log("status:", health.status); + * }); + * + * @returns {Promise} Returns a promise to the {@link SorobanRpc.GetHealthResponse} object with the status of the server ("healthy"). + */ + public async getHealth(): Promise { + return await jsonrpc.post( + this.serverURL.toString(), + "getHealth", + ); + } + + /** + * Reads the current value of contract data ledger entries directly. + * + * @example + * const contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"; + * const key = xdr.ScVal.scvSymbol("counter"); + * server.getContractData(contractId, key, 'temporary').then(data => { + * console.log("value:", data.xdr); + * console.log("lastModified:", data.lastModifiedLedgerSeq); + * console.log("latestLedger:", data.latestLedger); + * }); + * + * Allows you to directly inspect the current state of a contract. This is a + * backup way to access your contract data which may not be available via + * events or simulateTransaction. + * + * @param {string|Address|Contract} contract - The contract ID containing the + * data to load. Encoded as Stellar Contract Address string (e.g. + * `CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5`), a + * {@link Contract}, or an {@link Address} instance. + * @param {xdr.ScVal} key - The key of the contract data to load. + * @param {Durability} [durability] - The "durability keyspace" that this + * ledger key belongs to, which is either 'temporary' or 'persistent' (the + * default), see {@link Durability}. + * + * @returns {Promise} Returns a promise to the + * {@link SorobanRpc.LedgerEntryResult} object with the current value. + * + * @warning If the data entry in question is a 'temporary' entry, it's + * entirely possible that it has expired out of existence. Future versions + * of this client may provide abstractions to handle that. + */ + public async getContractData( + contract: string | Address | Contract, + key: xdr.ScVal, + durability: Durability = Durability.Persistent, + ): Promise { + // coalesce `contract` param variants to an ScAddress + let scAddress: xdr.ScAddress; + if (typeof contract === 'string') { + scAddress = new Contract(contract).address().toScAddress(); + } else if (contract instanceof Address) { + scAddress = contract.toScAddress(); + } else if (contract instanceof Contract) { + scAddress = contract.address().toScAddress(); + } else { + throw new TypeError(`unknown contract type: ${contract}`); + } + + let xdrDurability: xdr.ContractDataDurability; + switch (durability) { + case Durability.Temporary: + xdrDurability = xdr.ContractDataDurability.temporary(); + break; + + case Durability.Persistent: + xdrDurability = xdr.ContractDataDurability.persistent(); + break; + + default: + throw new TypeError(`invalid durability: ${durability}`); + } + + let contractKey: string = xdr.LedgerKey.contractData( + new xdr.LedgerKeyContractData({ + contract: scAddress, + key, + durability: xdrDurability, + bodyType: xdr.ContractEntryBodyType.dataEntry() // expirationExtension is internal + }) + ).toXDR("base64"); + + return jsonrpc.post( + this.serverURL.toString(), + "getLedgerEntries", + [contractKey], + ).then(response => { + const ledgerEntries = response.entries ?? []; + if (ledgerEntries.length !== 1) { + return Promise.reject({ + code: 404, + message: `Contract data not found. Contract: ${Address.fromScAddress(scAddress).toString()}, Key: ${key.toXDR("base64")}, Durability: ${durability}`, + }); + } + return ledgerEntries[0]; + }); + } + + /** + * Reads the current value of ledger entries directly. + * + * Allows you to directly inspect the current state of contracts, contract's + * code, or any other ledger entries. This is a backup way to access your + * contract data which may not be available via events or simulateTransaction. + * + * To fetch contract wasm byte-code, use the ContractCode ledger entry key. + * + * @example + * const contractId = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"; + * const key = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({ + * contractId: StrKey.decodeContract(contractId), + * key: xdr.ScVal.scvSymbol("counter"), + * })); + * server.getLedgerEntries([key]).then(response => { + * const ledgerData = response.entries[0]; + * console.log("key:", ledgerData.key); + * console.log("value:", ledgerData.xdr); + * console.log("lastModified:", ledgerData.lastModifiedLedgerSeq); + * console.log("latestLedger:", response.latestLedger); + * }); + * + * @param {xdr.ScVal[]} keys - The ledger entry keys to load. + * + * @returns {Promise} Returns a promise + * to the {@link SorobanRpc.GetLedgerEntriesResponse} object with the + * current value. + */ + public async getLedgerEntries( + keys: xdr.LedgerKey[], + ): Promise { + return await jsonrpc.post( + this.serverURL.toString(), + "getLedgerEntries", + keys.map((k) => k.toXDR("base64")), + ); + } + + /** + * Fetch the details of a submitted transaction. + * + * When submitting a transaction, clients should poll this to tell when the + * transaction has completed. + * + * @example + * const transactionHash = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a"; + * server.getTransaction(transactionHash).then(transaction => { + * console.log("status:", transaction.status); + * console.log("envelopeXdr:", transaction.envelopeXdr); + * console.log("resultMetaXdr:", transaction.resultMetaXdr); + * console.log("resultXdr:", transaction.resultXdr); + * }); + * + * @param {string} hash - The hex-encoded hash of the transaction to check. + * + * @returns {Promise} Returns a + * promise to the {@link SorobanRpc.GetTransactionResponse} object + * with the status, result, and other details about the transaction. + */ + public async getTransaction( + hash: string, + ): Promise { + return await jsonrpc.post( + this.serverURL.toString(), + "getTransaction", + hash, + ); + } + + /** + * Fetches all events that match a given set of filters. + * + * The given filters (see {@link SorobanRpc.EventFilter} for detailed fields) + * are combined only in a logical OR fashion, and all of the fields in each + * filter are optional. + * + * To page through events, use the `pagingToken` field on the relevant + * {@link SorobanRpc.EventResponse} object to set the `cursor` parameter. + * + * @example + * server.getEvents({ + * startLedger: "1000", + * filters: [ + * { + * type: "contract", + * contractIds: [ "deadb33f..." ], + * topics: [[ "AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc=", "*" ]] + * }, { + * type: "system", + * contractIds: [ "...c4f3b4b3..." ], + * topics: [[ "*" ], [ "*", "AAAAAQB6Mcc=" ]] + * }, { + * contractIds: [ "...c4f3b4b3..." ], + * topics: [[ "AAAABQAAAAh0cmFuc2Zlcg==" ]] + * }, { + * type: "diagnostic", + * topics: [[ "AAAAAQB6Mcc=" ]] + * } + * ], + * limit: 10, + * }); + * + * @returns {Promise} a promise to the + * {@link SorobanRpc.GetEventsResponse} object containing a paginatable set + * of the events matching the given event filters. + */ + public async getEvents( + request: GetEventsRequest, + ): Promise { + // TODO: It'd be nice if we could do something to infer the types of filter + // arguments a user wants, e.g. converting something like "transfer/*/42" + // into the base64-encoded `ScVal` equivalents by inferring that the first + // is an ScSymbol and the last is a U32. + // + // The difficulty comes in matching up the correct integer primitives. + // + // It also means this library will rely on the XDR definitions. + return await jsonrpc.postObject(this.serverURL.toString(), "getEvents", { + filters: request.filters ?? [], + pagination: { + ...(request.cursor && { cursor: request.cursor }), // add fields only if defined + ...(request.limit && { limit: request.limit }), + }, + ...(request.startLedger && { startLedger: String(request.startLedger) }), + }); + } + + /** + * Fetches metadata about the network which Soroban-RPC is connected to. + * + * @example + * server.getNetwork().then(network => { + * console.log("friendbotUrl:", network.friendbotUrl); + * console.log("passphrase:", network.passphrase); + * console.log("protocolVersion:", network.protocolVersion); + * }); + * + * @returns {Promise} a promise to the + * {@link SorobanRpc.GetNetworkResponse} object containing metadata + * about the current network this soroban-rpc server is connected to. + */ + public async getNetwork(): Promise { + return await jsonrpc.post(this.serverURL.toString(), "getNetwork"); + } + + /** + * Fetches the latest ledger meta info from network which Soroban-RPC is connected to. + * + * @example + * server.getLatestLedger().then(response => { + * console.log("hash:", response.id); + * console.log("sequence:", response.sequence); + * console.log("protocolVersion:", response.protocolVersion); + * }); + * + * @returns {Promise} a promise to the + * {@link SorobanRpc.GetLatestLedgerResponse} object containing metadata + * about the latest ledger from network soroban-rpc server is connected to. + */ + public async getLatestLedger(): Promise { + return await jsonrpc.post(this.serverURL.toString(), "getLatestLedger"); + } + + /** + * Submit a trial contract invocation to get back return values, expected + * ledger footprint, expected authorizations, and expected costs. + * + * @example + * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; + * const contract = new SorobanClient.Contract(contractId); + * + * // Right now, this is just the default fee for this example. + * const fee = 100; + * + * const transaction = new SorobanClient.TransactionBuilder(account, { + * fee, + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * // networkPassphrase: SorobanClient.Networks.PUBLIC, + * networkPassphrase: SorobanClient.Networks.FUTURENET + * }) + * // Add a contract.increment soroban contract invocation operation + * .addOperation(contract.call("increment")) + * // Make this transaction valid for the next 30 seconds only + * .setTimeout(30) + * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) + * // .addMemo(SorobanClient.Memo.text('Hello world!')) + * .build(); + * + * // Sign this transaction with the secret key + * // NOTE: signing is transaction is network specific. Test network transactions + * // won't work in the public network. To switch networks, use the Network object + * // as explained above (look for SorobanClient.Network). + * const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); + * transaction.sign(sourceKeypair); + * + * server.simulateTransaction(transaction).then(sim => { + * console.log("cost:", sim.cost); + * console.log("results:", sim.results); + * console.log("error:", sim.error); + * console.log("latestLedger:", sim.latestLedger); + * }); + * + * @param {Transaction | FeeBumpTransaction} transaction - The transaction to + * simulate. It should include exactly one operation, which must be one of + * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, + * or {@link xdr.RestoreFootprintOp}. Any provided footprint will be + * ignored. + * + * @returns {Promise} Returns a + * promise to the {@link SorobanRpc.SimulateTransactionResponse} object + * with the cost, footprint, result/auth requirements (if applicable), and + * error of the transaction. + */ + public async simulateTransaction( + transaction: Transaction | FeeBumpTransaction, + ): Promise { + return await jsonrpc.post( + this.serverURL.toString(), + "simulateTransaction", + transaction.toXDR(), + ); + } + + /** + * Submit a trial contract invocation, first run a simulation of the contract + * invocation as defined on the incoming transaction, and apply the results to + * a new copy of the transaction which is then returned. Setting the ledger + * footprint and authorization, so the resulting transaction is ready for + * signing & sending. + * + * The returned transaction will also have an updated fee that is the sum of + * fee set on incoming transaction with the contract resource fees estimated + * from simulation. It is adviseable to check the fee on returned transaction + * and validate or take appropriate measures for interaction with user to + * confirm it is acceptable. + * + * You can call the {@link Server.simulateTransaction} method directly first + * if you want to inspect estimated fees for a given transaction in detail + * first, if that is of importance. + * + * @example + * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; + * const contract = new SorobanClient.Contract(contractId); + * + * // Right now, this is just the default fee for this example. + * const fee = 100; + * + * const transaction = new SorobanClient.TransactionBuilder(account, { + * fee, + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * // networkPassphrase: SorobanClient.Networks.PUBLIC, + * networkPassphrase: SorobanClient.Networks.TESTNET + * }) + * // Add a contract.increment soroban contract invocation operation + * .addOperation(contract.call("increment")) + * // Make this transaction valid for the next 30 seconds only + * .setTimeout(30) + * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) + * // .addMemo(SorobanClient.Memo.text('Hello world!')) + * .build(); + * + * preparedTransaction = await server.prepareTransaction(transaction); + * + * // Sign this transaction with the secret key + * // NOTE: signing is transaction is network specific. Test network transactions + * // won't work in the public network. To switch networks, use the Network object + * // as explained above (look for SorobanClient.Network). + * const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); + * preparedTransaction.sign(sourceKeypair); + * + * server.sendTransaction(transaction).then(result => { + * console.log("hash:", result.hash); + * console.log("status:", result.status); + * console.log("errorResultXdr:", result.errorResultXdr); + * }); + * + * @param {Transaction | FeeBumpTransaction} transaction - The transaction to + * prepare. It should include exactly one operation, which must be one of + * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, + * or {@link xdr.RestoreFootprintOp}. + * + * Any provided footprint will be overwritten. However, if your operation + * has existing auth entries, they will be preferred over ALL auth entries + * from the simulation. In other words, if you include auth entries, you + * don't care about the auth returned from the simulation. Other fields + * (footprint, etc.) will be filled as normal. + * @param {string} [networkPassphrase] - Explicitly provide a network + * passphrase. If not passed, the current network passphrase will be + * requested from the server via {@link Server.getNetwork}. + * + * @returns {Promise} Returns a copy of the + * transaction, with the expected authorizations (in the case of + * invocation) and ledger footprint added. The transaction fee will also + * automatically be padded with the contract's minimum resource fees + * discovered from the simulation. + * + * @throws {jsonrpc.Error | Error} if simulation fails + */ + public async prepareTransaction( + transaction: Transaction | FeeBumpTransaction, + networkPassphrase?: string, + ): Promise { + const [{ passphrase }, simResponse] = await Promise.all([ + networkPassphrase + ? Promise.resolve({ passphrase: networkPassphrase }) + : this.getNetwork(), + this.simulateTransaction(transaction), + ]); + if (simResponse.error) { + throw simResponse.error; + } + if (!simResponse.results || simResponse.results.length !== 1) { + throw new Error("transaction simulation failed"); + } + return assembleTransaction(transaction, passphrase, simResponse); + } + + /** + * Submit a real transaction to the Stellar network. This is the only way to + * make changes "on-chain". Unlike Horizon, Soroban-RPC does not wait for + * transaction completion. It simply validates the transaction and enqueues + * it. Clients should call {@link Server#getTransactionStatus} to learn about + * transaction success/failure. + * + * @example + * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; + * const contract = new SorobanClient.Contract(contractId); + * + * // Right now, this is just the default fee for this example. + * const fee = 100; + * + * const transaction = new SorobanClient.TransactionBuilder(account, { + * fee, + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * // networkPassphrase: SorobanClient.Networks.PUBLIC, + * networkPassphrase: SorobanClient.Networks.STANDALONE + * }) + * // Add a contract.increment soroban contract invocation operation + * // Note: For real transactions you will need to include the footprint + * // and auth in the operation, as returned from simulateTransaction. + * .addOperation(contract.call("increment")) + * // Make this transaction valid for the next 30 seconds only + * .setTimeout(30) + * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) + * // .addMemo(SorobanClient.Memo.text('Hello world!')) + * .build(); + * + * // Sign this transaction with the secret key + * // NOTE: signing is transaction is network specific. Test network transactions + * // won't work in the public network. To switch networks, use the Network object + * // as explained above (look for SorobanClient.Network). + * const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); + * transaction.sign(sourceKeypair); + * + * server.sendTransaction(transaction).then(result => { + * console.log("hash:", result.hash); + * console.log("status:", result.status); + * console.log("errorResultXdr:", result.errorResultXdr); + * }); + * + * @param {Transaction | FeeBumpTransaction} transaction - The transaction to + * submit. + * @returns {Promise} Returns a promise to + * the {@link SorobanRpc.SendTransactionResponse} object with the + * transaction id, status, and any error if available. + */ + public async sendTransaction( + transaction: Transaction | FeeBumpTransaction, + ): Promise { + return await jsonrpc.post( + this.serverURL.toString(), + "sendTransaction", + transaction.toXDR(), + ); + } + + /** + * Use the friendbot faucet to create and fund a new account. The method will + * return an Account object for the created account, or if the account already + * existed. If friendbot is not configured on this network, this method will + * throw an error. If the request fails, this method will throw an error. + * + * @example + * server + * .requestAirdrop("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4") + * .then(accountCreated => { + * console.log("accountCreated:", accountCreated); + * }).catch(error => { + * console.error("error:", error); + * }); + * + * @param {string | Account} address - The address or account we want to + * create and fund. + * @param {string} [friendbotUrl] - The optional explicit address for + * friendbot. If not provided, the client will call the Soroban-RPC + * `getNetwork` method to attempt to find this network's friendbot url. + * + * @returns {Promise} Returns a promise to the {@link Account} object + * with populated sequence number. + */ + public async requestAirdrop( + address: string | Pick, + friendbotUrl?: string, + ): Promise { + const account = typeof address === "string" ? address : address.accountId(); + friendbotUrl = friendbotUrl || (await this.getNetwork()).friendbotUrl; + if (!friendbotUrl) { + throw new Error("No friendbot URL configured for current network"); + } + try { + const response = await AxiosClient.post( + `${friendbotUrl}?addr=${encodeURIComponent(account)}`, + ); + const meta = xdr.TransactionMeta.fromXDR( + response.data.result_meta_xdr, + "base64", + ); + const sequence = findCreatedAccountSequenceInTransactionMeta(meta); + return new Account(account, sequence); + } catch (error: any) { + if (error.response?.status === 400) { + if (error.response.detail?.includes("createAccountAlreadyExist")) { + // Account already exists, load the sequence number + return this.getAccount(account); + } + } + throw error; + } + } +} + +function findCreatedAccountSequenceInTransactionMeta( + meta: xdr.TransactionMeta, +): string { + let operations: xdr.OperationMeta[] = []; + switch (meta.switch()) { + case 0: + operations = meta.operations(); + break; + case 1: + operations = meta.v1().operations(); + break; + case 2: + operations = meta.v2().operations(); + break; + case 3: + operations = meta.v3().operations(); + break; + default: + throw new Error("Unexpected transaction meta switch value"); + } + + for (const op of operations) { + for (const c of op.changes()) { + if (c.switch() !== xdr.LedgerEntryChangeType.ledgerEntryCreated()) { + continue; + } + const data = c.created().data(); + if (data.switch() !== xdr.LedgerEntryType.account()) { + continue; + } + + return data.account().seqNum().toString(); + } + } + throw new Error("No account created in transaction"); +} + +export namespace Server { + export interface Options { + allowHttp?: boolean; + timeout?: number; + appName?: string; + appVersion?: string; + } +} diff --git a/src/soroban/src/soroban_rpc.ts b/src/soroban/src/soroban_rpc.ts new file mode 100644 index 000000000..446faa23e --- /dev/null +++ b/src/soroban/src/soroban_rpc.ts @@ -0,0 +1,141 @@ +import { AssetType } from "stellar-base"; +import * as jsonrpc from "./jsonrpc"; + +// TODO: Better parsing for hashes, and base64-encoded xdr + +/* tslint:disable-next-line:no-namespace */ +/* @namespace SorobanRpc + */ +export namespace SorobanRpc { + export interface Balance { + asset_type: AssetType.credit4 | AssetType.credit12; + asset_code: string; + asset_issuer: string; + classic: string; + smart: string; + } + + export interface Cost { + cpuInsns: string; + memBytes: string; + } + + export interface GetHealthResponse { + status: "healthy"; + } + + export interface LedgerEntryResult { + key: string; + // xdr is a base-64 encoded {@link xdr.LedgerEntryData} + xdr: string; + lastModifiedLedgerSeq?: number; + } + + /* Response for jsonrpc method `getLedgerEntries` + */ + export interface GetLedgerEntriesResponse { + entries: LedgerEntryResult[] | null; + latestLedger: number; + } + + /* Response for jsonrpc method `getNetwork` + */ + export interface GetNetworkResponse { + friendbotUrl?: string; + passphrase: string; + protocolVersion: string; + } + + /* Response for jsonrpc method `getLatestLedger` + */ + export interface GetLatestLedgerResponse { + id: string; + sequence: number; + protocolVersion: string; + } + + export type GetTransactionStatus = "SUCCESS" | "NOT_FOUND" | "FAILED"; + + export interface GetTransactionResponse { + status: GetTransactionStatus; + latestLedger: number; + latestLedgerCloseTime: number; + oldestLedger: number; + oldestLedgerCloseTime: number; + + // the fields below are set if status is SUCCESS + applicationOrder?: number; + feeBump?: boolean; + envelopeXdr?: string; + resultXdr?: string; + resultMetaXdr?: string; + ledger?: number; + createdAt?: number; + } + + export type EventType = "contract" | "system" | "diagnostic"; + + export interface EventFilter { + type?: EventType; + contractIds?: string[]; + topics?: string[][]; + } + + export interface GetEventsResponse { + events?: EventResponse[]; + } + + export interface EventResponse { + type: EventType; + ledger: string; + ledgerClosedAt: string; + contractId: string; + id: string; + pagingToken: string; + inSuccessfulContractCall: boolean; + topic: string[]; + value: { + xdr: string; + }; + } + + export interface RequestAirdropResponse { + transaction_id: string; + } + + export type SendTransactionStatus = + | "PENDING" + | "DUPLICATE" + | "TRY_AGAIN_LATER" + | "ERROR"; + + export interface SendTransactionResponse { + status: SendTransactionStatus; + // errorResultXdr is only set when status is ERROR + errorResultXdr?: string; + hash: string; + latestLedger: number; + latestLedgerCloseTime: number; + } + + export interface SimulateHostFunctionResult { + // each string is SorobanAuthorizationEntry XDR in base64 + auth?: string[]; + // function response as SCVal XDR in base64 + xdr: string; + } + + export interface SimulateTransactionResponse { + id: string; + error?: jsonrpc.Error; + // this is SorobanTransactionData XDR in base64 + transactionData: string; + events: string[]; + minResourceFee: string; + // This will only contain a single element, because only a single + // invokeHostFunctionOperation is supported per transaction. + results: SimulateHostFunctionResult[]; + latestLedger: number; + cost: Cost; + } +} diff --git a/src/soroban/src/transaction.ts b/src/soroban/src/transaction.ts new file mode 100644 index 000000000..48b83ff38 --- /dev/null +++ b/src/soroban/src/transaction.ts @@ -0,0 +1,120 @@ +import { + Account, + FeeBumpTransaction, + Operation, + Transaction, + TransactionBuilder, + xdr, +} from "stellar-base"; + +import { SorobanRpc } from "./soroban_rpc"; + +// TODO: Transaction is immutable, so we need to re-build it here. :( +export function assembleTransaction( + raw: Transaction | FeeBumpTransaction, + networkPassphrase: string, + simulation: SorobanRpc.SimulateTransactionResponse +): Transaction { + if ("innerTransaction" in raw) { + // TODO: Handle feebump transactions + return assembleTransaction( + raw.innerTransaction, + networkPassphrase, + simulation + ); + } + + if (!isSorobanTransaction(raw)) { + throw new TypeError( + "unsupported transaction: must contain exactly one " + + "invokeHostFunction, bumpFootprintExpiration, or restoreFootprint " + + "operation" + ); + } + + if (simulation.results.length !== 1) { + throw new Error(`simulation results invalid: ${simulation.results}`); + } + + const source = new Account(raw.source, `${parseInt(raw.sequence, 10) - 1}`); + const classicFeeNum = parseInt(raw.fee, 10) || 0; + const minResourceFeeNum = parseInt(simulation.minResourceFee, 10) || 0; + const txnBuilder = new TransactionBuilder(source, { + // automatically update the tx fee that will be set on the resulting tx to + // the sum of 'classic' fee provided from incoming tx.fee and minResourceFee + // provided by simulation. + // + // 'classic' tx fees are measured as the product of tx.fee * 'number of + // operations', In soroban contract tx, there can only be single operation + // in the tx, so can make simplification of total classic fees for the + // soroban transaction will be equal to incoming tx.fee + minResourceFee. + fee: (classicFeeNum + minResourceFeeNum).toString(), + memo: raw.memo, + networkPassphrase, + timebounds: raw.timeBounds, + ledgerbounds: raw.ledgerBounds, + minAccountSequence: raw.minAccountSequence, + minAccountSequenceAge: raw.minAccountSequenceAge, + minAccountSequenceLedgerGap: raw.minAccountSequenceLedgerGap, + extraSigners: raw.extraSigners, + }); + + switch (raw.operations[0].type) { + case "invokeHostFunction": + const invokeOp: Operation.InvokeHostFunction = raw.operations[0]; + const existingAuth = invokeOp.auth ?? []; + txnBuilder.addOperation( + Operation.invokeHostFunction({ + source: invokeOp.source, + func: invokeOp.func, + // if auth entries are already present, we consider this "advanced + // usage" and disregard ALL auth entries from the simulation + // + // the intuition is "if auth exists, this tx has probably been + // simulated before" + auth: + existingAuth.length > 0 + ? existingAuth + : simulation.results[0].auth?.map((a) => + xdr.SorobanAuthorizationEntry.fromXDR(a, "base64") + ) ?? [], + }) + ); + break; + + case "bumpFootprintExpiration": + txnBuilder.addOperation( + Operation.bumpFootprintExpiration(raw.operations[0]) + ); + break; + + case "restoreFootprint": + txnBuilder.addOperation(Operation.restoreFootprint(raw.operations[0])); + break; + } + + // apply the pre-built Soroban Tx Data from simulation onto the Tx + const sorobanTxData = xdr.SorobanTransactionData.fromXDR( + simulation.transactionData, + "base64" + ); + txnBuilder.setSorobanData(sorobanTxData); + + return txnBuilder.build(); +} + +function isSorobanTransaction(tx: Transaction): boolean { + if (tx.operations.length !== 1) { + return false; + } + + switch (tx.operations[0].type) { + case "invokeHostFunction": + case "bumpFootprintExpiration": + case "restoreFootprint": + return true; + + default: + return false; + } +} diff --git a/src/soroban/src/utils.ts b/src/soroban/src/utils.ts new file mode 100644 index 000000000..af4bb76a2 --- /dev/null +++ b/src/soroban/src/utils.ts @@ -0,0 +1,8 @@ +// Check if the given object X has a field Y, and make that available to +// typescript typing. +export function hasOwnProperty( + obj: X, + prop: Y, +): obj is X & Record { + return obj.hasOwnProperty(prop); +} From b810d8cb6a3bd26d8a5d26df10d2f22b793fdd12 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Fri, 4 Aug 2023 15:49:14 -0700 Subject: [PATCH 02/14] Okay, everything at least builds --- package.json | 49 +- src/index.ts | 2 + src/soroban/{src => }/axios.ts | 2 +- src/soroban/{src => }/browser.ts | 0 src/soroban/{src => }/friendbot.ts | 0 src/soroban/index.ts | 18 + src/soroban/{src => }/jsonrpc.ts | 0 src/soroban/{src => }/server.ts | 9 +- src/soroban/{src => }/soroban_rpc.ts | 0 src/soroban/src/.eslintrc.js | 42 -- src/soroban/src/index.ts | 25 - src/soroban/{src => }/transaction.ts | 0 src/soroban/{src => }/utils.ts | 0 test/integration/apiary.js | 2 +- test/unit/call_builders_test.js | 2 +- test/unit/federation_server_test.js | 86 +-- test/unit/horizon_path_test.js | 14 +- test/unit/liquidity_pool_endpoints_test.js | 26 +- test/unit/server/claimable_balances.js | 24 +- test/unit/server/join_test.js | 6 +- test/unit/server_check_memo_required_test.js | 16 +- test/unit/server_test.js | 402 ++++++------ test/unit/server_transaction_test.js | 40 +- test/unit/stellar_toml_resolver_test.js | 18 +- test/unit/utils_test.js | 644 +++++++++--------- yarn.lock | 656 ++++++++++++++++--- 26 files changed, 1252 insertions(+), 831 deletions(-) rename src/soroban/{src => }/axios.ts (97%) rename src/soroban/{src => }/browser.ts (100%) rename src/soroban/{src => }/friendbot.ts (100%) create mode 100644 src/soroban/index.ts rename src/soroban/{src => }/jsonrpc.ts (100%) rename src/soroban/{src => }/server.ts (99%) rename src/soroban/{src => }/soroban_rpc.ts (100%) delete mode 100644 src/soroban/src/.eslintrc.js delete mode 100644 src/soroban/src/index.ts rename src/soroban/{src => }/transaction.ts (100%) rename src/soroban/{src => }/utils.ts (100%) diff --git a/package.json b/package.json index 079aa9e6c..4330a8c7a 100644 --- a/package.json +++ b/package.json @@ -76,43 +76,42 @@ ] }, "devDependencies": { - "@babel/cli": "^7.22.6", - "@babel/core": "^7.22.8", - "@babel/eslint-parser": "^7.22.7", - "@babel/eslint-plugin": "^7.19.1", - "@babel/preset-env": "^7.22.7", - "@babel/preset-typescript": "^7.21.4", - "@babel/register": "^7.21.0", - "@definitelytyped/dtslint": "^0.0.163", + "@babel/cli": "^7.22.9", + "@babel/core": "^7.22.9", + "@babel/eslint-parser": "^7.22.9", + "@babel/eslint-plugin": "^7.22.5", + "@babel/preset-env": "^7.22.9", + "@babel/preset-typescript": "^7.22.5", + "@babel/register": "^7.22.5", + "@definitelytyped/dtslint": "^0.0.165", "@istanbuljs/nyc-config-babel": "3.0.0", "@stellar/tsconfig": "^1.0.2", "@types/detect-node": "^2.0.0", "@types/eventsource": "^1.1.2", - "@types/lodash": "^4.14.192", - "@types/node": "^20.4.1", + "@types/lodash": "^4.14.196", + "@types/node": "^20.4.2", "@types/randombytes": "^2.0.0", "@types/urijs": "^1.19.6", - "@typescript-eslint/parser": "^5.59.7", + "@typescript-eslint/parser": "^6.2.1", "axios-mock-adapter": "^1.21.5", - "babel-loader": "^9.1.3", + "babel-loader": "^9.1.2", "babel-plugin-istanbul": "^6.1.1", - "buffer": "^6.0.3", "chai": "^4.3.7", "chai-as-promised": "^7.1.1", - "chai-http": "^4.3.0", + "chai-http": "^4.4.0", "cross-env": "^7.0.3", - "eslint": "^8.44.0", + "eslint": "^8.45.0", "eslint-config-airbnb-base": "^15.0.0", - "eslint-config-prettier": "^8.8.0", - "eslint-plugin-import": "^2.25.2", + "eslint-config-prettier": "^8.10.0", + "eslint-plugin-import": "^2.28.0", "eslint-plugin-node": "^11.1.0", "eslint-plugin-prefer-import": "^0.0.1", - "eslint-plugin-prettier": "^4.2.1", + "eslint-plugin-prettier": "^5.0.0", "eslint-webpack-plugin": "^4.0.1", "ghooks": "^2.0.4", "husky": "^8.0.3", "jsdoc": "^4.0.2", - "karma": "^6.4.1", + "karma": "^6.4.2", "karma-chai": "^0.1.0", "karma-chrome-launcher": "^3.1.0", "karma-coverage": "^2.2.1", @@ -126,24 +125,26 @@ "mocha": "^10.2.0", "node-polyfill-webpack-plugin": "^2.0.1", "nyc": "^15.1.0", - "prettier": "^2.8.7", + "prettier": "^3.0.1", "randombytes": "^2.1.0", "sinon": "^15.2.0", "sinon-chai": "^3.7.0", "taffydb": "^2.7.3", - "terser-webpack-plugin": "^5.3.9", + "terser-webpack-plugin": "^5.3.8", "ts-node": "^10.9.1", "typescript": "^5.1.6", "utility-types": "^3.7.0", - "webpack": "^5.88.1", - "webpack-cli": "^5.0.1" + "webpack": "^5.88.2", + "webpack-cli": "^5.1.4" }, "dependencies": { "axios": "^1.4.0", "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", "eventsource": "^2.0.2", "randombytes": "^2.1.0", - "stellar-base": "^9.0.0", + "stellar-base": "10.0.0-soroban.5", "toml": "^3.0.0", "urijs": "^1.19.1" } diff --git a/src/index.ts b/src/index.ts index 49b9c30c5..633eb644a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,6 +31,8 @@ export * from "./utils"; // expose classes and functions from stellar-base export * from "stellar-base"; +export * from './soroban'; + export { version }; export default module.exports; diff --git a/src/soroban/src/axios.ts b/src/soroban/axios.ts similarity index 97% rename from src/soroban/src/axios.ts rename to src/soroban/axios.ts index 384015a4c..6d4eaed31 100644 --- a/src/soroban/src/axios.ts +++ b/src/soroban/axios.ts @@ -2,7 +2,7 @@ import axios, { AxiosResponse } from "axios"; import URI from "urijs"; /* tslint:disable-next-line:no-var-requires */ -const version = require("../package.json").version; +export const version = require("../../package.json").version; export interface ServerTime { serverTime: number; diff --git a/src/soroban/src/browser.ts b/src/soroban/browser.ts similarity index 100% rename from src/soroban/src/browser.ts rename to src/soroban/browser.ts diff --git a/src/soroban/src/friendbot.ts b/src/soroban/friendbot.ts similarity index 100% rename from src/soroban/src/friendbot.ts rename to src/soroban/friendbot.ts diff --git a/src/soroban/index.ts b/src/soroban/index.ts new file mode 100644 index 000000000..9435f158f --- /dev/null +++ b/src/soroban/index.ts @@ -0,0 +1,18 @@ +// tslint:disable-next-line: no-reference +/// + +export { version } from './axios'; + +// Expose all types and helpers +export * from "./soroban_rpc"; +export * from "./transaction"; + +// http classes to expose +export { Server } from "./server"; +export { + default as AxiosClient, + SERVER_TIME_MAP, + getCurrentServerTime, +} from "./axios"; + +export default module.exports; diff --git a/src/soroban/src/jsonrpc.ts b/src/soroban/jsonrpc.ts similarity index 100% rename from src/soroban/src/jsonrpc.ts rename to src/soroban/jsonrpc.ts diff --git a/src/soroban/src/server.ts b/src/soroban/server.ts similarity index 99% rename from src/soroban/src/server.ts rename to src/soroban/server.ts index 518d029f4..b33f74ee4 100644 --- a/src/soroban/src/server.ts +++ b/src/soroban/server.ts @@ -1,7 +1,5 @@ /* tslint:disable:variable-name no-namespace */ -import isEmpty from "lodash/isEmpty"; -import merge from "lodash/merge"; import { Account, Address, @@ -69,11 +67,10 @@ export class Server { if (opts.appVersion) { customHeaders["X-App-Version"] = opts.appVersion; } - if (!isEmpty(customHeaders)) { + if ((Object.keys(customHeaders).length ?? 0) !== 0) { AxiosClient.interceptors.request.use((config: any) => { - // merge the custom headers with an existing headers - config.headers = merge(customHeaders, config.headers); - + // merge the custom headers with any existing headers + config.headers = Object.assign(config.headers, customHeaders); return config; }); } diff --git a/src/soroban/src/soroban_rpc.ts b/src/soroban/soroban_rpc.ts similarity index 100% rename from src/soroban/src/soroban_rpc.ts rename to src/soroban/soroban_rpc.ts diff --git a/src/soroban/src/.eslintrc.js b/src/soroban/src/.eslintrc.js deleted file mode 100644 index 2dff00d7b..000000000 --- a/src/soroban/src/.eslintrc.js +++ /dev/null @@ -1,42 +0,0 @@ -module.exports = { - env: { - es6: true, - }, - parser: "@babel/eslint-parser", - extends: ["airbnb-base", "prettier"], - plugins: ["prettier", "prefer-import"], - rules: { - // OFF - "import/prefer-default-export": 0, - "node/no-unsupported-features/es-syntax": 0, - "node/no-unsupported-features/es-builtins": 0, - camelcase: 0, - "class-methods-use-this": 0, - "linebreak-style": 0, - "new-cap": 0, - "no-param-reassign": 0, - "no-underscore-dangle": 0, - "no-use-before-define": 0, - "prefer-destructuring": 0, - "lines-between-class-members": 0, - - // WARN - "prefer-import/prefer-import-over-require": [1], - "no-console": ["warn", { allow: ["assert"] }], - "no-debugger": 1, - "no-unused-vars": 1, - "arrow-body-style": 1, - "valid-jsdoc": [ - 1, - { - requireReturnDescription: false, - }, - ], - "prefer-const": 1, - "object-shorthand": 1, - "require-await": 1, - - // ERROR - "no-unused-expressions": [2, { allowTaggedTemplates: true }], - }, -}; diff --git a/src/soroban/src/index.ts b/src/soroban/src/index.ts deleted file mode 100644 index 6d0f82f79..000000000 --- a/src/soroban/src/index.ts +++ /dev/null @@ -1,25 +0,0 @@ -// tslint:disable-next-line: no-reference -/// - -/* tslint:disable:no-var-requires */ -require("es6-promise").polyfill(); -const version = require("../package.json").version; - -// Expose all types -export * from "./soroban_rpc"; - -// stellar-sdk classes to expose -export { Server } from "./server"; -export { - default as AxiosClient, - SERVER_TIME_MAP, - getCurrentServerTime, -} from "./axios"; -export * from "./transaction"; - -// expose classes and functions from stellar-base -export * from "stellar-base"; - -export { version }; - -export default module.exports; diff --git a/src/soroban/src/transaction.ts b/src/soroban/transaction.ts similarity index 100% rename from src/soroban/src/transaction.ts rename to src/soroban/transaction.ts diff --git a/src/soroban/src/utils.ts b/src/soroban/utils.ts similarity index 100% rename from src/soroban/src/utils.ts rename to src/soroban/utils.ts diff --git a/test/integration/apiary.js b/test/integration/apiary.js index 7050bb4ee..7c95d40fc 100644 --- a/test/integration/apiary.js +++ b/test/integration/apiary.js @@ -157,7 +157,7 @@ describe("tests the /accounts endpoint", function () { .then((resp) => { // find the pool share balance(s) const poolShares = resp.balances.filter( - (b) => b.asset_type === "liquidity_pool_shares" + (b) => b.asset_type === "liquidity_pool_shares", ); expect(poolShares).to.have.lengthOf(1); diff --git a/test/unit/call_builders_test.js b/test/unit/call_builders_test.js index 28a8f882f..80541b7ec 100644 --- a/test/unit/call_builders_test.js +++ b/test/unit/call_builders_test.js @@ -10,7 +10,7 @@ describe("CallBuilder functions", function () { expect(arg.toString()).not.to.be.equal("https://onedom.ain/one_segment"); // https://onedom.ain/ expect(builder.url.toString()).to.be.equal( - "https://onedom.ain/one_segment" + "https://onedom.ain/one_segment", ); }); }); diff --git a/test/unit/federation_server_test.js b/test/unit/federation_server_test.js index bc3bad34d..b8d97181f 100644 --- a/test/unit/federation_server_test.js +++ b/test/unit/federation_server_test.js @@ -4,7 +4,7 @@ describe("federation-server.js tests", function () { beforeEach(function () { this.server = new StellarSdk.FederationServer( "https://acme.com:1337/federation", - "stellar.org" + "stellar.org", ); this.axiosMock = sinon.mock(axios); @@ -21,8 +21,8 @@ describe("federation-server.js tests", function () { () => new StellarSdk.FederationServer( "http://acme.com:1337/federation", - "stellar.org" - ) + "stellar.org", + ), ).to.throw(/Cannot connect to insecure federation server/); }); @@ -32,8 +32,8 @@ describe("federation-server.js tests", function () { new StellarSdk.FederationServer( "http://acme.com:1337/federation", "stellar.org", - { allowHttp: true } - ) + { allowHttp: true }, + ), ).to.not.throw(); }); @@ -44,8 +44,8 @@ describe("federation-server.js tests", function () { new StellarSdk.FederationServer( "http://acme.com:1337/federation", "stellar.org", - { allowHttp: true } - ) + { allowHttp: true }, + ), ).to.not.throw(); }); }); @@ -56,8 +56,8 @@ describe("federation-server.js tests", function () { .expects("get") .withArgs( sinon.match( - "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org" - ) + "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org", + ), ) .returns( Promise.resolve({ @@ -66,7 +66,7 @@ describe("federation-server.js tests", function () { account_id: "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", }, - }) + }), ); }); @@ -76,7 +76,7 @@ describe("federation-server.js tests", function () { .then((response) => { expect(response.stellar_address).equals("bob*stellar.org"); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ); done(); }) @@ -91,7 +91,7 @@ describe("federation-server.js tests", function () { .then((response) => { expect(response.stellar_address).equals("bob*stellar.org"); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ); done(); }) @@ -107,8 +107,8 @@ describe("federation-server.js tests", function () { .expects("get") .withArgs( sinon.match( - "https://acme.com:1337/federation?type=id&q=GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" - ) + "https://acme.com:1337/federation?type=id&q=GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + ), ) .returns( Promise.resolve({ @@ -117,19 +117,19 @@ describe("federation-server.js tests", function () { account_id: "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", }, - }) + }), ); }); it("requests is correct", function (done) { this.server .resolveAccountId( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ) .then((response) => { expect(response.stellar_address).equals("bob*stellar.org"); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ); done(); }) @@ -145,8 +145,8 @@ describe("federation-server.js tests", function () { .expects("get") .withArgs( sinon.match( - "https://acme.com:1337/federation?type=txid&q=3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889" - ) + "https://acme.com:1337/federation?type=txid&q=3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", + ), ) .returns( Promise.resolve({ @@ -155,19 +155,19 @@ describe("federation-server.js tests", function () { account_id: "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", }, - }) + }), ); }); it("requests is correct", function (done) { this.server .resolveTransactionId( - "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889" + "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", ) .then((response) => { expect(response.stellar_address).equals("bob*stellar.org"); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ); done(); }) @@ -189,19 +189,19 @@ describe("federation-server.js tests", function () { # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" `, - }) + }), ); StellarSdk.FederationServer.createForDomain("acme.com").then( (federationServer) => { expect(federationServer.serverURL.protocol()).equals("https"); expect(federationServer.serverURL.hostname()).equals( - "api.stellar.org" + "api.stellar.org", ); expect(federationServer.serverURL.path()).equals("/federation"); expect(federationServer.domain).equals("acme.com"); done(); - } + }, ); }); @@ -212,12 +212,12 @@ FEDERATION_SERVER="https://api.stellar.org/federation" .returns( Promise.resolve({ data: "", - }) + }), ); StellarSdk.FederationServer.createForDomain("acme.com") .should.be.rejectedWith( - /stellar.toml does not contain FEDERATION_SERVER field/ + /stellar.toml does not contain FEDERATION_SERVER field/, ) .and.notify(done); }); @@ -226,7 +226,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" describe("FederationServer.resolve", function () { it("succeeds for a valid account ID", function (done) { StellarSdk.FederationServer.resolve( - "GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J" + "GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J", ) .should.eventually.deep.equal({ account_id: @@ -252,15 +252,15 @@ FEDERATION_SERVER="https://api.stellar.org/federation" # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" `, - }) + }), ); this.axiosMock .expects("get") .withArgs( sinon.match( - "https://api.stellar.org/federation?type=name&q=bob%2Astellar.org" - ) + "https://api.stellar.org/federation?type=name&q=bob%2Astellar.org", + ), ) .returns( Promise.resolve({ @@ -271,7 +271,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" memo_type: "id", memo: "100", }, - }) + }), ); StellarSdk.FederationServer.resolve("bob*stellar.org") @@ -296,8 +296,8 @@ FEDERATION_SERVER="https://api.stellar.org/federation" .expects("get") .withArgs( sinon.match( - "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org" - ) + "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org", + ), ) .returns( Promise.resolve({ @@ -308,7 +308,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" memo_type: "id", memo: 100, }, - }) + }), ); this.server @@ -323,7 +323,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" return done(); } var response = Array(StellarSdk.FEDERATION_RESPONSE_MAX_SIZE + 10).join( - "a" + "a", ); let tempServer = http .createServer((req, res) => { @@ -334,11 +334,11 @@ FEDERATION_SERVER="https://api.stellar.org/federation" new StellarSdk.FederationServer( "http://localhost:4444/federation", "stellar.org", - { allowHttp: true } + { allowHttp: true }, ) .resolveAddress("bob*stellar.org") .should.be.rejectedWith( - /federation response exceeds allowed size of [0-9]+/ + /federation response exceeds allowed size of [0-9]+/, ) .notify(done) .then(() => tempServer.close()); @@ -376,7 +376,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" new StellarSdk.FederationServer( "http://localhost:4444/federation", "stellar.org", - opts + opts, ) .resolveAddress("bob*stellar.org") .should.be.rejectedWith(/timeout of 1000ms exceeded/) @@ -398,10 +398,10 @@ FEDERATION_SERVER="https://api.stellar.org/federation" new StellarSdk.FederationServer( "http://localhost:4444/federation", "stellar.org", - opts + opts, ) .resolveAccountId( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS" + "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", ) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) @@ -422,10 +422,10 @@ FEDERATION_SERVER="https://api.stellar.org/federation" new StellarSdk.FederationServer( "http://localhost:4444/federation", "stellar.org", - opts + opts, ) .resolveTransactionId( - "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889" + "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", ) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) diff --git a/test/unit/horizon_path_test.js b/test/unit/horizon_path_test.js index 65ef48ace..2b62adfdc 100644 --- a/test/unit/horizon_path_test.js +++ b/test/unit/horizon_path_test.js @@ -47,7 +47,7 @@ describe("horizon path tests", function () { .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - } + }, ); it("server.transactions() " + serverUrl, function (done) { @@ -69,7 +69,7 @@ describe("horizon path tests", function () { .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - } + }, ); it("server.operations().includeFailed(true) " + serverUrl, function (done) { @@ -92,7 +92,7 @@ describe("horizon path tests", function () { .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - } + }, ); it( @@ -105,7 +105,7 @@ describe("horizon path tests", function () { .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - } + }, ); it("server.submitTransaction() " + serverUrl, function (done) { @@ -114,7 +114,7 @@ describe("horizon path tests", function () { let keypair = StellarSdk.Keypair.random(); let account = new StellarSdk.Account( keypair.publicKey(), - "56199647068161" + "56199647068161", ); let fakeTransaction = new StellarSdk.TransactionBuilder(account, { @@ -126,13 +126,13 @@ describe("horizon path tests", function () { destination: keypair.publicKey(), asset: StellarSdk.Asset.native(), amount: "100.50", - }) + }), ) .setTimeout(StellarSdk.TimeoutInfinite) .build(); fakeTransaction.sign(keypair); let tx = encodeURIComponent( - fakeTransaction.toEnvelope().toXDR().toString("base64") + fakeTransaction.toEnvelope().toXDR().toString("base64"), ); this.axiosMock diff --git a/test/unit/liquidity_pool_endpoints_test.js b/test/unit/liquidity_pool_endpoints_test.js index 118b9c72a..92ab3b196 100644 --- a/test/unit/liquidity_pool_endpoints_test.js +++ b/test/unit/liquidity_pool_endpoints_test.js @@ -88,11 +88,11 @@ describe("/liquidity_pools tests", function () { const EURT = new StellarSdk.Asset( "EURT", - "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S" + "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", ); const PHP = new StellarSdk.Asset( "PHP", - "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S" + "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", ); it("returns the right root response", function (done) { @@ -143,7 +143,7 @@ describe("/liquidity_pools tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match(`${LP_URL}?reserves=${encodeURIComponent(queryStr)}`) + sinon.match(`${LP_URL}?reserves=${encodeURIComponent(queryStr)}`), ) .returns(Promise.resolve({ data: testCase.response })); @@ -153,7 +153,7 @@ describe("/liquidity_pools tests", function () { .call() .then((pools) => { expect(pools.records).to.deep.equal( - testCase.response._embedded.records + testCase.response._embedded.records, ); done(); }) @@ -187,10 +187,10 @@ describe("/liquidity_pools tests", function () { it("checks for valid IDs", function () { expect(() => - this.server.liquidityPools().liquidityPoolId("nonsense") + this.server.liquidityPools().liquidityPoolId("nonsense"), ).to.throw(); expect(() => - this.server.liquidityPools().liquidityPoolId(lpId) + this.server.liquidityPools().liquidityPoolId(lpId), ).not.to.throw(); }); @@ -389,7 +389,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolOps) => { expect(poolOps.records).to.deep.equal( - poolOpsResponse._embedded.records + poolOpsResponse._embedded.records, ); done(); }) @@ -481,7 +481,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTxs) => { expect(poolTxs.records).to.deep.equal( - poolTxsResponse._embedded.records + poolTxsResponse._embedded.records, ); done(); }) @@ -757,7 +757,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolEffects) => { expect(poolEffects.records).to.deep.equal( - poolEffectsResponse._embedded.records + poolEffectsResponse._embedded.records, ); done(); }) @@ -833,7 +833,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTrades) => { expect(poolTrades.records).to.deep.equal( - poolTradesResponse._embedded.records + poolTradesResponse._embedded.records, ); done(); }) @@ -1000,7 +1000,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolOps) => { expect(poolOps.records).to.deep.equal( - poolOpsResponse._embedded.records + poolOpsResponse._embedded.records, ); done(); }) @@ -1092,7 +1092,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTxs) => { expect(poolTxs.records).to.deep.equal( - poolTxsResponse._embedded.records + poolTxsResponse._embedded.records, ); done(); }) @@ -1368,7 +1368,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolFxs) => { expect(poolFxs.records).to.deep.equal( - poolFxsResponse._embedded.records + poolFxsResponse._embedded.records, ); done(); }) diff --git a/test/unit/server/claimable_balances.js b/test/unit/server/claimable_balances.js index d02b94a66..d25680b13 100644 --- a/test/unit/server/claimable_balances.js +++ b/test/unit/server/claimable_balances.js @@ -3,7 +3,7 @@ const MockAdapter = require("axios-mock-adapter"); describe("ClaimableBalanceCallBuilder", function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337" + "https://horizon-live.stellar.org:1337", ); this.axiosMock = sinon.mock(HorizonAxiosClient); StellarSdk.Config.setDefault(); @@ -43,15 +43,15 @@ describe("ClaimableBalanceCallBuilder", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072" - ) + "https://horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", + ), ) .returns(Promise.resolve({ data: singleBalanceResponse })); this.server .claimableBalances() .claimableBalance( - "00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072" + "00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", ) .call() .then(function (response) { @@ -85,8 +85,8 @@ describe("ClaimableBalanceCallBuilder", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .returns(Promise.resolve({ data })); @@ -126,8 +126,8 @@ describe("ClaimableBalanceCallBuilder", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .returns(Promise.resolve({ data })); @@ -167,8 +167,8 @@ describe("ClaimableBalanceCallBuilder", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .returns(Promise.resolve({ data })); @@ -177,8 +177,8 @@ describe("ClaimableBalanceCallBuilder", function () { .asset( new StellarSdk.Asset( "USD", - "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .call() .then(function (response) { diff --git a/test/unit/server/join_test.js b/test/unit/server/join_test.js index eee5183c6..39853a83d 100644 --- a/test/unit/server/join_test.js +++ b/test/unit/server/join_test.js @@ -3,7 +3,7 @@ const MockAdapter = require("axios-mock-adapter"); describe("Server - CallBuilder#join", function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337" + "https://horizon-live.stellar.org:1337", ); this.axiosMock = sinon.mock(HorizonAxiosClient); }); @@ -146,8 +146,8 @@ describe("Server - CallBuilder#join", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/operations?join=transactions" - ) + "https://horizon-live.stellar.org:1337/operations?join=transactions", + ), ) .returns(Promise.resolve({ data: operationsResponse })); diff --git a/test/unit/server_check_memo_required_test.js b/test/unit/server_check_memo_required_test.js index 017594f9a..bde7f2bb6 100644 --- a/test/unit/server_check_memo_required_test.js +++ b/test/unit/server_check_memo_required_test.js @@ -9,13 +9,13 @@ function buildTransaction(destination, operations = [], builderOpts = {}) { let account = new StellarSdk.Account(keypair.publicKey(), "56199647068161"); let transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ).addOperation( StellarSdk.Operation.payment({ destination: destination, asset: StellarSdk.Asset.native(), amount: "100.50", - }) + }), ); operations.forEach((op) => (transaction = transaction.addOperation(op))); @@ -28,7 +28,7 @@ function buildTransaction(destination, operations = [], builderOpts = {}) { keypair, "200", transaction, - txBuilderOpts.networkPassphrase + txBuilderOpts.networkPassphrase, ); } else { return transaction; @@ -132,7 +132,7 @@ describe("server.js check-memo-required", function () { expect(err.accountId).to.eq(accountId); expect(err.operationIndex).to.eq(0); done(); - } + }, ) .catch(function (err) { done(err); @@ -157,7 +157,7 @@ describe("server.js check-memo-required", function () { expect(err.accountId).to.eq(accountId); expect(err.operationIndex).to.eq(0); done(); - } + }, ) .catch(function (err) { done(err); @@ -208,7 +208,7 @@ describe("server.js check-memo-required", function () { function (err) { expect(err).to.be.instanceOf(StellarSdk.NetworkError); done(); - } + }, ) .catch(function (err) { done(err); @@ -251,11 +251,11 @@ describe("server.js check-memo-required", function () { const usd = new StellarSdk.Asset( "USD", - "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB" + "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB", ); const eur = new StellarSdk.Asset( "EUR", - "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL" + "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL", ); const liquidityPoolAsset = new StellarSdk.LiquidityPoolAsset(eur, usd, 30); diff --git a/test/unit/server_test.js b/test/unit/server_test.js index b0a2c40f8..0d1ff3b44 100644 --- a/test/unit/server_test.js +++ b/test/unit/server_test.js @@ -3,7 +3,7 @@ const MockAdapter = require("axios-mock-adapter"); describe("server.js non-transaction tests", function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337" + "https://horizon-live.stellar.org:1337", ); this.axiosMock = sinon.mock(HorizonAxiosClient); StellarSdk.Config.setDefault(); @@ -17,7 +17,7 @@ describe("server.js non-transaction tests", function () { describe("Server.constructor", function () { it("throws error for insecure server", function () { expect( - () => new StellarSdk.Server("http://horizon-live.stellar.org:1337") + () => new StellarSdk.Server("http://horizon-live.stellar.org:1337"), ).to.throw(/Cannot connect to insecure horizon server/); }); @@ -26,14 +26,14 @@ describe("server.js non-transaction tests", function () { () => new StellarSdk.Server("http://horizon-live.stellar.org:1337", { allowHttp: true, - }) + }), ).to.not.throw(); }); it("allow insecure server when global Config.allowHttp flag is set", function () { StellarSdk.Config.setAllowHttp(true); expect( - () => new StellarSdk.Server("http://horizon-live.stellar.org:1337") + () => new StellarSdk.Server("http://horizon-live.stellar.org:1337"), ).to.not.throw(); }); }); @@ -81,7 +81,7 @@ describe("server.js non-transaction tests", function () { {}, { date: "Wed, 13 Mar 2019 22:15:07 GMT", - } + }, ); this.server @@ -144,7 +144,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats") + sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), ) .returns(Promise.resolve({ data: response })); @@ -163,7 +163,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats") + sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), ) .returns(Promise.resolve({ data: {} })); @@ -222,7 +222,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats") + sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), ) .returns(Promise.resolve({ data: response })); @@ -325,8 +325,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS" - ) + "https://horizon-live.stellar.org:1337/accounts/GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS", + ), ) .returns(Promise.resolve({ data: accountResponse })); @@ -335,7 +335,7 @@ describe("server.js non-transaction tests", function () { .then((response) => { // Response data expect(response.account_id).to.be.equal( - "GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS" + "GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS", ); expect(response.subentry_count).to.be.equal(5); expect(response.transactions).to.be.a("function"); @@ -410,7 +410,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers") + sinon.match("https://horizon-live.stellar.org:1337/ledgers"), ) .returns(Promise.resolve({ data: ledgersResponse })); @@ -419,7 +419,7 @@ describe("server.js non-transaction tests", function () { .call() .then((response) => { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records + ledgersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -437,8 +437,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers?limit=1&cursor=b&order=asc" - ) + "https://horizon-live.stellar.org:1337/ledgers?limit=1&cursor=b&order=asc", + ), ) .returns(Promise.resolve({ data: ledgersResponse })); }); @@ -452,7 +452,7 @@ describe("server.js non-transaction tests", function () { .call() .then((response) => { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records + ledgersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -465,8 +465,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers?order=asc&limit=1&cursor=4294967296" - ) + "https://horizon-live.stellar.org:1337/ledgers?order=asc&limit=1&cursor=4294967296", + ), ) .returns(Promise.resolve({ data: ledgersResponse })); @@ -479,7 +479,7 @@ describe("server.js non-transaction tests", function () { .then(function (page) { page.next().then(function (response) { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records + ledgersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -524,12 +524,12 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers/1") + sinon.match("https://horizon-live.stellar.org:1337/ledgers/1"), ) .returns( Promise.reject({ response: { status: 404, statusText: "NotFound", data: {} }, - }) + }), ); this.server @@ -553,7 +553,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers/1") + sinon.match("https://horizon-live.stellar.org:1337/ledgers/1"), ) .returns(Promise.resolve({ data: singleLedgerResponse })); @@ -577,8 +577,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/1?limit=1&cursor=b&order=asc" - ) + "https://horizon-live.stellar.org:1337/ledgers/1?limit=1&cursor=b&order=asc", + ), ) .returns(Promise.resolve({ data: singleLedgerResponse })); @@ -675,8 +675,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions" - ) + "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions", + ), ) .returns(Promise.resolve({ data: transactionsResponse })); @@ -684,8 +684,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations/ - ) + /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations/, + ), ) .returns(Promise.resolve({ data: { operations: [] } })); @@ -695,7 +695,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records + transactionsResponse._embedded.records, ); expect(response.records[0].ledger).to.be.a("function"); expect(response.records[0].ledger_attr).to.be.equal(7952722); @@ -723,8 +723,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions?cursor=b&limit=1&order=asc" - ) + "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions?cursor=b&limit=1&order=asc", + ), ) .returns(Promise.resolve({ data: transactionsResponse })); @@ -732,8 +732,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations\?limit=1/ - ) + /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations\?limit=1/, + ), ) .returns(Promise.resolve({ data: { operations: [] } })); @@ -746,7 +746,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records + transactionsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -841,15 +841,15 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0" - ) + "https://horizon-live.stellar.org:1337/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", + ), ) .returns(Promise.resolve({ data: singleTranssactionResponse })); this.server .transactions() .transaction( - "6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0" + "6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", ) .call() .then(function (response) { @@ -1039,20 +1039,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/transactions" - ) + "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/transactions", + ), ) .returns(Promise.resolve({ data: transactionsResponse })); this.server .transactions() .forClaimableBalance( - "000000000102030000000000000000000000000000000000000000000000000000000000" + "000000000102030000000000000000000000000000000000000000000000000000000000", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records + transactionsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1126,8 +1126,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K" - ) + "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + ), ) .returns(Promise.resolve({ data: singleAccountResponse })); @@ -1250,8 +1250,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42" - ) + "https://horizon-live.stellar.org:1337/accounts?signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + ), ) .returns(Promise.resolve({ data: accountsForSignerResponse })); @@ -1261,7 +1261,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForSignerResponse._embedded.records + accountsForSignerResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1378,8 +1378,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "https://horizon-live.stellar.org:1337/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .returns(Promise.resolve({ data: accountsForAssetResponse })); @@ -1388,13 +1388,13 @@ describe("server.js non-transaction tests", function () { .forAsset( new StellarSdk.Asset( "USD", - "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD" - ) + "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + ), ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForAssetResponse._embedded.records + accountsForAssetResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1515,8 +1515,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42" - ) + "https://horizon-live.stellar.org:1337/accounts?sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + ), ) .returns(Promise.resolve({ data: accountsForSponsor })); @@ -1526,7 +1526,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForSponsor._embedded.records + accountsForSponsor._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1670,20 +1670,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7" - ) + "https://horizon-live.stellar.org:1337/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", + ), ) .returns(Promise.resolve({ data: accountsForAssetResponse })); this.server .accounts() .forLiquidityPool( - "dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7" + "dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForAssetResponse._embedded.records + accountsForAssetResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1718,8 +1718,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?order=asc" - ) + "https://horizon-live.stellar.org:1337/offers?order=asc", + ), ) .returns(Promise.resolve({ data: offersResponse })); this.server @@ -1728,7 +1728,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records + offersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1774,7 +1774,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/offers/12345") + sinon.match("https://horizon-live.stellar.org:1337/offers/12345"), ) .returns(Promise.resolve({ data: offerResponse })); @@ -1797,21 +1797,21 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers?order=asc" - ) + "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers?order=asc", + ), ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() .forAccount( - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K" + "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", ) .order("asc") .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records + offersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1824,15 +1824,15 @@ describe("server.js non-transaction tests", function () { it("selling requests the correct endpoint", function (done) { const selling = new StellarSdk.Asset( "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG" + "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", ); this.axiosMock .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc" - ) + "https://horizon-live.stellar.org:1337/offers?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", + ), ) .returns(Promise.resolve({ data: offersResponse })); @@ -1843,7 +1843,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records + offersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1856,15 +1856,15 @@ describe("server.js non-transaction tests", function () { it("buying requests the correct endpoint", function (done) { const buying = new StellarSdk.Asset( "COP", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG" + "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", ); this.axiosMock .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?buying_asset_type=credit_alphanum4&buying_asset_code=COP&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc" - ) + "https://horizon-live.stellar.org:1337/offers?buying_asset_type=credit_alphanum4&buying_asset_code=COP&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", + ), ) .returns(Promise.resolve({ data: offersResponse })); @@ -1875,7 +1875,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records + offersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1890,8 +1890,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?sponsor=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc" - ) + "https://horizon-live.stellar.org:1337/offers?sponsor=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", + ), ) .returns(Promise.resolve({ data: offersResponse })); @@ -1902,7 +1902,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records + offersResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -1936,8 +1936,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=native&buying_asset_type=credit_alphanum4&buying_asset_code=USD&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG" - ) + "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=native&buying_asset_type=credit_alphanum4&buying_asset_code=USD&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", + ), ) .returns(Promise.resolve({ data: orderBookResponse })); @@ -1946,8 +1946,8 @@ describe("server.js non-transaction tests", function () { StellarSdk.Asset.native(), new StellarSdk.Asset( "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG" - ) + "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", + ), ) .call() .then(function (response) { @@ -1964,8 +1964,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&buying_asset_type=native" - ) + "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&buying_asset_type=native", + ), ) .returns(Promise.resolve({ data: orderBookResponse })); @@ -1973,9 +1973,9 @@ describe("server.js non-transaction tests", function () { .orderbook( new StellarSdk.Asset( "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG" + "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", ), - StellarSdk.Asset.native() + StellarSdk.Asset.native(), ) .call() .then(function (response) { @@ -2052,7 +2052,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2118,8 +2118,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM" - ) + "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + ), ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2129,13 +2129,13 @@ describe("server.js non-transaction tests", function () { StellarSdk.Asset.native(), new StellarSdk.Asset( "JPY", - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM" - ) + "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + ), ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2201,8 +2201,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?offer_id=278232" - ) + "https://horizon-live.stellar.org:1337/trades?offer_id=278232", + ), ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2212,7 +2212,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2273,20 +2273,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades" - ) + "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades", + ), ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() .forAccount( - "GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY" + "GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2355,8 +2355,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0" - ) + "https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0", + ), ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2368,7 +2368,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2434,8 +2434,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?trade_type=orderbook" - ) + "https://horizon-live.stellar.org:1337/trades?trade_type=orderbook", + ), ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2445,7 +2445,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2512,8 +2512,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?trade_type=liquidity_pool" - ) + "https://horizon-live.stellar.org:1337/trades?trade_type=liquidity_pool", + ), ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2523,7 +2523,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records + tradesResponse._embedded.records, ); done(); }) @@ -2610,8 +2610,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/paths/strict-receive?source_account=GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" - ) + "https://horizon-live.stellar.org:1337/paths/strict-receive?source_account=GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + ), ) .returns(Promise.resolve({ data: pathsResponse })); @@ -2620,14 +2620,14 @@ describe("server.js non-transaction tests", function () { "GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP", new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), - "20.0" + "20.0", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records + pathsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2639,14 +2639,14 @@ describe("server.js non-transaction tests", function () { }); it("requests the correct endpoint when source is a list of assets", function (done) { let destinationAssets = encodeURIComponent( - "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ); this.axiosMock .expects("get") .withArgs( sinon.match( - `https://horizon-live.stellar.org:1337/paths/strict-receive?source_assets=${destinationAssets}&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN` - ) + `https://horizon-live.stellar.org:1337/paths/strict-receive?source_assets=${destinationAssets}&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN`, + ), ) .returns(Promise.resolve({ data: pathsResponse })); @@ -2654,11 +2654,11 @@ describe("server.js non-transaction tests", function () { StellarSdk.Asset.native(), new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), new StellarSdk.Asset( "USD", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), ]; @@ -2667,14 +2667,14 @@ describe("server.js non-transaction tests", function () { assets, new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), - "20.0" + "20.0", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records + pathsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2763,8 +2763,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_account=GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V" - ) + "https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_account=GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V", + ), ) .returns(Promise.resolve({ data: pathsResponse })); @@ -2772,15 +2772,15 @@ describe("server.js non-transaction tests", function () { .strictSendPaths( new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), "20.0", - "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V" + "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records + pathsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2792,14 +2792,14 @@ describe("server.js non-transaction tests", function () { }); it("requests the correct endpoint when destination is a list of assets", function (done) { let destinationAssets = encodeURIComponent( - "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ); this.axiosMock .expects("get") .withArgs( sinon.match( - `https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_assets=${destinationAssets}` - ) + `https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_assets=${destinationAssets}`, + ), ) .returns(Promise.resolve({ data: pathsResponse })); @@ -2807,11 +2807,11 @@ describe("server.js non-transaction tests", function () { StellarSdk.Asset.native(), new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), new StellarSdk.Asset( "USD", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), ]; @@ -2819,15 +2819,15 @@ describe("server.js non-transaction tests", function () { .strictSendPaths( new StellarSdk.Asset( "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN" + "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", ), "20.0", - assets + assets, ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records + pathsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2882,8 +2882,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/effects?cursor=b" - ) + "https://horizon-live.stellar.org:1337/effects?cursor=b", + ), ) .returns(Promise.resolve({ data: effectsResponse })); @@ -2893,7 +2893,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records + effectsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2909,20 +2909,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/effects" - ) + "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/effects", + ), ) .returns(Promise.resolve({ data: effectsResponse })); this.server .effects() .forAccount( - "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE" + "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records + effectsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2938,20 +2938,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae/effects" - ) + "https://horizon-live.stellar.org:1337/transactions/ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae/effects", + ), ) .returns(Promise.resolve({ data: effectsResponse })); this.server .effects() .forTransaction( - "ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae" + "ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records + effectsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -2964,7 +2964,7 @@ describe("server.js non-transaction tests", function () { it("rejects two filters", function (done) { expect(() => - this.server.effects().forOperation("blah").forLedger("234").call() + this.server.effects().forOperation("blah").forLedger("234").call(), ).to.throw(/Too many filters/); done(); }); @@ -3023,8 +3023,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/operations/123456789" - ) + "https://horizon-live.stellar.org:1337/operations/123456789", + ), ) .returns(Promise.resolve({ data: operationsResponse })); @@ -3034,7 +3034,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records + operationsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3050,20 +3050,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/operations" - ) + "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/operations", + ), ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() .forAccount( - "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE" + "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records + operationsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3079,20 +3079,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/operations" - ) + "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/operations", + ), ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() .forClaimableBalance( - "000000000102030000000000000000000000000000000000000000000000000000000000" + "000000000102030000000000000000000000000000000000000000000000000000000000", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records + operationsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3108,8 +3108,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/123456789/operations" - ) + "https://horizon-live.stellar.org:1337/ledgers/123456789/operations", + ), ) .returns(Promise.resolve({ data: operationsResponse })); @@ -3119,7 +3119,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records + operationsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3135,8 +3135,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/blah/operations" - ) + "https://horizon-live.stellar.org:1337/transactions/blah/operations", + ), ) .returns(Promise.resolve({ data: operationsResponse })); @@ -3146,7 +3146,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records + operationsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3211,20 +3211,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/payments" - ) + "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/payments", + ), ) .returns(Promise.resolve({ data: paymentsResponse })); this.server .payments() .forAccount( - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K" + "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records + paymentsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3240,8 +3240,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/123456789/payments" - ) + "https://horizon-live.stellar.org:1337/ledgers/123456789/payments", + ), ) .returns(Promise.resolve({ data: paymentsResponse })); @@ -3251,7 +3251,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records + paymentsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3267,20 +3267,20 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731/payments" - ) + "https://horizon-live.stellar.org:1337/transactions/77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731/payments", + ), ) .returns(Promise.resolve({ data: paymentsResponse })); this.server .payments() .forTransaction( - "77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731" + "77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731", ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records + paymentsResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3302,8 +3302,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/friendbot?addr=GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K" - ) + "https://horizon-live.stellar.org:1337/friendbot?addr=GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + ), ) .returns(Promise.resolve({ data: friendbotResponse })); @@ -3377,8 +3377,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=BTC&counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&start_time=1512689100000&end_time=1512775500000&resolution=300000" - ) + "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=BTC&counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&start_time=1512689100000&end_time=1512775500000&resolution=300000", + ), ) .returns(Promise.resolve({ data: tradeAggregationResponse })); @@ -3387,17 +3387,17 @@ describe("server.js non-transaction tests", function () { StellarSdk.Asset.native(), new StellarSdk.Asset( "BTC", - "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH" + "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH", ), 1512689100000, 1512775500000, 300000, - 0 + 0, ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradeAggregationResponse._embedded.records + tradeAggregationResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3413,8 +3413,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=credit_alphanum4&base_asset_code=BTC&base_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&counter_asset_type=native&start_time=1512689100000&end_time=1512775500000&resolution=300000" - ) + "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=credit_alphanum4&base_asset_code=BTC&base_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&counter_asset_type=native&start_time=1512689100000&end_time=1512775500000&resolution=300000", + ), ) .returns(Promise.resolve({ data: tradeAggregationResponse })); @@ -3422,18 +3422,18 @@ describe("server.js non-transaction tests", function () { .tradeAggregation( new StellarSdk.Asset( "BTC", - "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH" + "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH", ), StellarSdk.Asset.native(), 1512689100000, 1512775500000, 300000, - 0 + 0, ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradeAggregationResponse._embedded.records + tradeAggregationResponse._embedded.records, ); expect(response.next).to.be.a("function"); expect(response.prev).to.be.a("function"); @@ -3503,7 +3503,7 @@ describe("server.js non-transaction tests", function () { this.axiosMock .expects("get") .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/assets?limit=1") + sinon.match("https://horizon-live.stellar.org:1337/assets?limit=1"), ) .returns(Promise.resolve({ data: assetsResponse })); @@ -3513,7 +3513,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.equal( - assetsResponse._embedded.records + assetsResponse._embedded.records, ); done(); }) @@ -3579,8 +3579,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_code=USD&limit=1" - ) + "https://horizon-live.stellar.org:1337/assets?asset_code=USD&limit=1", + ), ) .returns(Promise.resolve({ data: assetsCodeResponse })); @@ -3591,7 +3591,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.equal( - assetsCodeResponse._embedded.records + assetsCodeResponse._embedded.records, ); done(); }) @@ -3657,8 +3657,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN&limit=1" - ) + "https://horizon-live.stellar.org:1337/assets?asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN&limit=1", + ), ) .returns(Promise.resolve({ data: assetIssuerResponse })); @@ -3669,7 +3669,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.equal( - assetIssuerResponse._embedded.records + assetIssuerResponse._embedded.records, ); done(); }) @@ -3735,8 +3735,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR&asset_code=USD" - ) + "https://horizon-live.stellar.org:1337/assets?asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR&asset_code=USD", + ), ) .returns(Promise.resolve({ data: assetCodeIssuerResponse })); @@ -3747,7 +3747,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.equal( - assetCodeIssuerResponse._embedded.records + assetCodeIssuerResponse._embedded.records, ); done(); }) @@ -3761,8 +3761,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_code=USD&asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR" - ) + "https://horizon-live.stellar.org:1337/assets?asset_code=USD&asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", + ), ) .returns(Promise.resolve({ data: assetCodeIssuerResponse })); @@ -3773,7 +3773,7 @@ describe("server.js non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.equal( - assetCodeIssuerResponse._embedded.records + assetCodeIssuerResponse._embedded.records, ); done(); }) @@ -3789,8 +3789,8 @@ describe("server.js non-transaction tests", function () { .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects" - ) + "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects", + ), ) .returns(Promise.resolve({ data: {} })); diff --git a/test/unit/server_transaction_test.js b/test/unit/server_transaction_test.js index 645f99f76..50ea7d49c 100644 --- a/test/unit/server_transaction_test.js +++ b/test/unit/server_transaction_test.js @@ -4,7 +4,7 @@ describe("server.js transaction tests", function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337" + "https://horizon-live.stellar.org:1337", ); this.axiosMock = sinon.mock(HorizonAxiosClient); let transaction = new StellarSdk.TransactionBuilder(account, { @@ -18,7 +18,7 @@ describe("server.js transaction tests", function () { "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", asset: StellarSdk.Asset.native(), amount: "100.50", - }) + }), ) .setTimeout(StellarSdk.TimeoutInfinite) .build(); @@ -26,7 +26,7 @@ describe("server.js transaction tests", function () { this.transaction = transaction; this.blob = encodeURIComponent( - transaction.toEnvelope().toXDR().toString("base64") + transaction.toEnvelope().toXDR().toString("base64"), ); }); @@ -40,7 +40,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: {} })); @@ -73,7 +73,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -119,7 +119,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -163,7 +163,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -207,7 +207,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -226,13 +226,13 @@ describe("server.js transaction tests", function () { expect(res.offerResults[0].isFullyOpen).to.equal(false); expect(res.offerResults[0].operationIndex).to.equal(0); expect(res.offerResults[0].currentOffer.selling.type).to.equal( - "native" + "native", ); expect(res.offerResults[0].currentOffer.buying.assetCode).to.equal( - "BAT" + "BAT", ); expect(res.offerResults[0].currentOffer.buying.issuer).to.equal( - "GBDEVU63Y6NTHJQQZIKVTC23NWLQVP3WJ2RI2OTSJTNYOIGICST6DUXR" + "GBDEVU63Y6NTHJQQZIKVTC23NWLQVP3WJ2RI2OTSJTNYOIGICST6DUXR", ); done(); @@ -261,7 +261,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -296,7 +296,7 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: response })); @@ -322,20 +322,20 @@ describe("server.js transaction tests", function () { .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: {} })); this.axiosMock .expects("get") .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW" - ) + "https://horizon-live.stellar.org:1337/accounts/GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + ), ) .returns( Promise.reject({ response: { status: 404, statusText: "NotFound", data: {} }, - }) + }), ) .once(); @@ -353,18 +353,18 @@ describe("server.js transaction tests", function () { keypair, "200", this.transaction, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); this.blob = encodeURIComponent( - feeBumpTx.toEnvelope().toXDR().toString("base64") + feeBumpTx.toEnvelope().toXDR().toString("base64"), ); this.axiosMock .expects("post") .withArgs( "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}` + `tx=${this.blob}`, ) .returns(Promise.resolve({ data: {} })); diff --git a/test/unit/stellar_toml_resolver_test.js b/test/unit/stellar_toml_resolver_test.js index 62a2b5142..cd932490a 100644 --- a/test/unit/stellar_toml_resolver_test.js +++ b/test/unit/stellar_toml_resolver_test.js @@ -27,12 +27,12 @@ describe("stellar_toml_resolver.js tests", function () { # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" `, - }) + }), ); StellarSdk.StellarTomlResolver.resolve("acme.com").then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "https://api.stellar.org/federation" + "https://api.stellar.org/federation", ); done(); }); @@ -49,14 +49,14 @@ FEDERATION_SERVER="https://api.stellar.org/federation" # for users on your domain. FEDERATION_SERVER="http://api.stellar.org/federation" `, - }) + }), ); StellarSdk.StellarTomlResolver.resolve("acme.com", { allowHttp: true, }).then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "http://api.stellar.org/federation" + "http://api.stellar.org/federation", ); done(); }); @@ -75,12 +75,12 @@ FEDERATION_SERVER="http://api.stellar.org/federation" # for users on your domain. FEDERATION_SERVER="http://api.stellar.org/federation" `, - }) + }), ); StellarSdk.StellarTomlResolver.resolve("acme.com").then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "http://api.stellar.org/federation" + "http://api.stellar.org/federation", ); done(); }); @@ -97,7 +97,7 @@ FEDERATION_SERVER="http://api.stellar.org/federation" # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" `, - }) + }), ); StellarSdk.StellarTomlResolver.resolve("acme.com") @@ -112,7 +112,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" .returns(Promise.reject()); StellarSdk.StellarTomlResolver.resolve( - "acme.com" + "acme.com", ).should.be.rejected.and.notify(done); }); @@ -132,7 +132,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" allowHttp: true, }) .should.be.rejectedWith( - /stellar.toml file exceeds allowed size of [0-9]+/ + /stellar.toml file exceeds allowed size of [0-9]+/, ) .notify(done) .then(() => tempServer.close()); diff --git a/test/unit/utils_test.js b/test/unit/utils_test.js index ef07703d6..f712c9d7c 100644 --- a/test/unit/utils_test.js +++ b/test/unit/utils_test.js @@ -33,13 +33,13 @@ describe("Utils", function () { "testanchor.stellar.org", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" - )) + "testanchor.stellar.org", + )), ).not.to.throw(); const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true + true, ); expect(transaction.operations[0].source).to.equal(muxedAddress); }); @@ -56,13 +56,13 @@ describe("Utils", function () { 300, StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "8884404377665521220" - )) + "8884404377665521220", + )), ).not.to.throw(); const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true + true, ); expect(transaction.memo.value).to.equal("8884404377665521220"); }); @@ -78,8 +78,8 @@ describe("Utils", function () { 300, StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "memo text" - )) + "memo text", + )), ).to.throw(); }); @@ -96,8 +96,8 @@ describe("Utils", function () { 300, StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "8884404377665521220" - )) + "8884404377665521220", + )), ).to.throw(/memo cannot be used if clientAccountID is a muxed account/); }); @@ -114,12 +114,12 @@ describe("Utils", function () { "testanchor.stellar.org", null, "testdomain", - clientSigningKeypair.publicKey() + clientSigningKeypair.publicKey(), ); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(transaction.sequence).to.eql("0"); @@ -134,12 +134,12 @@ describe("Utils", function () { expect(operation1.name).to.eql("testanchor.stellar.org auth"); expect(operation1.source).to.eql( - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF" + "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", ); expect(operation1.type).to.eql("manageData"); expect(operation1.value.length).to.eql(64); expect(Buffer.from(operation1.value.toString(), "base64").length).to.eql( - 48 + 48, ); expect(operation2.name).to.equal("web_auth_domain"); @@ -162,12 +162,12 @@ describe("Utils", function () { "testanchor.stellar.org", 600, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); let maxTime = parseInt(transaction.timeBounds.maxTime); @@ -190,8 +190,8 @@ describe("Utils", function () { 600, StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "10154623012567072189" - ) + "10154623012567072189", + ), ).to.throw(/memo cannot be used if clientAccountID is a muxed account/); }); @@ -206,8 +206,8 @@ describe("Utils", function () { "testanchor.stellar.org", null, "testdomain", - null - ) + null, + ), ).to.throw(/clientSigningKey is required if clientDomain is provided/); }); }); @@ -223,7 +223,7 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); const innerTx = new StellarSdk.TransactionBuilder( @@ -235,14 +235,14 @@ describe("Utils", function () { minTime: 0, maxTime: 0, }, - } + }, ) .addOperation( StellarSdk.Operation.payment({ destination: clientKP.publicKey(), asset: StellarSdk.Asset.native(), amount: "10.000", - }) + }), ) .build(); @@ -250,7 +250,7 @@ describe("Utils", function () { serverKP, "300", innerTx, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ).toXDR(); expect(() => @@ -259,11 +259,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid challenge: expected a Transaction but received a FeeBumpTransaction/ + /Invalid challenge: expected a Transaction but received a FeeBumpTransaction/, ); expect(() => @@ -272,8 +272,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.not.throw(StellarSdk.InvalidSep10ChallengeError); expect(() => StellarSdk.Utils.readChallengeTx( @@ -281,8 +281,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.not.throw(StellarSdk.InvalidSep10ChallengeError); }); it("returns the transaction and the clientAccountID (client's pubKey) if the challenge was created successfully", function () { @@ -295,14 +295,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -311,8 +311,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transaction, clientAccountID: clientKP.publicKey(), @@ -333,14 +333,14 @@ describe("Utils", function () { 300, StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - clientMemo + clientMemo, ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -349,8 +349,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transaction, clientAccountID: clientKP.publicKey(), @@ -370,7 +370,7 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); @@ -378,7 +378,7 @@ describe("Utils", function () { const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true + true, ); expect( @@ -387,8 +387,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transaction, clientAccountID: muxedAddress, @@ -405,7 +405,7 @@ describe("Utils", function () { "MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC"; const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ @@ -413,7 +413,7 @@ describe("Utils", function () { name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), withMuxing: true, - }) + }), ) .addMemo(new StellarSdk.Memo.id("5842698851377328257")) .setTimeout(30) @@ -424,7 +424,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(() => @@ -433,11 +433,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has a memo but the client account ID is a muxed account/ + /The transaction has a memo but the client account ID is a muxed account/, ); }); @@ -447,14 +447,14 @@ describe("Utils", function () { const transaction = new StellarSdk.TransactionBuilder( new StellarSdk.Account(serverKP.publicKey(), "-1"), - { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET } + { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET }, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "SDF-test auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -467,11 +467,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF-test", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + serverKP.publicKey() + "'" + "Transaction not signed by server: '" + serverKP.publicKey() + "'", ); }); @@ -481,7 +481,7 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "100"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .setTimeout(30) .build(); @@ -494,11 +494,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction sequence number should be zero/ + /The transaction sequence number should be zero/, ); }); @@ -511,7 +511,7 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); let serverAccountId = StellarSdk.Keypair.random().publicKey(); @@ -522,11 +522,11 @@ describe("Utils", function () { serverAccountId, StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction source account is not equal to the server's account/ + /The transaction source account is not equal to the server's account/, ); }); @@ -535,7 +535,7 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .setTimeout(30) .build(); @@ -549,11 +549,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction should contain at least one operation/ + /The transaction should contain at least one operation/, ); }); @@ -562,13 +562,13 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ name: "SDF auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -582,11 +582,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation should contain a source account/ + /The transaction\'s operation should contain a source account/, ); }); @@ -595,13 +595,13 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.accountMerge({ destination: keypair.publicKey(), source: keypair.publicKey(), - }) + }), ) .setTimeout(30) .build(); @@ -615,11 +615,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation type should be \'manageData\'/ + /The transaction\'s operation type should be \'manageData\'/, ); }); @@ -648,7 +648,7 @@ describe("Utils", function () { name: `${anchorName} auth`, value, source: clientKeypair.publicKey(), - }) + }), ) .build(); @@ -657,7 +657,7 @@ describe("Utils", function () { transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(clientKeypair); @@ -672,11 +672,11 @@ describe("Utils", function () { serverKeypair.publicKey(), StellarSdk.Networks.TESTNET, anchorName, - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction requires non-infinite timebounds/ + /The transaction requires non-infinite timebounds/, ); }); @@ -685,14 +685,14 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ name: "SDF auth", value: randomBytes(64), source: "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - }) + }), ) .setTimeout(30) .build(); @@ -706,11 +706,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation value should be a 64 bytes base64 random string/ + /The transaction\'s operation value should be a 64 bytes base64 random string/, ); }); @@ -719,14 +719,14 @@ describe("Utils", function () { const account = new StellarSdk.Account(keypair.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ name: "SDF auth", value: null, source: "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - }) + }), ) .setTimeout(30) .build(); @@ -738,11 +738,11 @@ describe("Utils", function () { StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), - StellarSdk.Networks.TESTNET - ) + StellarSdk.Networks.TESTNET, + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation values should not be null/ + /The transaction\'s operation values should not be null/, ); }); @@ -756,7 +756,7 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); // Note that this is greater than the grace period of 5 minutes (600 seconds) @@ -764,7 +764,7 @@ describe("Utils", function () { const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(clientKeypair); @@ -779,11 +779,11 @@ describe("Utils", function () { keypair.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has expired/ + /The transaction has expired/, ); }); @@ -801,11 +801,11 @@ describe("Utils", function () { "GDMSN2PQ3EB32LZY5JVACI4H7GUVQ3YUWOM4437IDTVQHHWHYG7CGA5Z", StellarSdk.Networks.TESTNET, "testnet-sep.stablex.cloud", - "staging-transfer-server.zetl.network" - ) + "staging-transfer-server.zetl.network", + ), ).not.to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has expired/ + /The transaction has expired/, ); }); @@ -815,14 +815,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -832,7 +832,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -841,8 +841,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -857,14 +857,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -874,7 +874,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -883,8 +883,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, ["SDF", "Test", "testanchor.stellar.org", "SDF-test"], - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -899,14 +899,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -918,12 +918,12 @@ describe("Utils", function () { StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, // home domain not provided - ) + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: a home domain must be provided for verification/ + /Invalid homeDomains: a home domain must be provided for verification/, ); }); @@ -933,14 +933,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -954,11 +954,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, // home domain as number - 1 - ) + 1, + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: homeDomains type is number but should be a string or an array/ + /Invalid homeDomains: homeDomains type is number but should be a string or an array/, ); }); @@ -968,14 +968,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "does.not.match auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -989,11 +989,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/ + /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/, ); }); @@ -1003,14 +1003,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "does.not.match auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -1024,11 +1024,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, ["SDF", "Test", "testanchor.stellar.org", "SDF-test"], - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/ + /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/, ); }); @@ -1038,21 +1038,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "SDF auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), name: "a key", value: "a value", - }) + }), ) .setTimeout(30) .build(); @@ -1062,7 +1062,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -1071,8 +1071,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -1087,21 +1087,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "SDF auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "a key", value: "a value", - }) + }), ) .setTimeout(30) .build(); @@ -1111,7 +1111,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(() => @@ -1120,11 +1120,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are unrecognized/ + /The transaction has operations that are unrecognized/, ); }); @@ -1134,20 +1134,20 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "SDF auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.bumpSequence({ source: clientKP.publicKey(), bumpTo: "0", - }) + }), ) .setTimeout(30) .build(); @@ -1157,7 +1157,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(() => @@ -1166,11 +1166,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are not of type 'manageData'/ + /The transaction has operations that are not of type 'manageData'/, ); }); @@ -1180,21 +1180,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), name: "web_auth_domain", value: "unexpected_web_auth_domain", - }) + }), ) .setTimeout(30) .build(); @@ -1204,7 +1204,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(() => @@ -1213,11 +1213,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /'web_auth_domain' operation value does not match testanchor.stellar.org/ + /'web_auth_domain' operation value does not match testanchor.stellar.org/, ); }); @@ -1227,21 +1227,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "web_auth_domain", value: "testanchor.stellar.org", - }) + }), ) .setTimeout(30) .build(); @@ -1251,7 +1251,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect(() => @@ -1260,11 +1260,11 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are unrecognized/ + /The transaction has operations that are unrecognized/, ); }); @@ -1274,14 +1274,14 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .setTimeout(30) .build(); @@ -1291,7 +1291,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -1300,8 +1300,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -1316,21 +1316,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), name: "web_auth_domain", value: "auth.stellar.org", - }) + }), ) .setTimeout(30) .build(); @@ -1340,7 +1340,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -1349,8 +1349,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "auth.stellar.org" - ) + "auth.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -1365,21 +1365,21 @@ describe("Utils", function () { const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), name: "nonWebAuthDomainKey", value: null, - }) + }), ) .setTimeout(30) .build(); @@ -1389,7 +1389,7 @@ describe("Utils", function () { const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); expect( @@ -1398,8 +1398,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "auth.stellar.org" - ) + "auth.stellar.org", + ), ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), @@ -1416,21 +1416,21 @@ describe("Utils", function () { const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), name: "client_domain", value: "testdomain", - }) + }), ) .setTimeout(30) .build(); @@ -1443,7 +1443,7 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, "testanchor.stellar.org", - "testanchor.stellar.org" + "testanchor.stellar.org", ); }); }); @@ -1482,7 +1482,7 @@ describe("Utils", function () { it("throws an error if the server hasn't signed the transaction", function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts + this.txBuilderOpts, ) .addOperation(this.operation) .setTimeout(30) @@ -1503,11 +1503,11 @@ describe("Utils", function () { threshold, signerSummary, "SDF-test", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + this.serverKP.publicKey() + "'" + "Transaction not signed by server: '" + this.serverKP.publicKey() + "'", ); }); @@ -1518,14 +1518,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1); const signedChallenge = transaction @@ -1544,8 +1544,8 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP1.publicKey()]); }); @@ -1556,14 +1556,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction @@ -1585,8 +1585,8 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); @@ -1597,14 +1597,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction @@ -1627,8 +1627,8 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); @@ -1645,14 +1645,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction @@ -1678,8 +1678,8 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); @@ -1690,14 +1690,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction @@ -1720,11 +1720,11 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - `signers with weight 3 do not meet threshold ${threshold}"` + `signers with weight 3 do not meet threshold ${threshold}"`, ); }); @@ -1735,14 +1735,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2, this.clientKP3); const signedChallenge = transaction @@ -1764,11 +1764,11 @@ describe("Utils", function () { threshold, signerSummary, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction has unrecognized signatures/ + /Transaction has unrecognized signatures/, ); }); @@ -1779,14 +1779,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1, this.clientKP2, this.clientKP3); const signedChallenge = transaction @@ -1804,11 +1804,11 @@ describe("Utils", function () { threshold, [], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/ + /No verifiable client signers provided, at least one G... address must be provided/, ); }); }); @@ -1850,14 +1850,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1); @@ -1873,15 +1873,15 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP1.publicKey()]); }); it("throws an error if the server hasn't signed the transaction", function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts + this.txBuilderOpts, ) .addOperation(this.operation) .setTimeout(30) @@ -1901,11 +1901,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], "SDF-test", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + this.serverKP.publicKey() + "'" + "Transaction not signed by server: '" + this.serverKP.publicKey() + "'", ); }); @@ -1916,7 +1916,7 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); @@ -1928,11 +1928,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/ + /No verifiable client signers provided, at least one G... address must be provided/, ); }); @@ -1943,18 +1943,18 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign( StellarSdk.Keypair.random(), - StellarSdk.Keypair.random() + StellarSdk.Keypair.random(), ); const signedChallenge = transaction .toEnvelope() @@ -1968,11 +1968,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/ + /None of the given signers match the transaction signatures/, ); }); @@ -1983,14 +1983,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); const clientSigners = [this.clientKP1, this.clientKP2]; transaction.sign(...clientSigners); @@ -2008,8 +2008,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, clientSignersPubKey, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql(clientSignersPubKey); }); @@ -2020,14 +2020,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); const clientSigners = [this.clientKP1, this.clientKP2]; transaction.sign(...clientSigners.reverse()); @@ -2045,8 +2045,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, clientSignersPubKey, "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.have.same.members(clientSignersPubKey); }); @@ -2057,14 +2057,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2); @@ -2080,8 +2080,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP2.publicKey()]); }); @@ -2092,14 +2092,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2); @@ -2115,8 +2115,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), StellarSdk.Keypair.random().publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP2.publicKey()]); }); @@ -2127,14 +2127,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.serverKP); @@ -2150,11 +2150,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.serverKP.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/ + /None of the given signers match the transaction signatures/, ); }); @@ -2165,14 +2165,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2); @@ -2188,8 +2188,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.clientKP2.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP2.publicKey()]); }); @@ -2206,14 +2206,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2); @@ -2229,8 +2229,8 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), preauthTxHash, xHash, unknownSignerType], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.eql([this.clientKP2.publicKey()]); }); @@ -2241,14 +2241,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1); const signedChallenge = transaction @@ -2263,11 +2263,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.clientKP2.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/ + /None of the given signers match the transaction signatures/, ); }); @@ -2278,14 +2278,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2, this.clientKP2); @@ -2301,11 +2301,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction has unrecognized signatures/ + /Transaction has unrecognized signatures/, ); }); @@ -2316,14 +2316,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP2, this.clientKP2); @@ -2339,18 +2339,18 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [this.clientKP2.secret()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/ + /No verifiable client signers provided, at least one G... address must be provided/, ); }); it("throws an error if no client has signed the transaction", function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts + this.txBuilderOpts, ) .addOperation(this.operation) .setTimeout(30) @@ -2371,11 +2371,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, clientSigners, "SDF-test", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/ + /None of the given signers match the transaction signatures/, ); }); @@ -2386,14 +2386,14 @@ describe("Utils", function () { "SDF", 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org" + "testanchor.stellar.org", ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(this.clientKP1); @@ -2409,11 +2409,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/ + /No verifiable client signers provided, at least one G... address must be provided/, ); }); @@ -2430,14 +2430,14 @@ describe("Utils", function () { "testanchor.stellar.org", null, "testdomain", - clientSigningKey.publicKey() + clientSigningKey.publicKey(), ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(clientKP); @@ -2454,7 +2454,7 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [clientKP.publicKey()], "SDF", - "testanchor.stellar.org" + "testanchor.stellar.org", ); expect(signersFound.indexOf(clientSigningKey.publicKey())).to.eql(-1); @@ -2473,14 +2473,14 @@ describe("Utils", function () { "testanchor.stellar.org", null, "testdomain", - clientSigningKeypair.publicKey() + clientSigningKeypair.publicKey(), ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET + StellarSdk.Networks.TESTNET, ); transaction.sign(clientKP); @@ -2497,11 +2497,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [clientKP.publicKey()], "SDF", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction not signed by the source account of the 'client_domain' ManageData operation/ + /Transaction not signed by the source account of the 'client_domain' ManageData operation/, ); }); @@ -2514,28 +2514,28 @@ describe("Utils", function () { const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts + txBuilderOpts, ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), name: "testanchor.stellar.org auth", value: randomBytes(48).toString("base64"), - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), name: "client_domain", value: "testdomain", - }) + }), ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), name: "client_domain", value: "testdomain2", - }) + }), ) .setTimeout(30) .build(); @@ -2558,11 +2558,11 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, [clientKP.publicKey()], "testanchor.stellar.org", - "testanchor.stellar.org" - ) + "testanchor.stellar.org", + ), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Found more than one client_domain operation/ + /Found more than one client_domain operation/, ); }); }); @@ -2573,7 +2573,7 @@ describe("Utils", function () { this.account = new StellarSdk.Account(this.keypair.publicKey(), "-1"); this.transaction = new StellarSdk.TransactionBuilder( this.account, - txBuilderOpts + txBuilderOpts, ) .setTimeout(30) .build(); @@ -2589,8 +2589,8 @@ describe("Utils", function () { expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - this.keypair.publicKey() - ) + this.keypair.publicKey(), + ), ).to.eql(true); }); @@ -2602,8 +2602,8 @@ describe("Utils", function () { expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - differentKeypair.publicKey() - ) + differentKeypair.publicKey(), + ), ).to.eql(false); }); @@ -2611,8 +2611,8 @@ describe("Utils", function () { expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - this.keypair.publicKey() - ) + this.keypair.publicKey(), + ), ).to.eql(false); }); }); @@ -2624,7 +2624,7 @@ describe("Utils", function () { this.account = new StellarSdk.Account(this.keypair1.publicKey(), "-1"); this.transaction = new StellarSdk.TransactionBuilder( this.account, - txBuilderOpts + txBuilderOpts, ) .setTimeout(30) .build(); @@ -2642,7 +2642,7 @@ describe("Utils", function () { this.keypair2.publicKey(), ]; expect( - StellarSdk.Utils.gatherTxSigners(this.transaction, expectedSignatures) + StellarSdk.Utils.gatherTxSigners(this.transaction, expectedSignatures), ).to.eql(expectedSignatures); }); @@ -2653,7 +2653,7 @@ describe("Utils", function () { this.keypair1, this.keypair2, this.keypair2, - this.keypair2 + this.keypair2, ); const expectedSignatures = [ @@ -2664,7 +2664,7 @@ describe("Utils", function () { StellarSdk.Utils.gatherTxSigners(this.transaction, [ this.keypair1.publicKey(), this.keypair2.publicKey(), - ]) + ]), ).to.eql(expectedSignatures); }); @@ -2678,7 +2678,7 @@ describe("Utils", function () { ]; expect( - StellarSdk.Utils.gatherTxSigners(this.transaction, wrongSignatures) + StellarSdk.Utils.gatherTxSigners(this.transaction, wrongSignatures), ).to.eql([]); }); @@ -2687,7 +2687,7 @@ describe("Utils", function () { StellarSdk.Utils.gatherTxSigners(this.transaction, [ this.keypair1.publicKey(), this.keypair2.publicKey(), - ]) + ]), ).to.eql([]); }); @@ -2699,10 +2699,10 @@ describe("Utils", function () { StellarSdk.Utils.gatherTxSigners(this.transaction, [ preauthTxHash, this.keypair1.publicKey(), - ]) + ]), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Signer is not a valid address/ + /Signer is not a valid address/, ); }); @@ -2714,10 +2714,10 @@ describe("Utils", function () { StellarSdk.Utils.gatherTxSigners(this.transaction, [ invalidGHash, this.keypair1.publicKey(), - ]) + ]), ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Signer is not a valid address/ + /Signer is not a valid address/, ); }); }); diff --git a/yarn.lock b/yarn.lock index e4bd090f6..32952a99f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,7 +15,7 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@babel/cli@^7.22.6": +"@babel/cli@^7.22.9": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.22.9.tgz#501b3614aeda7399371f6d5991404f069b059986" integrity sha512-nb2O7AThqRo7/E53EGiuAkMaRbb7J5Qp3RvN+dmua1U+kydm0oznkhqbTEG15yk26G/C3yL6OdZjzgl+DMXVVA== @@ -43,7 +43,7 @@ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.22.9.tgz#71cdb00a1ce3a329ce4cbec3a44f9fef35669730" integrity sha512-5UamI7xkUcJ3i9qVDS+KFDEK8/7oJ55/sJMB1Ge7IEapr7KfdfV/HErR+koZwOfd+SgtFKOKRhRakdg++DcJpQ== -"@babel/core@^7.12.3", "@babel/core@^7.22.8", "@babel/core@^7.7.5": +"@babel/core@^7.12.3", "@babel/core@^7.22.9", "@babel/core@^7.7.5": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.22.9.tgz#bd96492c68822198f33e8a256061da3cf391f58f" integrity sha512-G2EgeufBcYw27U4hhoIwFcgc1XU7TlXJ3mv04oOv1WCuo900U/anZSPzEqNjwdjgffkk2Gs0AN0dW1CKVLcG7w== @@ -64,7 +64,7 @@ json5 "^2.2.2" semver "^6.3.1" -"@babel/eslint-parser@^7.22.7": +"@babel/eslint-parser@^7.22.9": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/eslint-parser/-/eslint-parser-7.22.9.tgz#75f8aa978d1e76c87cc6f26c1ea16ae58804d390" integrity sha512-xdMkt39/nviO/4vpVdrEYPwXCsYIXSSAr6mC7WQsNIlGnuxKyKE7GZjalcnbSWiC4OXGNNN3UQPeHfjSC6sTDA== @@ -73,7 +73,7 @@ eslint-visitor-keys "^2.1.0" semver "^6.3.1" -"@babel/eslint-plugin@^7.19.1": +"@babel/eslint-plugin@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/eslint-plugin/-/eslint-plugin-7.22.5.tgz#47407d8c9e527b62ff75ee11e4baa6de3da7cf0e" integrity sha512-lDXW06rf1sXywWWw+UdS/iYxRjrqhH4AXdPeKE4+fEgEoGBXcdIDQ+uCJOUcvCb0jCTvfwHOSXkwnfd24EAkLQ== @@ -861,7 +861,7 @@ "@babel/helper-create-regexp-features-plugin" "^7.22.5" "@babel/helper-plugin-utils" "^7.22.5" -"@babel/preset-env@^7.22.7": +"@babel/preset-env@^7.22.9": version "7.22.9" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.22.9.tgz#57f17108eb5dfd4c5c25a44c1977eba1df310ac7" integrity sha512-wNi5H/Emkhll/bqPjsjQorSykrlfY5OWakd6AulLvMEytpKasMVUpVy8RL4qBIBs5Ac6/5i0/Rv0b/Fg6Eag/g== @@ -958,7 +958,7 @@ "@babel/types" "^7.4.4" esutils "^2.0.2" -"@babel/preset-typescript@^7.21.4": +"@babel/preset-typescript@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.22.5.tgz#16367d8b01d640e9a507577ed4ee54e0101e51c8" integrity sha512-YbPaal9LxztSGhmndR46FmAbkJ/1fAsw293tSU+I5E5h+cnJ3d4GTwyUgGYmOXJYdGA+uNePle4qbaRzj2NISQ== @@ -969,7 +969,7 @@ "@babel/plugin-transform-modules-commonjs" "^7.22.5" "@babel/plugin-transform-typescript" "^7.22.5" -"@babel/register@^7.21.0": +"@babel/register@^7.22.5": version "7.22.5" resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.22.5.tgz#e4d8d0f615ea3233a27b5c6ada6750ee59559939" integrity sha512-vV6pm/4CijSQ8Y47RH5SopXzursN35RQINfGJkmOlcpAtGuf94miFvIPhCKGQN7WGIcsgG1BHEX2KVdTYwTwUQ== @@ -1038,27 +1038,27 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@definitelytyped/dts-critic@^0.0.163": - version "0.0.163" - resolved "https://registry.yarnpkg.com/@definitelytyped/dts-critic/-/dts-critic-0.0.163.tgz#51750eddefd781daf481f8e4d4d277b7bd51fc87" - integrity sha512-HsTvylj8x2gQaawsOCcN2Xk2Cx0wgV9kaj83hgsO9SITZSPd7dA0UkHyNRadbMkMwqNDKcnizcmWdz0+0gIo8A== +"@definitelytyped/dts-critic@^0.0.165": + version "0.0.165" + resolved "https://registry.yarnpkg.com/@definitelytyped/dts-critic/-/dts-critic-0.0.165.tgz#78900fa5a5c5f2bbd8e4cca718a6121c500d63af" + integrity sha512-A9SaTgIjRl4nEn8h4Zx6UsMroObkJfGAETo6QX42+V1Fs+fFlgR7q2btSa0YR9dxjtZ0gb9TL06vzA5LmSRp+g== dependencies: - "@definitelytyped/header-parser" "^0.0.163" + "@definitelytyped/header-parser" "^0.0.165" command-exists "^1.2.8" rimraf "^3.0.2" - semver "^6.2.0" + semver "^7.5.2" tmp "^0.2.1" yargs "^15.3.1" -"@definitelytyped/dtslint@^0.0.163": - version "0.0.163" - resolved "https://registry.yarnpkg.com/@definitelytyped/dtslint/-/dtslint-0.0.163.tgz#d31f7c01f2f829d69ab0b3c46801d5547860236d" - integrity sha512-U0uw7Zu0QdYSuBMYgxvRYjkhkeulTEg8vDgJ7TiYQUv/wODeujSAmGahQn51E5hOlSMYUw7A9utdbUukxE02SQ== +"@definitelytyped/dtslint@^0.0.165": + version "0.0.165" + resolved "https://registry.yarnpkg.com/@definitelytyped/dtslint/-/dtslint-0.0.165.tgz#f0997329fae909aaa5b10da2ee3030d66a7fe51e" + integrity sha512-q9WRDjZP8HxaSWAZIsfq8/G8GS2nLnHt5CqZkM2ZBmdTb+1toE3F0wQQBs7HPGJfIsx1XCW4zl0KC6Gpf4oxYg== dependencies: - "@definitelytyped/dts-critic" "^0.0.163" - "@definitelytyped/header-parser" "^0.0.163" - "@definitelytyped/typescript-versions" "^0.0.163" - "@definitelytyped/utils" "^0.0.163" + "@definitelytyped/dts-critic" "^0.0.165" + "@definitelytyped/header-parser" "^0.0.165" + "@definitelytyped/typescript-versions" "^0.0.165" + "@definitelytyped/utils" "^0.0.165" "@typescript-eslint/eslint-plugin" "^5.55.0" "@typescript-eslint/parser" "^5.55.0" "@typescript-eslint/types" "^5.56.0" @@ -1071,26 +1071,26 @@ tslint "5.14.0" yargs "^15.1.0" -"@definitelytyped/header-parser@^0.0.163": - version "0.0.163" - resolved "https://registry.yarnpkg.com/@definitelytyped/header-parser/-/header-parser-0.0.163.tgz#fdf5589a048e89b2a2adbd33d5d3d78ecd2a2ec6" - integrity sha512-Jr+/q+ESfc7uWldz/j11BfpjIN/gB4WmwhFENhWaMwM0W/9p0ShF+OiUqGhk2Q3Iz8v/oyWzSsxyxgasg9kCxQ== +"@definitelytyped/header-parser@^0.0.165": + version "0.0.165" + resolved "https://registry.yarnpkg.com/@definitelytyped/header-parser/-/header-parser-0.0.165.tgz#3a827312387d3426d645f4866b08d280ff9297af" + integrity sha512-UJkrgsNvY0qa2sbUdIcdT4P1iGi0MxvZ/TUB3psidyOAmqDbyPprlPbQwLp34k7NI+RQBRQogb8j4Dez4vRuLA== dependencies: - "@definitelytyped/typescript-versions" "^0.0.163" + "@definitelytyped/typescript-versions" "^0.0.165" "@types/parsimmon" "^1.10.1" parsimmon "^1.13.0" -"@definitelytyped/typescript-versions@^0.0.163": - version "0.0.163" - resolved "https://registry.yarnpkg.com/@definitelytyped/typescript-versions/-/typescript-versions-0.0.163.tgz#b3e018057a0437740102850de2c093c8cddd9e6f" - integrity sha512-+GWtJhC+7UaCUnJ+ZkA7bfGuPd6ZbJKEjbHqh76/gOXsqAUOMEa49ufsLlIPUbkEeQlnDNoTHCegE5X/Q+u+/A== +"@definitelytyped/typescript-versions@^0.0.165": + version "0.0.165" + resolved "https://registry.yarnpkg.com/@definitelytyped/typescript-versions/-/typescript-versions-0.0.165.tgz#462cf009fe097ce98a96455588256912127df734" + integrity sha512-aLAAhpNPWTSSxKL3B60z9NIxYqeU+K0OfjGDim8D4BlBn2EXBb43h5leQVb+w2YtIQhkUJAAN9bFYzp+beNf1g== -"@definitelytyped/utils@^0.0.163": - version "0.0.163" - resolved "https://registry.yarnpkg.com/@definitelytyped/utils/-/utils-0.0.163.tgz#1fb26bf5cf22a00c16924fcb115fe76a46817972" - integrity sha512-6MX5TxaQbG/j2RkCWbcbLvv+YNipKqY0eQJafDhwC/RprUocpg+uYVNlH8XzdKRWOGJ0pq7SZOsJD4C3A01ZXg== +"@definitelytyped/utils@^0.0.165": + version "0.0.165" + resolved "https://registry.yarnpkg.com/@definitelytyped/utils/-/utils-0.0.165.tgz#53785269aa4a9743a28810ab12ebb1aca33bd504" + integrity sha512-Bg4l1XLfuIb+4/S3AVO5ozFO7XMybxr5m+6FNVkw/HVt/IYiuwR5hDfm7FLlJHw1TYsF8AsIXIu3S9fRlrNntw== dependencies: - "@definitelytyped/typescript-versions" "^0.0.163" + "@definitelytyped/typescript-versions" "^0.0.165" "@qiwi/npm-registry-client" "^8.9.1" "@types/node" "^14.14.35" charm "^1.0.2" @@ -1116,6 +1116,11 @@ resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.5.1.tgz#cdd35dce4fa1a89a4fd42b1599eb35b3af408884" integrity sha512-Z5ba73P98O1KUYCCJTUeVpja9RcGoMdncZ6T49FCUl2lN38JtCJ+3WgIDBv0AuY4WChU5PmtJmOCTlN6FZTFKQ== +"@eslint-community/regexpp@^4.6.1": + version "4.6.2" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.6.2.tgz#1816b5f6948029c5eaacb0703b850ee0cb37d8f8" + integrity sha512-pPTNuaAG3QMH+buKyBIGJs3g/S5y0caxw0ygM3YyE6yJFySwiGGSzA+mM3KJ8QQvzeLh3blwgSonkFjgQdxzMw== + "@eslint/eslintrc@^2.1.0": version "2.1.0" resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.0.tgz#82256f164cc9e0b59669efc19d57f8092706841d" @@ -1131,11 +1136,31 @@ minimatch "^3.1.2" strip-json-comments "^3.1.1" +"@eslint/eslintrc@^2.1.1": + version "2.1.1" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-2.1.1.tgz#18d635e24ad35f7276e8a49d135c7d3ca6a46f93" + integrity sha512-9t7ZA7NGGK8ckelF0PQCfcxIUzs1Md5rrO6U/c+FIQNanea5UZC0wqKXH4vHBccmu4ZJgZ2idtPeW7+Q2npOEA== + dependencies: + ajv "^6.12.4" + debug "^4.3.2" + espree "^9.6.0" + globals "^13.19.0" + ignore "^5.2.0" + import-fresh "^3.2.1" + js-yaml "^4.1.0" + minimatch "^3.1.2" + strip-json-comments "^3.1.1" + "@eslint/js@8.44.0": version "8.44.0" resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.44.0.tgz#961a5903c74139390478bdc808bcde3fc45ab7af" integrity sha512-Ag+9YM4ocKQx9AarydN0KY2j0ErMHNIocPDrVo8zAE44xLTjEtz81OdR68/cydGtk6m6jDb5Za3r2useMzYmSw== +"@eslint/js@^8.46.0": + version "8.46.0" + resolved "https://registry.yarnpkg.com/@eslint/js/-/js-8.46.0.tgz#3f7802972e8b6fe3f88ed1aabc74ec596c456db6" + integrity sha512-a8TLtmPi8xzPkCbp/OGFUo5yhRkHM2Ko9kOWP4znJr0WAhWyThaw3PnwX4vOTWOAMsV2uRt32PPDcEz63esSaA== + "@humanwhocodes/config-array@^0.11.10": version "0.11.10" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.10.tgz#5a3ffe32cc9306365fb3fd572596cd602d5e12d2" @@ -1298,6 +1323,18 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" +"@pkgr/utils@^2.3.1": + version "2.4.2" + resolved "https://registry.yarnpkg.com/@pkgr/utils/-/utils-2.4.2.tgz#9e638bbe9a6a6f165580dc943f138fd3309a2cbc" + integrity sha512-POgTXhjrTfbTV63DiFXav4lBHiICLKKwDeaKn9Nphwj7WH6m0hMMCaJkMyRWjgtPFyRKRVoMXXjczsTQRDEhYw== + dependencies: + cross-spawn "^7.0.3" + fast-glob "^3.3.0" + is-glob "^4.0.3" + open "^9.1.0" + picocolors "^1.0.0" + tslib "^2.6.0" + "@qiwi/npm-registry-client@^8.9.1": version "8.9.1" resolved "https://registry.yarnpkg.com/@qiwi/npm-registry-client/-/npm-registry-client-8.9.1.tgz#1769f6501a436ec39c496ca0a9a2fab9db7718df" @@ -1474,10 +1511,10 @@ resolved "https://registry.yarnpkg.com/@types/linkify-it/-/linkify-it-3.0.2.tgz#fd2cd2edbaa7eaac7e7f3c1748b52a19143846c9" integrity sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA== -"@types/lodash@^4.14.192": - version "4.14.195" - resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.195.tgz#bafc975b252eb6cea78882ce8a7b6bf22a6de632" - integrity sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg== +"@types/lodash@^4.14.196": + version "4.14.196" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.196.tgz#a7c3d6fc52d8d71328b764e28e080b4169ec7a95" + integrity sha512-22y3o88f4a94mKljsZcanlNWPzO0uBsBdzLAngf2tp533LzZcQzb6+eZPJ+vCTt+bqF2XnvT9gejTLsAcJAJyQ== "@types/markdown-it@^12.2.3": version "12.2.3" @@ -1492,7 +1529,7 @@ resolved "https://registry.yarnpkg.com/@types/mdurl/-/mdurl-1.0.2.tgz#e2ce9d83a613bacf284c7be7d491945e39e1f8e9" integrity sha512-eC4U9MlIcu2q0KQmXszyn5Akca/0jrQmwDRgpAMJai7qBWq4amIQhZyNau4VYGtCeALvW1/NtjzJJ567aZxfKA== -"@types/node@*", "@types/node@>=10.0.0", "@types/node@^20.4.1": +"@types/node@*", "@types/node@>=10.0.0": version "20.4.1" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.1.tgz#a6033a8718653c50ac4962977e14d0f984d9527d" integrity sha512-JIzsAvJeA/5iY6Y/OxZbv1lUcc8dNSE77lb2gnBH+/PJ3lFR1Ccvgwl5JWnHAkNHcRsT0TbpVOsiMKZ1F/yyJg== @@ -1502,6 +1539,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.53.tgz#42855629b8773535ab868238718745bf56c56219" integrity sha512-soGmOpVBUq+gaBMwom1M+krC/NNbWlosh4AtGA03SyWNDiqSKtwp7OulO1M6+mg8YkHMvJ/y0AkCeO8d1hNb7A== +"@types/node@^20.4.2": + version "20.4.7" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.4.7.tgz#74d323a93f1391a63477b27b9aec56669c98b2ab" + integrity sha512-bUBrPjEry2QUTsnuEjzjbS7voGWCc30W0qzgMf90GPeDGFRakvrz47ju+oqDAKCXLUCe39u57/ORMl/O/04/9g== + "@types/parsimmon@^1.10.1": version "1.10.6" resolved "https://registry.yarnpkg.com/@types/parsimmon/-/parsimmon-1.10.6.tgz#8fcf95990514d2a7624aa5f630c13bf2427f9cdd" @@ -1560,7 +1602,7 @@ semver "^7.3.7" tsutils "^3.21.0" -"@typescript-eslint/parser@^5.55.0", "@typescript-eslint/parser@^5.59.7": +"@typescript-eslint/parser@^5.55.0": version "5.62.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.62.0.tgz#1b63d082d849a2fcae8a569248fbe2ee1b8a56c7" integrity sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA== @@ -1570,6 +1612,17 @@ "@typescript-eslint/typescript-estree" "5.62.0" debug "^4.3.4" +"@typescript-eslint/parser@^6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-6.2.1.tgz#e18a31eea1cca8841a565f1701960c8123ed07f9" + integrity sha512-Ld+uL1kYFU8e6btqBFpsHkwQ35rw30IWpdQxgOqOh4NfxSDH6uCkah1ks8R/RgQqI5hHPXMaLy9fbFseIe+dIg== + dependencies: + "@typescript-eslint/scope-manager" "6.2.1" + "@typescript-eslint/types" "6.2.1" + "@typescript-eslint/typescript-estree" "6.2.1" + "@typescript-eslint/visitor-keys" "6.2.1" + debug "^4.3.4" + "@typescript-eslint/scope-manager@5.62.0": version "5.62.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.62.0.tgz#d9457ccc6a0b8d6b37d0eb252a23022478c5460c" @@ -1578,6 +1631,14 @@ "@typescript-eslint/types" "5.62.0" "@typescript-eslint/visitor-keys" "5.62.0" +"@typescript-eslint/scope-manager@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.2.1.tgz#b6f43a867b84e5671fe531f2b762e0b68f7cf0c4" + integrity sha512-UCqBF9WFqv64xNsIEPfBtenbfodPXsJ3nPAr55mGPkQIkiQvgoWNo+astj9ZUfJfVKiYgAZDMnM6dIpsxUMp3Q== + dependencies: + "@typescript-eslint/types" "6.2.1" + "@typescript-eslint/visitor-keys" "6.2.1" + "@typescript-eslint/type-utils@5.62.0": version "5.62.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.62.0.tgz#286f0389c41681376cdad96b309cedd17d70346a" @@ -1593,6 +1654,11 @@ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.62.0.tgz#258607e60effa309f067608931c3df6fed41fd2f" integrity sha512-87NVngcbVXUahrRTqIK27gD2t5Cu1yuCXxbLcFtCzZGlfyVWWh8mLHkoxzjsB6DDNnvdL+fW8MiwPEJyGJQDgQ== +"@typescript-eslint/types@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.2.1.tgz#7fcdeceb503aab601274bf5e210207050d88c8ab" + integrity sha512-528bGcoelrpw+sETlyM91k51Arl2ajbNT9L4JwoXE2dvRe1yd8Q64E4OL7vHYw31mlnVsf+BeeLyAZUEQtqahQ== + "@typescript-eslint/typescript-estree@5.62.0", "@typescript-eslint/typescript-estree@^5.55.0": version "5.62.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.62.0.tgz#7d17794b77fabcac615d6a48fb143330d962eb9b" @@ -1606,6 +1672,19 @@ semver "^7.3.7" tsutils "^3.21.0" +"@typescript-eslint/typescript-estree@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.2.1.tgz#2af6e90c1e91cb725a5fe1682841a3f74549389e" + integrity sha512-G+UJeQx9AKBHRQBpmvr8T/3K5bJa485eu+4tQBxFq0KoT22+jJyzo1B50JDT9QdC1DEmWQfdKsa8ybiNWYsi0Q== + dependencies: + "@typescript-eslint/types" "6.2.1" + "@typescript-eslint/visitor-keys" "6.2.1" + debug "^4.3.4" + globby "^11.1.0" + is-glob "^4.0.3" + semver "^7.5.4" + ts-api-utils "^1.0.1" + "@typescript-eslint/utils@5.62.0", "@typescript-eslint/utils@^5.55.0": version "5.62.0" resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-5.62.0.tgz#141e809c71636e4a75daa39faed2fb5f4b10df86" @@ -1628,6 +1707,14 @@ "@typescript-eslint/types" "5.62.0" eslint-visitor-keys "^3.3.0" +"@typescript-eslint/visitor-keys@6.2.1": + version "6.2.1" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.2.1.tgz#442e7c09fe94b715a54ebe30e967987c3c41fbf4" + integrity sha512-iTN6w3k2JEZ7cyVdZJTVJx2Lv7t6zFA8DCrJEHD2mwfc16AEvvBWVhbFh34XyG2NORCd0viIgQY1+u7kPI0WpA== + dependencies: + "@typescript-eslint/types" "6.2.1" + eslint-visitor-keys "^3.4.1" + "@webassemblyjs/ast@1.11.6", "@webassemblyjs/ast@^1.11.5": version "1.11.6" resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.11.6.tgz#db046555d3c413f8966ca50a95176a0e2c642e24" @@ -1981,6 +2068,17 @@ array-union@^2.1.0: resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== +array.prototype.findlastindex@^1.2.2: + version "1.2.2" + resolved "https://registry.yarnpkg.com/array.prototype.findlastindex/-/array.prototype.findlastindex-1.2.2.tgz#bc229aef98f6bd0533a2bc61ff95209875526c9b" + integrity sha512-tb5thFFlUcp7NdNF6/MpDk/1r/4awWG1FIz3YqDf+/zJSTezBb+/5WViH41obXULHVpDzoiCLpJ/ZO9YbJMsdw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + es-shim-unscopables "^1.0.0" + get-intrinsic "^1.1.3" + array.prototype.flat@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/array.prototype.flat/-/array.prototype.flat-1.3.1.tgz#ffc6576a7ca3efc2f46a143b9d1dda9b4b3cf5e2" @@ -2001,6 +2099,18 @@ array.prototype.flatmap@^1.3.1: es-abstract "^1.20.4" es-shim-unscopables "^1.0.0" +arraybuffer.prototype.slice@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.1.tgz#9b5ea3868a6eebc30273da577eb888381c0044bb" + integrity sha512-09x0ZWFEjj4WD8PDbykUwo3t9arLn8NIzmmYEJFpYekOAQjpkGSyrQhNoRTcwwcFRu+ycWF78QZ63oWTqSjBcw== + dependencies: + array-buffer-byte-length "^1.0.0" + call-bind "^1.0.2" + define-properties "^1.2.0" + get-intrinsic "^1.2.1" + is-array-buffer "^3.0.2" + is-shared-array-buffer "^1.0.2" + asap@^2.0.0: version "2.0.6" resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" @@ -2094,7 +2204,7 @@ babel-code-frame@^6.22.0: esutils "^2.0.2" js-tokens "^3.0.2" -babel-loader@^9.1.3: +babel-loader@^9.1.2: version "9.1.3" resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-9.1.3.tgz#3d0e01b4e69760cc694ee306fe16d358aa1c6f9a" integrity sha512-xG3ST4DglodGf8qSwv0MdeWLhrDsw/32QMdTO5T1ZIp9gQur0HkCyFs7Awskr10JKXFXwpAhiCuYX5oGXnRGbw== @@ -2164,6 +2274,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +big-integer@^1.6.44: + version "1.6.51" + resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" + integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg== + bignumber.js@^9.1.1: version "9.1.1" resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6" @@ -2216,6 +2331,13 @@ body-parser@^1.19.0: type-is "~1.6.18" unpipe "1.0.0" +bplist-parser@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/bplist-parser/-/bplist-parser-0.2.0.tgz#43a9d183e5bf9d545200ceac3e712f79ebbe8d0e" + integrity sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw== + dependencies: + big-integer "^1.6.44" + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -2360,6 +2482,13 @@ builtins@^1.0.3: resolved "https://registry.yarnpkg.com/builtins/-/builtins-1.0.3.tgz#cb94faeb61c8696451db36534e1422f94f0aee88" integrity sha512-uYBjakWipfaO/bXI7E8rq6kpwHRZK5cNYrUv2OzZSI/FvmdMyXJ2tG9dKcjEC5YHmHpUAwsargWIZNWdxb/bnQ== +bundle-name@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/bundle-name/-/bundle-name-3.0.0.tgz#ba59bcc9ac785fb67ccdbf104a2bf60c099f0e1a" + integrity sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw== + dependencies: + run-applescript "^5.0.0" + bytes@3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/bytes/-/bytes-3.1.2.tgz#8b0beeb98605adf1b128fa4386403c009e0221a5" @@ -2422,7 +2551,7 @@ chai-as-promised@^7.1.1: dependencies: check-error "^1.0.2" -chai-http@^4.3.0: +chai-http@^4.4.0: version "4.4.0" resolved "https://registry.yarnpkg.com/chai-http/-/chai-http-4.4.0.tgz#bb8c346caa25b3c76118c68f7a7cecc0493669b8" integrity sha512-uswN3rZpawlRaa5NiDUHcDZ3v2dw5QgLyAwnQ2tnVNuP7CwIsOFuYJ0xR1WiR7ymD4roBnJIzOUep7w9jQMFJA== @@ -2904,6 +3033,24 @@ deep-is@^0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.4.tgz#a6f2dce612fadd2ef1f519b73551f17e85199831" integrity sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ== +default-browser-id@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/default-browser-id/-/default-browser-id-3.0.0.tgz#bee7bbbef1f4e75d31f98f4d3f1556a14cea790c" + integrity sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA== + dependencies: + bplist-parser "^0.2.0" + untildify "^4.0.0" + +default-browser@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/default-browser/-/default-browser-4.0.0.tgz#53c9894f8810bf86696de117a6ce9085a3cbc7da" + integrity sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA== + dependencies: + bundle-name "^3.0.0" + default-browser-id "^3.0.0" + execa "^7.1.1" + titleize "^3.0.0" + default-require-extensions@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-3.0.1.tgz#bfae00feeaeada68c2ae256c62540f60b80625bd" @@ -2911,6 +3058,11 @@ default-require-extensions@^3.0.0: dependencies: strip-bom "^4.0.0" +define-lazy-prop@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz#dbb19adfb746d7fc6d734a06b72f4a00d021255f" + integrity sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg== + define-properties@^1.1.3, define-properties@^1.1.4, define-properties@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/define-properties/-/define-properties-1.2.0.tgz#52988570670c9eacedd8064f4a990f2405849bd5" @@ -2947,6 +3099,11 @@ destroy@1.2.0: resolved "https://registry.yarnpkg.com/destroy/-/destroy-1.2.0.tgz#4803735509ad8be552934c67df614f94e66fa015" integrity sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg== +detect-node@^2.0.4: + version "2.1.0" + resolved "https://registry.yarnpkg.com/detect-node/-/detect-node-2.1.0.tgz#c9c70775a49c3d03bc2c06d9a73be550f978f8b1" + integrity sha512-T0NIuQpnTvFDATNuHN5roPwSBG83rFsuO+MXXH9/3N1eFbn4wcPjttvjMLEPWJ0RGUYgQE7cGgS3tNxbqCGM7g== + dezalgo@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/dezalgo/-/dezalgo-1.0.4.tgz#751235260469084c132157dfa857f386d4c33d81" @@ -3167,6 +3324,51 @@ es-abstract@^1.19.0, es-abstract@^1.20.4: unbox-primitive "^1.0.2" which-typed-array "^1.1.9" +es-abstract@^1.21.2: + version "1.22.1" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.22.1.tgz#8b4e5fc5cefd7f1660f0f8e1a52900dfbc9d9ccc" + integrity sha512-ioRRcXMO6OFyRpyzV3kE1IIBd4WG5/kltnzdxSCqoP8CMGs/Li+M1uF5o7lOkZVFjDs+NLesthnF66Pg/0q0Lw== + dependencies: + array-buffer-byte-length "^1.0.0" + arraybuffer.prototype.slice "^1.0.1" + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + es-set-tostringtag "^2.0.1" + es-to-primitive "^1.2.1" + function.prototype.name "^1.1.5" + get-intrinsic "^1.2.1" + get-symbol-description "^1.0.0" + globalthis "^1.0.3" + gopd "^1.0.1" + has "^1.0.3" + has-property-descriptors "^1.0.0" + has-proto "^1.0.1" + has-symbols "^1.0.3" + internal-slot "^1.0.5" + is-array-buffer "^3.0.2" + is-callable "^1.2.7" + is-negative-zero "^2.0.2" + is-regex "^1.1.4" + is-shared-array-buffer "^1.0.2" + is-string "^1.0.7" + is-typed-array "^1.1.10" + is-weakref "^1.0.2" + object-inspect "^1.12.3" + object-keys "^1.1.1" + object.assign "^4.1.4" + regexp.prototype.flags "^1.5.0" + safe-array-concat "^1.0.0" + safe-regex-test "^1.0.0" + string.prototype.trim "^1.2.7" + string.prototype.trimend "^1.0.6" + string.prototype.trimstart "^1.0.6" + typed-array-buffer "^1.0.0" + typed-array-byte-length "^1.0.0" + typed-array-byte-offset "^1.0.0" + typed-array-length "^1.0.4" + unbox-primitive "^1.0.2" + which-typed-array "^1.1.10" + es-module-lexer@^1.2.1: version "1.3.0" resolved "https://registry.yarnpkg.com/es-module-lexer/-/es-module-lexer-1.3.0.tgz#6be9c9e0b4543a60cd166ff6f8b4e9dae0b0c16f" @@ -3242,10 +3444,10 @@ eslint-config-airbnb-base@^15.0.0: object.entries "^1.1.5" semver "^6.3.0" -eslint-config-prettier@^8.8.0: - version "8.8.0" - resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.8.0.tgz#bfda738d412adc917fd7b038857110efe98c9348" - integrity sha512-wLbQiFre3tdGgpDv67NQKnJuTlcUVYHas3k+DZCc2U2BadthoEY4B7hLPvAxaqdyOGCzuLfii2fqGph10va7oA== +eslint-config-prettier@^8.10.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-8.10.0.tgz#3a06a662130807e2502fc3ff8b4143d8a0658e11" + integrity sha512-SM8AMJdeQqRYT9O9zguiruQZaN7+z+E4eAP9oiLNGKMtomwaB1E9dcgUD6ZAn/eQAb52USbvezbiljfZUhbJcg== eslint-import-resolver-node@^0.3.7: version "0.3.7" @@ -3256,7 +3458,7 @@ eslint-import-resolver-node@^0.3.7: is-core-module "^2.11.0" resolve "^1.22.1" -eslint-module-utils@^2.7.4: +eslint-module-utils@^2.8.0: version "2.8.0" resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.8.0.tgz#e439fee65fc33f6bba630ff621efc38ec0375c49" integrity sha512-aWajIYfsqCKRDgUfjEXNN/JlrzauMuSEy5sbd7WXbtW3EH6A6MpwEh42c7qD+MqQo9QMJ6fWLAeIJynx0g6OAw== @@ -3271,26 +3473,29 @@ eslint-plugin-es@^3.0.0: eslint-utils "^2.0.0" regexpp "^3.0.0" -eslint-plugin-import@^2.25.2: - version "2.27.5" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.27.5.tgz#876a6d03f52608a3e5bb439c2550588e51dd6c65" - integrity sha512-LmEt3GVofgiGuiE+ORpnvP+kAm3h6MLZJ4Q5HCyHADofsb4VzXFsRiWj3c0OFiV+3DWFh0qg3v9gcPlfc3zRow== +eslint-plugin-import@^2.28.0: + version "2.28.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.28.0.tgz#8d66d6925117b06c4018d491ae84469eb3cb1005" + integrity sha512-B8s/n+ZluN7sxj9eUf7/pRFERX0r5bnFA2dCaLHy2ZeaQEAz0k+ZZkFWRFHJAqxfxQDx6KLv9LeIki7cFdwW+Q== dependencies: array-includes "^3.1.6" + array.prototype.findlastindex "^1.2.2" array.prototype.flat "^1.3.1" array.prototype.flatmap "^1.3.1" debug "^3.2.7" doctrine "^2.1.0" eslint-import-resolver-node "^0.3.7" - eslint-module-utils "^2.7.4" + eslint-module-utils "^2.8.0" has "^1.0.3" - is-core-module "^2.11.0" + is-core-module "^2.12.1" is-glob "^4.0.3" minimatch "^3.1.2" + object.fromentries "^2.0.6" + object.groupby "^1.0.0" object.values "^1.1.6" - resolve "^1.22.1" - semver "^6.3.0" - tsconfig-paths "^3.14.1" + resolve "^1.22.3" + semver "^6.3.1" + tsconfig-paths "^3.14.2" eslint-plugin-node@^11.1.0: version "11.1.0" @@ -3309,12 +3514,13 @@ eslint-plugin-prefer-import@^0.0.1: resolved "https://registry.yarnpkg.com/eslint-plugin-prefer-import/-/eslint-plugin-prefer-import-0.0.1.tgz#0df4e117da29109ef561d355ec19f41df0ada6f6" integrity sha512-2OKD3Bjgqkn0BvEGRwpEDhjXPSXvT3CXmWIrIavwafOkQE8FLTvFybEBT9dm7P0kHnjlNGv1AfNsL/i/GNDNHA== -eslint-plugin-prettier@^4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-4.2.1.tgz#651cbb88b1dab98bfd42f017a12fa6b2d993f94b" - integrity sha512-f/0rXLXUt0oFYs8ra4w49wYZBG5GKZpAYsJSm6rnYL5uVDjd+zowwMwVZHnAjf4edNrKpCDYfXDgmRE/Ak7QyQ== +eslint-plugin-prettier@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz#6887780ed95f7708340ec79acfdf60c35b9be57a" + integrity sha512-AgaZCVuYDXHUGxj/ZGu1u8H8CYgDY3iG6w5kUFw4AzMVXzB7VvbKgYR4nATIN+OvUrghMbiDLeimVjVY5ilq3w== dependencies: prettier-linter-helpers "^1.0.0" + synckit "^0.8.5" eslint-rule-composer@^0.3.0: version "0.3.0" @@ -3337,6 +3543,14 @@ eslint-scope@^7.2.0: esrecurse "^4.3.0" estraverse "^5.2.0" +eslint-scope@^7.2.2: + version "7.2.2" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-7.2.2.tgz#deb4f92563390f32006894af62a22dba1c46423f" + integrity sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg== + dependencies: + esrecurse "^4.3.0" + estraverse "^5.2.0" + eslint-utils@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/eslint-utils/-/eslint-utils-2.1.0.tgz#d2de5e03424e707dc10c74068ddedae708741b27" @@ -3359,6 +3573,11 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.1.tgz#c22c48f48942d08ca824cc526211ae400478a994" integrity sha512-pZnmmLwYzf+kWaM/Qgrvpen51upAktaaiI01nsJD/Yr3lMOdNtq0cxkrrg16w64VtisN6okbs7Q8AfGqj4c9fA== +eslint-visitor-keys@^3.4.2: + version "3.4.2" + resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.2.tgz#8c2095440eca8c933bedcadf16fefa44dbe9ba5f" + integrity sha512-8drBzUEyZ2llkpCA67iYrgEssKDUu68V8ChqqOfFupIaG/LCVPUT+CoGJpT77zJprs4T/W7p07LP7zAIMuweVw== + eslint-webpack-plugin@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/eslint-webpack-plugin/-/eslint-webpack-plugin-4.0.1.tgz#f0f0e9afff2801d8bd41eac88e5409821ecbaccb" @@ -3370,7 +3589,7 @@ eslint-webpack-plugin@^4.0.1: normalize-path "^3.0.0" schema-utils "^4.0.0" -eslint@^8.17.0, eslint@^8.44.0: +eslint@^8.17.0: version "8.44.0" resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.44.0.tgz#51246e3889b259bbcd1d7d736a0c10add4f0e500" integrity sha512-0wpHoUbDUHgNCyvFB5aXLiQVfK9B0at6gUvzy83k4kAsQ/u769TQDX6iKC+aO4upIHO9WSaA3QoXYQDHbNwf1A== @@ -3415,6 +3634,49 @@ eslint@^8.17.0, eslint@^8.44.0: strip-json-comments "^3.1.0" text-table "^0.2.0" +eslint@^8.45.0: + version "8.46.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.46.0.tgz#a06a0ff6974e53e643acc42d1dcf2e7f797b3552" + integrity sha512-cIO74PvbW0qU8e0mIvk5IV3ToWdCq5FYG6gWPHHkx6gNdjlbAYvtfHmlCMXxjcoVaIdwy/IAt3+mDkZkfvb2Dg== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.6.1" + "@eslint/eslintrc" "^2.1.1" + "@eslint/js" "^8.46.0" + "@humanwhocodes/config-array" "^0.11.10" + "@humanwhocodes/module-importer" "^1.0.1" + "@nodelib/fs.walk" "^1.2.8" + ajv "^6.12.4" + chalk "^4.0.0" + cross-spawn "^7.0.2" + debug "^4.3.2" + doctrine "^3.0.0" + escape-string-regexp "^4.0.0" + eslint-scope "^7.2.2" + eslint-visitor-keys "^3.4.2" + espree "^9.6.1" + esquery "^1.4.2" + esutils "^2.0.2" + fast-deep-equal "^3.1.3" + file-entry-cache "^6.0.1" + find-up "^5.0.0" + glob-parent "^6.0.2" + globals "^13.19.0" + graphemer "^1.4.0" + ignore "^5.2.0" + imurmurhash "^0.1.4" + is-glob "^4.0.0" + is-path-inside "^3.0.3" + js-yaml "^4.1.0" + json-stable-stringify-without-jsonify "^1.0.1" + levn "^0.4.1" + lodash.merge "^4.6.2" + minimatch "^3.1.2" + natural-compare "^1.4.0" + optionator "^0.9.3" + strip-ansi "^6.0.1" + text-table "^0.2.0" + espree@^9.6.0: version "9.6.0" resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.0.tgz#80869754b1c6560f32e3b6929194a3fe07c5b82f" @@ -3424,6 +3686,15 @@ espree@^9.6.0: acorn-jsx "^5.3.2" eslint-visitor-keys "^3.4.1" +espree@^9.6.1: + version "9.6.1" + resolved "https://registry.yarnpkg.com/espree/-/espree-9.6.1.tgz#a2a17b8e434690a5432f2f8018ce71d331a48c6f" + integrity sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ== + dependencies: + acorn "^8.9.0" + acorn-jsx "^5.3.2" + eslint-visitor-keys "^3.4.1" + esprima@^4.0.0: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" @@ -3486,6 +3757,21 @@ evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: md5.js "^1.3.4" safe-buffer "^5.1.1" +execa@^5.0.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" + is-stream "^2.0.0" + merge-stream "^2.0.0" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" + strip-final-newline "^2.0.0" + execa@^7.0.0: version "7.1.1" resolved "https://registry.yarnpkg.com/execa/-/execa-7.1.1.tgz#3eb3c83d239488e7b409d48e8813b76bb55c9c43" @@ -3501,6 +3787,21 @@ execa@^7.0.0: signal-exit "^3.0.7" strip-final-newline "^3.0.0" +execa@^7.1.1: + version "7.2.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-7.2.0.tgz#657e75ba984f42a70f38928cedc87d6f2d4fe4e9" + integrity sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA== + dependencies: + cross-spawn "^7.0.3" + get-stream "^6.0.1" + human-signals "^4.3.0" + is-stream "^3.0.0" + merge-stream "^2.0.0" + npm-run-path "^5.1.0" + onetime "^6.0.0" + signal-exit "^3.0.7" + strip-final-newline "^3.0.0" + extend@^3.0.0, extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" @@ -3537,6 +3838,17 @@ fast-glob@^3.2.9: merge2 "^1.3.0" micromatch "^4.0.4" +fast-glob@^3.3.0: + version "3.3.1" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.3.1.tgz#784b4e897340f3dbbef17413b3f11acf03c874c4" + integrity sha512-kNFPyjhh5cKjrUltxs+wFx+ZkbRaxxmZ+X0ZU31SOsxCEtP9VPgtq2teZw1DebupL5GmDaNQ6yKMMVcM41iqDg== + dependencies: + "@nodelib/fs.stat" "^2.0.2" + "@nodelib/fs.walk" "^1.2.3" + glob-parent "^5.1.2" + merge2 "^1.3.0" + micromatch "^4.0.4" + fast-json-stable-stringify@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" @@ -3841,7 +4153,7 @@ get-func-name@^2.0.0: resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41" integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0: +get-intrinsic@^1.0.2, get-intrinsic@^1.1.1, get-intrinsic@^1.1.3, get-intrinsic@^1.2.0, get-intrinsic@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.2.1.tgz#d295644fed4505fc9cde952c37ee12b477a83d82" integrity sha512-2DcsyfABl+gVHEfCOaTrWgyt+tb6MSEGmKq+kI5HwLbIYgjgmMcV8KQ41uaKz1xxUcn9tJtgFbQUEVcEbd0FYw== @@ -3856,7 +4168,7 @@ get-package-type@^0.1.0: resolved "https://registry.yarnpkg.com/get-package-type/-/get-package-type-0.1.0.tgz#8de2d803cff44df3bc6c456e6668b36c3926e11a" integrity sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q== -get-stream@^6.0.1: +get-stream@^6.0.0, get-stream@^6.0.1: version "6.0.1" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== @@ -4145,6 +4457,11 @@ https-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha512-J+FkSdyD+0mA0N+81tMotaRMfSL9SGi+xpD3T6YApKsc3bGSXJlfXri3VyFOeYkfLRQisDk1W+jIFFKBeUBbBg== +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== + human-signals@^4.3.0: version "4.3.1" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-4.3.1.tgz#ab7f811e851fca97ffbd2c1fe9a958964de321b2" @@ -4279,7 +4596,7 @@ is-callable@^1.1.3, is-callable@^1.1.4, is-callable@^1.2.7: resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.7.tgz#3bc2a85ea742d9e36205dcacdd72ca1fdc51b055" integrity sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA== -is-core-module@^2.11.0, is-core-module@^2.5.0: +is-core-module@^2.11.0, is-core-module@^2.12.0, is-core-module@^2.12.1, is-core-module@^2.5.0: version "2.12.1" resolved "https://registry.yarnpkg.com/is-core-module/-/is-core-module-2.12.1.tgz#0c0b6885b6f80011c71541ce15c8d66cf5a4f9fd" integrity sha512-Q4ZuBAe2FUsKtyQJoQHlvP8OvBERxO3jEmy1I7hcRXcJBGGHFh/aJBswbXuS9sgrDH2QUO8ilkwNPHvHMd8clg== @@ -4298,6 +4615,11 @@ is-docker@^2.0.0: resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-2.2.1.tgz#33eeabe23cfe86f14bde4408a02c0cfb853acdaa" integrity sha512-F+i2BKsFrH66iaUFc0woD8sLy8getkwTwtOBjvs56Cx4CgJDeKQeqfz8wAYiSb8JOprWhHH5p77PbmYCvvUuXQ== +is-docker@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-docker/-/is-docker-3.0.0.tgz#90093aa3106277d8a77a5910dbae71747e15a200" + integrity sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ== + is-extglob@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" @@ -4334,6 +4656,13 @@ is-glob@^4.0.0, is-glob@^4.0.1, is-glob@^4.0.3, is-glob@~4.0.1: dependencies: is-extglob "^2.1.1" +is-inside-container@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-inside-container/-/is-inside-container-1.0.0.tgz#e81fba699662eb31dbdaf26766a61d4814717ea4" + integrity sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA== + dependencies: + is-docker "^3.0.0" + is-ip@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-ip/-/is-ip-2.0.0.tgz#68eea07e8a0a0a94c2d080dd674c731ab2a461ab" @@ -4467,6 +4796,11 @@ isarray@0.0.1: resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" integrity sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ== +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -4604,10 +4938,10 @@ js-tokens@^4.0.0: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== -js-xdr@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/js-xdr/-/js-xdr-2.0.0.tgz#ef24ea27369ab60217c001fd0e27301f6981ba0a" - integrity sha512-4mctWHR47ejNcfpE8/Xl3l2wYqO1Qy09d1pveZRmarUz2BcuU/M8grzadxV6PoN/X0ywOb6cy6117qYUWkfeBA== +js-xdr@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/js-xdr/-/js-xdr-3.0.0.tgz#fb74275de0ed3cec61269721140a576edf6fca7e" + integrity sha512-tSt6UKJ2L7t+yaQURGkHo9kop9qnVbChTlCu62zNiDbDZQoZb/YjUj2iFJ3lgelhfg9p5bhO2o/QX+g36TPsSQ== js-yaml@4.1.0, js-yaml@^4.1.0: version "4.1.0" @@ -4796,7 +5130,7 @@ karma-webpack@^5.0.0: minimatch "^3.0.4" webpack-merge "^4.1.5" -karma@^6.4.1: +karma@^6.4.2: version "6.4.2" resolved "https://registry.yarnpkg.com/karma/-/karma-6.4.2.tgz#a983f874cee6f35990c4b2dcc3d274653714de8e" integrity sha512-C6SU/53LB31BEgRg+omznBEMY4SjHU3ricV6zBcAe1EeILKkeScr+fZXtaI5WyDbkVowJxxAI6h73NcFPmXolQ== @@ -5356,6 +5690,13 @@ normalize-path@^3.0.0, normalize-path@~3.0.0: semver "^7.3.4" validate-npm-package-name "^3.0.0" +npm-run-path@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" + integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== + dependencies: + path-key "^3.0.0" + npm-run-path@^5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-5.1.0.tgz#bc62f7f3f6952d9894bd08944ba011a6ee7b7e00" @@ -5458,6 +5799,25 @@ object.entries@^1.1.5: define-properties "^1.1.4" es-abstract "^1.20.4" +object.fromentries@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.6.tgz#cdb04da08c539cffa912dcd368b886e0904bfa73" + integrity sha512-VciD13dswC4j1Xt5394WR4MzmAQmlgN72phd/riNp9vtD7tp4QQWJ0R4wvclXcafgcYK8veHRed2W6XeGBvcfg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.4" + es-abstract "^1.20.4" + +object.groupby@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/object.groupby/-/object.groupby-1.0.0.tgz#cb29259cf90f37e7bac6437686c1ea8c916d12a9" + integrity sha512-70MWG6NfRH9GnbZOikuhPPYzpUpof9iW2J9E4dW7FXTqPNb6rllE6u39SKwwiNh8lCwX3DDb5OgcKGiEBrTTyw== + dependencies: + call-bind "^1.0.2" + define-properties "^1.2.0" + es-abstract "^1.21.2" + get-intrinsic "^1.2.1" + object.values@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.6.tgz#4abbaa71eba47d63589d402856f908243eea9b1d" @@ -5488,7 +5848,7 @@ once@^1.3.0, once@^1.4.0: dependencies: wrappy "1" -onetime@^5.1.0: +onetime@^5.1.0, onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== @@ -5502,6 +5862,16 @@ onetime@^6.0.0: dependencies: mimic-fn "^4.0.0" +open@^9.1.0: + version "9.1.0" + resolved "https://registry.yarnpkg.com/open/-/open-9.1.0.tgz#684934359c90ad25742f5a26151970ff8c6c80b6" + integrity sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg== + dependencies: + default-browser "^4.0.0" + define-lazy-prop "^3.0.0" + is-inside-container "^1.0.0" + is-wsl "^2.2.0" + opt-cli@1.5.1: version "1.5.1" resolved "https://registry.yarnpkg.com/opt-cli/-/opt-cli-1.5.1.tgz#04db447b13c96b992eb31685266f4ed0d9736dc2" @@ -5665,7 +6035,7 @@ path-is-absolute@^1.0.0: resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg== -path-key@^3.1.0: +path-key@^3.0.0, path-key@^3.1.0: version "3.1.1" resolved "https://registry.yarnpkg.com/path-key/-/path-key-3.1.1.tgz#581f6ade658cbba65a0d3380de7753295054f375" integrity sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q== @@ -5771,10 +6141,10 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.8.7: - version "2.8.8" - resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da" - integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q== +prettier@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.1.tgz#65271fc9320ce4913c57747a70ce635b30beaa40" + integrity sha512-fcOWSnnpCrovBsmFZIGIy9UqK2FaI7Hqax+DIO0A9UxeVoY4iweyaFjS5TavZN97Hfehph0nhsZnjlVKzEQSrQ== process-nextick-args@~2.0.0: version "2.0.1" @@ -5960,7 +6330,7 @@ regenerator-transform@^0.15.1: dependencies: "@babel/runtime" "^7.8.4" -regexp.prototype.flags@^1.4.3: +regexp.prototype.flags@^1.4.3, regexp.prototype.flags@^1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.5.0.tgz#fe7ce25e7e4cca8db37b6634c8a2c7009199b9cb" integrity sha512-0SutC3pNudRKgquxGoRGIz946MZVHqbNfPjBdxeOhBrdgDKlRoXmYLQN9xRbrR09ZXWeGAdPuif7egofn6v5LA== @@ -6079,6 +6449,15 @@ resolve@^1.10.1, resolve@^1.14.2, resolve@^1.20.0, resolve@^1.22.1, resolve@^1.3 path-parse "^1.0.7" supports-preserve-symlinks-flag "^1.0.0" +resolve@^1.22.3: + version "1.22.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.3.tgz#4b4055349ffb962600972da1fdc33c46a4eb3283" + integrity sha512-P8ur/gp/AmbEzjr729bZnLjXK5Z+4P0zhIJgBgzqRih7hL7BOukHGtSTA3ACMY467GRFz3duQsi0bDZdR7DKdw== + dependencies: + is-core-module "^2.12.0" + path-parse "^1.0.7" + supports-preserve-symlinks-flag "^1.0.0" + restore-cursor@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-3.1.0.tgz#39f67c54b3a7a58cea5236d95cf0034239631f7e" @@ -6124,6 +6503,13 @@ ripemd160@^2.0.0, ripemd160@^2.0.1: hash-base "^3.0.0" inherits "^2.0.1" +run-applescript@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/run-applescript/-/run-applescript-5.0.0.tgz#e11e1c932e055d5c6b40d98374e0268d9b11899c" + integrity sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg== + dependencies: + execa "^5.0.0" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" @@ -6138,6 +6524,16 @@ rxjs@^7.8.0: dependencies: tslib "^2.1.0" +safe-array-concat@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/safe-array-concat/-/safe-array-concat-1.0.0.tgz#2064223cba3c08d2ee05148eedbc563cd6d84060" + integrity sha512-9dVEFruWIsnie89yym+xWTAYASdpw3CJV7Li/6zBewGf9z2i1j31rP6jnY0pHEO4QZh6N0K11bFjWmdR8UGdPQ== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.0" + has-symbols "^1.0.3" + isarray "^2.0.5" + safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@^5.2.1, safe-buffer@~5.2.0: version "5.2.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" @@ -6181,7 +6577,7 @@ schema-utils@^4.0.0: ajv-formats "^2.1.1" ajv-keywords "^5.1.0" -"semver@2 >=2.2.1 || 3.x || 4 || 5 || 7", semver@^7.3.4, semver@^7.3.7, semver@^7.3.8: +"semver@2 >=2.2.1 || 3.x || 4 || 5 || 7", semver@^7.3.4, semver@^7.3.7, semver@^7.3.8, semver@^7.5.2, semver@^7.5.4: version "7.5.4" resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== @@ -6193,7 +6589,7 @@ semver@^5.3.0, semver@^5.6.0: resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.2.tgz#48d55db737c3287cd4835e17fa13feace1c41ef8" integrity sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g== -semver@^6.0.0, semver@^6.1.0, semver@^6.2.0, semver@^6.3.0, semver@^6.3.1: +semver@^6.0.0, semver@^6.1.0, semver@^6.3.0, semver@^6.3.1: version "6.3.1" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4" integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA== @@ -6263,7 +6659,7 @@ side-channel@^1.0.4: get-intrinsic "^1.0.2" object-inspect "^1.9.0" -signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.7: +signal-exit@^3.0.0, signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7: version "3.0.7" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9" integrity sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ== @@ -6459,15 +6855,15 @@ statuses@~1.5.0: resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA== -stellar-base@^9.0.0: - version "9.0.0" - resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-9.0.0.tgz#af29349e011ee88657d9a62534388b50b3002d88" - integrity sha512-rnc0P28C2TlDoKpiL/Xw+4DyNqZ+hLxfcXub9gOH3FyPnGTr7QbGBiP0gYnRAndPp6xzX1F+hcCcPl31ce47/w== +stellar-base@10.0.0-soroban.5: + version "10.0.0-soroban.5" + resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-10.0.0-soroban.5.tgz#bf12f3a947ac15fa22a61121a705e80ee7eb4834" + integrity sha512-4gASMPVftdtuG4JqrRVgjjUyy/gIzv3FTJxR9Y8jfYi7KaduXn5YwaNjRC3UABlScqh2G1ax5+7NFkHhZXg5oA== dependencies: base32.js "^0.1.0" bignumber.js "^9.1.1" - crypto-browserify "^3.12.0" - js-xdr "^2.0.0" + buffer "^6.0.3" + js-xdr "^3.0.0" sha.js "^2.3.6" tweetnacl "^1.0.3" optionalDependencies: @@ -6604,6 +7000,11 @@ strip-bom@^4.0.0: resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-4.0.0.tgz#9c3505c1db45bcedca3d9cf7a16f5c5aa3901878" integrity sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w== +strip-final-newline@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-2.0.0.tgz#89b852fb2fcbe936f6f4b3187afb0a12c1ab58ad" + integrity sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA== + strip-final-newline@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/strip-final-newline/-/strip-final-newline-3.0.0.tgz#52894c313fbff318835280aed60ff71ebf12b8fd" @@ -6666,6 +7067,14 @@ supports-preserve-symlinks-flag@^1.0.0: resolved "https://registry.yarnpkg.com/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz#6eda4bd344a3c94aea376d4cc31bc77311039e09" integrity sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w== +synckit@^0.8.5: + version "0.8.5" + resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.8.5.tgz#b7f4358f9bb559437f9f167eb6bc46b3c9818fa3" + integrity sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q== + dependencies: + "@pkgr/utils" "^2.3.1" + tslib "^2.5.0" + taffydb@^2.7.3: version "2.7.3" resolved "https://registry.yarnpkg.com/taffydb/-/taffydb-2.7.3.tgz#2ad37169629498fca5bc84243096d3cde0ec3a34" @@ -6699,7 +7108,7 @@ tar@^6.1.11: mkdirp "^1.0.3" yallist "^4.0.0" -terser-webpack-plugin@^5.3.7, terser-webpack-plugin@^5.3.9: +terser-webpack-plugin@^5.3.7, terser-webpack-plugin@^5.3.8: version "5.3.9" resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-5.3.9.tgz#832536999c51b46d468067f9e37662a3b96adfe1" integrity sha512-ZuXsqE07EcggTWQjXUj+Aot/OMcD0bMKGgF63f7UxYcu5/AJF53aIpK1YoP5xR9l6s/Hy2b+t1AM0bLNPRuhwA== @@ -6746,6 +7155,11 @@ timers-browserify@^2.0.12: dependencies: setimmediate "^1.0.4" +titleize@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/titleize/-/titleize-3.0.0.tgz#71c12eb7fdd2558aa8a44b0be83b8a76694acd53" + integrity sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ== + tmp@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.2.1.tgz#8457fc3037dcf4719c251367a1af6500ee1ccf14" @@ -6783,6 +7197,11 @@ tough-cookie@~2.5.0: psl "^1.1.28" punycode "^2.1.1" +ts-api-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ts-api-utils/-/ts-api-utils-1.0.1.tgz#8144e811d44c749cd65b2da305a032510774452d" + integrity sha512-lC/RGlPmwdrIBFTX59wwNzqh7aR2otPNPR/5brHZm/XKFYKsfqxihXUe9pU3JI+3vGkl+vyCoNNnPhJn3aLK1A== + ts-node@^10.9.1: version "10.9.1" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" @@ -6802,7 +7221,7 @@ ts-node@^10.9.1: v8-compile-cache-lib "^3.0.1" yn "3.1.1" -tsconfig-paths@^3.14.1: +tsconfig-paths@^3.14.2: version "3.14.2" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz#6e32f1f79412decd261f92d633a9dc1cfa99f088" integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g== @@ -6822,6 +7241,11 @@ tslib@^2.1.0: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.0.tgz#b295854684dbda164e181d259a22cd779dcd7bc3" integrity sha512-7At1WUettjcSRHXCyYtTselblcHl9PJFFVKiCAy/bY97+BPZXSQ2wbq0P9s8tK2G7dFQfNnlJnPAiArVBVBsfA== +tslib@^2.5.0, tslib@^2.6.0: + version "2.6.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.1.tgz#fd8c9a0ff42590b25703c0acb3de3d3f4ede0410" + integrity sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig== + tslint@5.14.0: version "5.14.0" resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.14.0.tgz#be62637135ac244fc9b37ed6ea5252c9eba1616e" @@ -6917,6 +7341,36 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" +typed-array-buffer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-buffer/-/typed-array-buffer-1.0.0.tgz#18de3e7ed7974b0a729d3feecb94338d1472cd60" + integrity sha512-Y8KTSIglk9OZEr8zywiIHG/kmQ7KWyjseXs1CbSo8vC42w7hg2HgYTxSWwP0+is7bWDc1H+Fo026CpHFwm8tkw== + dependencies: + call-bind "^1.0.2" + get-intrinsic "^1.2.1" + is-typed-array "^1.1.10" + +typed-array-byte-length@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-length/-/typed-array-byte-length-1.0.0.tgz#d787a24a995711611fb2b87a4052799517b230d0" + integrity sha512-Or/+kvLxNpeQ9DtSydonMxCx+9ZXOswtwJn17SNLvhptaXYDJvkFFP5zbfU/uLmvnBJlI4yrnXRxpdWH/M5tNA== + dependencies: + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + +typed-array-byte-offset@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/typed-array-byte-offset/-/typed-array-byte-offset-1.0.0.tgz#cbbe89b51fdef9cd6aaf07ad4707340abbc4ea0b" + integrity sha512-RD97prjEt9EL8YgAgpOkf3O4IF9lhJFr9g0htQkm0rchFp/Vx7LW5Q8fSXXub7BXAODyUQohRMyOc3faCPd0hg== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + has-proto "^1.0.1" + is-typed-array "^1.1.10" + typed-array-length@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/typed-array-length/-/typed-array-length-1.0.4.tgz#89d83785e5c4098bec72e08b319651f0eac9c1bb" @@ -7001,6 +7455,11 @@ unpipe@1.0.0, unpipe@~1.0.0: resolved "https://registry.yarnpkg.com/unpipe/-/unpipe-1.0.0.tgz#b2bf4ee8514aae6165b4817829d21b2ef49904ec" integrity sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ== +untildify@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/untildify/-/untildify-4.0.0.tgz#2bc947b953652487e4600949fb091e3ae8cd919b" + integrity sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw== + update-browserslist-db@^1.0.11: version "1.0.11" resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.0.11.tgz#9a2a641ad2907ae7b3616506f4b977851db5b940" @@ -7117,7 +7576,7 @@ watchpack@^2.4.0: glob-to-regexp "^0.4.1" graceful-fs "^4.1.2" -webpack-cli@^5.0.1: +webpack-cli@^5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" integrity sha512-pIDJHIEI9LR0yxHXQ+Qh95k2EvXpWzZ5l+d+jIo+RdSm9MiHfzazIxwwni/p7+x4eJZuvG1AJwgC4TNQ7NRgsg== @@ -7156,10 +7615,10 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.88.1: - version "5.88.1" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.88.1.tgz#21eba01e81bd5edff1968aea726e2fbfd557d3f8" - integrity sha512-FROX3TxQnC/ox4N+3xQoWZzvGXSuscxR32rbzjpXgEzWudJFEJBpdlkkob2ylrv5yzzufD1zph1OoFsLtm6stQ== +webpack@^5.88.2: + version "5.88.2" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.88.2.tgz#f62b4b842f1c6ff580f3fcb2ed4f0b579f4c210e" + integrity sha512-JmcgNZ1iKj+aiR0OvTYtWQqJwq37Pf683dY9bVORwVbUrDhLhdn/PlO2sHsFHPkj7sHNQF3JwaAkp49V+Sq1tQ== dependencies: "@types/eslint-scope" "^3.7.3" "@types/estree" "^1.0.0" @@ -7202,6 +7661,17 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.1.tgz#776b1fe35d90aebe99e8ac15eb24093389a4a409" integrity sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ== +which-typed-array@^1.1.10: + version "1.1.11" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.11.tgz#99d691f23c72aab6768680805a271b69761ed61a" + integrity sha512-qe9UWWpkeG5yzZ0tNYxDmd7vo58HDBc39mZ0xWWpolAGADdFOzkfamWLDxkOWcvHQKVmdTyQdLD4NOfjLWTKew== + dependencies: + available-typed-arrays "^1.0.5" + call-bind "^1.0.2" + for-each "^0.3.3" + gopd "^1.0.1" + has-tostringtag "^1.0.0" + which-typed-array@^1.1.2, which-typed-array@^1.1.9: version "1.1.10" resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.10.tgz#74baa2789991905c2076abb317103b866c64e69e" From bd396a00dd4d0949840d4b3a78e4b1e3de8a8870 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 14:43:06 -0700 Subject: [PATCH 03/14] All tests are passing \o/ --- babel.config.json | 5 +- package.json | 8 +- src/index.ts | 3 +- src/soroban/index.ts | 2 + test/test-nodejs.js | 3 + test/unit/browser_test.js | 5 + .../server/claimable_balances.js | 0 test/unit/{ => horizon}/server/join_test.js | 0 test/unit/soroban/constructor_test.js | 27 ++ test/unit/soroban/get_account_test.js | 109 +++++++ test/unit/soroban/get_contract_data_test.js | 117 ++++++++ test/unit/soroban/get_events_test.js | 265 ++++++++++++++++++ test/unit/soroban/get_health_test.js | 39 +++ test/unit/soroban/get_latest_ledger_test.js | 40 +++ test/unit/soroban/get_network_test.js | 40 +++ test/unit/soroban/get_transaction_test.js | 66 +++++ test/unit/soroban/request_airdrop_test.js | 257 +++++++++++++++++ test/unit/soroban/send_transaction_test.js | 69 +++++ .../unit/soroban/simulate_transaction_test.js | 133 +++++++++ 19 files changed, 1180 insertions(+), 8 deletions(-) rename test/unit/{ => horizon}/server/claimable_balances.js (100%) rename test/unit/{ => horizon}/server/join_test.js (100%) create mode 100644 test/unit/soroban/constructor_test.js create mode 100644 test/unit/soroban/get_account_test.js create mode 100644 test/unit/soroban/get_contract_data_test.js create mode 100644 test/unit/soroban/get_events_test.js create mode 100644 test/unit/soroban/get_health_test.js create mode 100644 test/unit/soroban/get_latest_ledger_test.js create mode 100644 test/unit/soroban/get_network_test.js create mode 100644 test/unit/soroban/get_transaction_test.js create mode 100644 test/unit/soroban/request_airdrop_test.js create mode 100644 test/unit/soroban/send_transaction_test.js create mode 100644 test/unit/soroban/simulate_transaction_test.js diff --git a/babel.config.json b/babel.config.json index ddf498d1b..72b56a3b0 100644 --- a/babel.config.json +++ b/babel.config.json @@ -5,7 +5,8 @@ "@babel/typescript" ], "targets": { - "browsers": [ "> 2%" ] // target modern browsers and ES6 + "node": 16, + "browsers": [ "> 2%" ] // target modern browsers and ES6 }, "env": { "development": { @@ -14,7 +15,7 @@ "production": { "comments": false, "targets": { - "node": 16, + // larger feature set for prod bundle "browsers": [ "> 2%", "ie 11", diff --git a/package.json b/package.json index 4330a8c7a..4b3e30f4f 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,7 @@ "name": "stellar-sdk", "version": "11.0.0-beta.1", "description": "A library for working with the Stellar Horizon server.", - "keywords": [ - "stellar" - ], + "keywords": [ "stellar", "soroban", "horizon" ], "homepage": "https://github.com/stellar/js-stellar-sdk", "bugs": { "url": "https://github.com/stellar/js-stellar-sdk/issues" @@ -17,7 +15,7 @@ "author": "Stellar Development Foundation ", "main": "./lib/index.js", "types": "./lib/index.d.ts", - "browser": "./dist/stellar-sdk.js", + "browser": "./dist/stellar-sdk.min.js", "files": [ "/types", "/lib", @@ -32,7 +30,7 @@ "build:docs": "cross-env NODE_ENV=docs yarn _babel", "clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/", "docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose", - "test": "yarn test:node && yarn test:integration && yarn test:browser", + "test": "yarn build && yarn test:node && yarn test:integration && yarn test:browser", "test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'", "test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'", "test:browser": "karma start config/karma.conf.js", diff --git a/src/index.ts b/src/index.ts index 633eb644a..e75eff13f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,8 @@ export * from "./utils"; // expose classes and functions from stellar-base export * from "stellar-base"; -export * from './soroban'; +// expose all Soroban stuff +export * as SorobanClient from './soroban'; export { version }; diff --git a/src/soroban/index.ts b/src/soroban/index.ts index 9435f158f..11003a0b3 100644 --- a/src/soroban/index.ts +++ b/src/soroban/index.ts @@ -7,6 +7,8 @@ export { version } from './axios'; export * from "./soroban_rpc"; export * from "./transaction"; +export * from 'stellar-base'; + // http classes to expose export { Server } from "./server"; export { diff --git a/test/test-nodejs.js b/test/test-nodejs.js index 50c87d04b..c6f25a9cf 100644 --- a/test/test-nodejs.js +++ b/test/test-nodejs.js @@ -2,9 +2,12 @@ require("@babel/register"); global.StellarSdk = require("../lib/"); +global.SorobanClient = global.StellarSdk.SorobanClient; global.axios = require("axios"); global.HorizonAxiosClient = StellarSdk.HorizonAxiosClient; +global.AxiosClient = global.SorobanClient.AxiosClient; +global.serverUrl = "https://horizon-live.stellar.org:1337/api/v1/jsonrpc"; var chaiAsPromised = require("chai-as-promised"); var chaiHttp = require("chai-http"); diff --git a/test/unit/browser_test.js b/test/unit/browser_test.js index eea4c4824..f750ed221 100644 --- a/test/unit/browser_test.js +++ b/test/unit/browser_test.js @@ -4,4 +4,9 @@ describe("Browser version tests", function () { expect(typeof _ === "undefined").to.be.true; } }); + + it("defines globals", function() { + expect(StellarSdk).to.not.be.undefined; + expect(SorobanClient).to.not.be.undefined; + }); }); diff --git a/test/unit/server/claimable_balances.js b/test/unit/horizon/server/claimable_balances.js similarity index 100% rename from test/unit/server/claimable_balances.js rename to test/unit/horizon/server/claimable_balances.js diff --git a/test/unit/server/join_test.js b/test/unit/horizon/server/join_test.js similarity index 100% rename from test/unit/server/join_test.js rename to test/unit/horizon/server/join_test.js diff --git a/test/unit/soroban/constructor_test.js b/test/unit/soroban/constructor_test.js new file mode 100644 index 000000000..a528d94ae --- /dev/null +++ b/test/unit/soroban/constructor_test.js @@ -0,0 +1,27 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server.constructor", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + let insecureServerUrl = serverUrl.replace("https://", "http://"); + + it("throws error for insecure server", function () { + expect(() => new SorobanClient.Server(insecureServerUrl)).to.throw( + /Cannot connect to insecure soroban-rpc server/ + ); + }); + + it("allow insecure server when opts.allowHttp flag is set", function () { + expect( + () => new SorobanClient.Server(insecureServerUrl, { allowHttp: true }) + ).to.not.throw(); + }); +}); diff --git a/test/unit/soroban/get_account_test.js b/test/unit/soroban/get_account_test.js new file mode 100644 index 000000000..4843823cb --- /dev/null +++ b/test/unit/soroban/get_account_test.js @@ -0,0 +1,109 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#getAccount", function () { + const { Account, StrKey, xdr } = SorobanClient; + + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + + console.log('client:', AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("requests the correct method", function (done) { + const address = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + const accountId = xdr.PublicKey.publicKeyTypeEd25519( + StrKey.decodeEd25519PublicKey(address) + ); + + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLedgerEntries", + params: [ + [ + xdr.LedgerKey.account( + new xdr.LedgerKeyAccount({ + accountId, + }) + ).toXDR("base64"), + ], + ], + }) + .returns( + Promise.resolve({ + data: { + result: { + entries: [ + { + xdr: "AAAAAAAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1g3gtpoE608YAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAQAAAAAY9D8iA", + }, + ], + }, + }, + }) + ); + + const expected = new Account(address, "1"); + this.server + .getAccount(address) + .then(function (response) { + expect(response).to.be.deep.equal(expected); + done(); + }) + .catch(done); + }); + + it("throws a useful error when the account is not found", function (done) { + const address = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + const accountId = xdr.PublicKey.publicKeyTypeEd25519( + StrKey.decodeEd25519PublicKey(address) + ); + + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLedgerEntries", + params: [ + [ + xdr.LedgerKey.account( + new xdr.LedgerKeyAccount({ + accountId, + }) + ).toXDR("base64"), + ], + ], + }) + .returns( + Promise.resolve({ + data: { + result: { + entries: null, + }, + }, + }) + ); + + this.server + .getAccount(address) + .then(function (_) { + done(new Error("Expected error to be thrown")); + }) + .catch(function (err) { + done( + err.message === `Account not found: ${address}` + ? null + : new Error(`Received unexpected error: ${err.message}`) + ); + }); + }); +}); diff --git a/test/unit/soroban/get_contract_data_test.js b/test/unit/soroban/get_contract_data_test.js new file mode 100644 index 000000000..a3b014a18 --- /dev/null +++ b/test/unit/soroban/get_contract_data_test.js @@ -0,0 +1,117 @@ +const MockAdapter = require("axios-mock-adapter"); +const xdr = SorobanClient.xdr; +const Address = SorobanClient.Address; + +describe("Server#getContractData", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + let address = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"; + let key = SorobanClient.xdr.ScVal.scvVec([ + SorobanClient.xdr.ScVal.scvSymbol("Admin"), + ]); + + it("key found", function (done) { + let result = { + id: address, + sequence: "1", + }; + + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLedgerEntries", + params: [ + [ + xdr.LedgerKey.contractData( + new xdr.LedgerKeyContractData({ + contract: new SorobanClient.Contract(address) + .address() + .toScAddress(), + key, + durability: xdr.ContractDataDurability.persistent(), + bodyType: xdr.ContractEntryBodyType.dataEntry(), + }) + ).toXDR("base64"), + ], + ], + }) + .returns( + Promise.resolve({ + data: { + result: { + entries: [result], + }, + }, + }) + ); + + this.server + .getContractData(address, key, "persistent") + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + + it("key not found", function (done) { + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLedgerEntries", + params: [ + [ + xdr.LedgerKey.contractData( + new xdr.LedgerKeyContractData({ + contract: new SorobanClient.Contract(address) + .address() + .toScAddress(), + key, + durability: xdr.ContractDataDurability.temporary(), + bodyType: xdr.ContractEntryBodyType.dataEntry(), + }) + ).toXDR("base64"), + ], + ], + }) + .returns(Promise.resolve({ data: { result: { entries: [] } } })); + + this.server + .getContractData(address, key, "temporary") + .then(function (_response) { + done(new Error("Expected error")); + }) + .catch(function (err) { + done( + err.code == 404 + ? null + : new Error("Expected error code 404, got: " + err.code) + ); + }); + }); + + it("fails on hex address (was deprecated now unsupported)", function (done) { + let hexAddress = "0".repeat(63) + "1"; + this.server + .getContractData(hexAddress, key, "persistent") + .then((reply) => done(new Error(`should fail, got: ${reply}`))) + .catch((error) => { + expect(error).to.contain(/unsupported contract id/i); + done(); + }); + }); +}); diff --git a/test/unit/soroban/get_events_test.js b/test/unit/soroban/get_events_test.js new file mode 100644 index 000000000..c53645e73 --- /dev/null +++ b/test/unit/soroban/get_events_test.js @@ -0,0 +1,265 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#getEvents", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("requests the correct endpoint", function (done) { + let result = { events: [] }; + setupMock( + this.axiosMock, + { + filters: [], + pagination: {}, + startLedger: "1", + }, + result + ); + + this.server + .getEvents({ startLedger: 1 }) + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + + it("can build wildcard filters", function (done) { + let result = filterEvents(getEventsResponseFixture, "*/*"); + + setupMock( + this.axiosMock, + { + startLedger: "1", + filters: [ + { + topics: [["*", "*"]], + }, + ], + pagination: {}, + }, + result + ); + + this.server + .getEvents({ + startLedger: 1, + filters: [ + { + topics: [["*", "*"]], + }, + ], + }) + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(done); + }); + + it("can build matching filters", function (done) { + let result = filterEvents( + getEventsResponseFixture, + "AAAABQAAAAh0cmFuc2Zlcg==/AAAAAQB6Mcc=" + ); + + setupMock( + this.axiosMock, + { + startLedger: "1", + filters: [ + { + topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="]], + }, + ], + pagination: {}, + }, + result + ); + + this.server + .getEvents({ + startLedger: 1, + filters: [ + { + topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="]], + }, + ], + }) + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(done); + }); + + it("can build mixed filters", function (done) { + let result = filterEventsByLedger( + filterEvents(getEventsResponseFixture, "AAAABQAAAAh0cmFuc2Zlcg==/*"), + 1 + ); + + setupMock( + this.axiosMock, + { + startLedger: "1", + filters: [ + { + topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "*"]], + }, + ], + pagination: {}, + }, + result + ); + + this.server + .getEvents({ + startLedger: 1, + filters: [ + { + topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "*"]], + }, + ], + }) + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(done); + }); + + it("can paginate", function (done) { + let result = filterEventsByLedger( + filterEvents(getEventsResponseFixture, "*/*"), + 1 + ); + + setupMock( + this.axiosMock, + { + filters: [ + { + topics: [["*", "*"]], + }, + ], + pagination: { + limit: 10, + cursor: "0164090849041387521-0000000000", + }, + }, + result + ); + + this.server + .getEvents({ + filters: [ + { + topics: [["*", "*"]], + }, + ], + cursor: "0164090849041387521-0000000000", + limit: 10, + }) + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(done); + }); +}); + +function filterEvents(events, filter) { + return events.filter( + (e, i) => + e.topic.length == filter.length && + e.topic.every((s, j) => s === filter[j] || s === "*") + ); +} + +function filterEventsByLedger(events, start) { + return events.filter((e) => { + return e.ledger.parseInt() >= start; + }); +} + +function setupMock(axiosMock, params, result) { + axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getEvents", + params: params, + }) + .returns(Promise.resolve({ data: { result } })); +} + +let getEventsResponseFixture = [ + { + type: "system", + ledger: "1", + ledgerClosedAt: "2022-11-16T16:10:41Z", + contractId: + "e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", + id: "0164090849041387521-0000000003", + pagingToken: "164090849041387521-3", + topic: ["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="], + inSuccessfulContractCall: true, + value: { + xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", + }, + }, + { + type: "contract", + ledger: "2", + ledgerClosedAt: "2022-11-16T16:10:41Z", + contractId: + "e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", + id: "0164090849041387521-0000000003", + pagingToken: "164090849041387521-3", + topic: ["AAAAAQB6Mcc=", "AAAABQAAAAh0cmFuc2Zlcg=="], + inSuccessfulContractCall: true, + value: { + xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", + }, + }, + { + type: "diagnostic", + ledger: "2", + ledgerClosedAt: "2022-11-16T16:10:41Z", + contractId: + "a3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", + id: "0164090849041387521-0000000003", + pagingToken: "164090849041387521-3", + inSuccessfulContractCall: true, + topic: ["AAAAAQB6Mcc="], + value: { + xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", + }, + }, + { + type: "contract", + ledger: "3", + ledgerClosedAt: "2022-12-14T01:01:20Z", + contractId: + "6ebe0114ae15f72f187f05d06dcb66b22bd97218755c9b4646b034ab961fc1d5", + id: "0000000171798695936-0000000001", + pagingToken: "0000000171798695936-0000000001", + inSuccessfulContractCall: true, + topic: ["AAAABQAAAAdDT1VOVEVSAA==", "AAAABQAAAAlpbmNyZW1lbnQAAAA="], + value: { + xdr: "AAAAAQAAAAE=", + }, + }, +]; diff --git a/test/unit/soroban/get_health_test.js b/test/unit/soroban/get_health_test.js new file mode 100644 index 000000000..4d18c2b25 --- /dev/null +++ b/test/unit/soroban/get_health_test.js @@ -0,0 +1,39 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#getHealth", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("requests the correct endpoint", function (done) { + let result = { + status: "healthy", + }; + + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getHealth", + params: null, + }) + .returns(Promise.resolve({ data: { result } })); + + this.server + .getHealth() + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(function (err) { + done(err); + }); + }); +}); diff --git a/test/unit/soroban/get_latest_ledger_test.js b/test/unit/soroban/get_latest_ledger_test.js new file mode 100644 index 000000000..6ad072ec9 --- /dev/null +++ b/test/unit/soroban/get_latest_ledger_test.js @@ -0,0 +1,40 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#getLatestLedger", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("requests the correct method", function (done) { + const result = { + id: "hashed_id", + sequence: 123, + protocolVersion: 20, + }; + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLatestLedger", + params: null, + }) + .returns(Promise.resolve({ data: { result } })); + + this.server + .getLatestLedger() + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(function (err) { + done(err); + }); + }); +}); diff --git a/test/unit/soroban/get_network_test.js b/test/unit/soroban/get_network_test.js new file mode 100644 index 000000000..0c68333ff --- /dev/null +++ b/test/unit/soroban/get_network_test.js @@ -0,0 +1,40 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#getNetwork", function () { + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("requests the correct method", function (done) { + const result = { + friendbotUrl: "https://friendbot.stellar.org", + passphrase: "Soroban Testnet ; December 2018", + protocolVersion: 20, + }; + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getNetwork", + params: null, + }) + .returns(Promise.resolve({ data: { result } })); + + this.server + .getNetwork() + .then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }) + .catch(function (err) { + done(err); + }); + }); +}); diff --git a/test/unit/soroban/get_transaction_test.js b/test/unit/soroban/get_transaction_test.js new file mode 100644 index 000000000..c921e8303 --- /dev/null +++ b/test/unit/soroban/get_transaction_test.js @@ -0,0 +1,66 @@ +describe("Server#getTransaction", function () { + let keypair = SorobanClient.Keypair.random(); + let account = new SorobanClient.Account( + keypair.publicKey(), + "56199647068161" + ); + + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + let transaction = new SorobanClient.TransactionBuilder(account, { + fee: 100, + networkPassphrase: SorobanClient.Networks.FUTURENET, + }) + .addOperation( + SorobanClient.Operation.payment({ + destination: + "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + asset: SorobanClient.Asset.native(), + amount: "100.50", + }) + ) + .setTimeout(SorobanClient.TimeoutInfinite) + .build(); + transaction.sign(keypair); + + this.transaction = transaction; + this.hash = this.transaction.hash().toString("hex"); + this.blob = transaction.toEnvelope().toXDR().toString("base64"); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("transaction not found", function (done) { + const result = { + status: "NOT_FOUND", + latestLedger: 100, + latestLedgerCloseTime: 12345, + oldestLedger: 50, + oldestLedgerCloseTime: 500, + }; + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getTransaction", + params: [this.hash], + }) + .returns(Promise.resolve({ data: { id: 1, result } })); + + this.server.getTransaction(this.hash).then(function (response) { + expect(response).to.be.deep.equal(result); + done(); + }); + }); + + xit("transaction pending", function (done) {}); + + xit("transaction success", function (done) {}); + + xit("transaction error", function (done) {}); +}); diff --git a/test/unit/soroban/request_airdrop_test.js b/test/unit/soroban/request_airdrop_test.js new file mode 100644 index 000000000..842812429 --- /dev/null +++ b/test/unit/soroban/request_airdrop_test.js @@ -0,0 +1,257 @@ +const MockAdapter = require("axios-mock-adapter"); + +describe("Server#requestAirdrop", function () { + const { Account, StrKey, xdr } = SorobanClient; + + function accountLedgerEntryData(accountId, sequence) { + return new xdr.LedgerEntryData.account( + new xdr.AccountEntry({ + accountId: xdr.AccountId.publicKeyTypeEd25519( + StrKey.decodeEd25519PublicKey(accountId) + ), + balance: xdr.Int64.fromString("1"), + seqNum: xdr.SequenceNumber.fromString(sequence), + numSubEntries: 0, + inflationDest: null, + flags: 0, + homeDomain: "", + // Taken from a real response. idk. + thresholds: Buffer.from("AQAAAA==", "base64"), + signers: [], + ext: new xdr.AccountEntryExt(0), + }) + ); + } + + // Create a mock transaction meta for the account we're going to request an airdrop for + function transactionMetaFor(accountId, sequence) { + const meta = new xdr.TransactionMeta(0, [ + new xdr.OperationMeta({ + changes: [ + xdr.LedgerEntryChange.ledgerEntryCreated( + new xdr.LedgerEntry({ + lastModifiedLedgerSeq: 0, + data: accountLedgerEntryData(accountId, sequence), + ext: new xdr.LedgerEntryExt(0), + }) + ), + ], + }), + ]); + return meta; + } + + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + function mockGetNetwork(friendbotUrl) { + const result = { + friendbotUrl, + passphrase: "Soroban Testnet ; December 2018", + protocolVersion: 20, + }; + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getNetwork", + params: null, + }) + .returns(Promise.resolve({ data: { result } })); + } + + it("returns true when the account is created", function (done) { + const friendbotUrl = "https://friendbot.stellar.org"; + const accountId = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + mockGetNetwork.call(this, friendbotUrl); + + const result_meta_xdr = transactionMetaFor(accountId, "1234").toXDR( + "base64" + ); + this.axiosMock + .expects("post") + .withArgs(`${friendbotUrl}?addr=${accountId}`) + .returns(Promise.resolve({ data: { result_meta_xdr } })); + + this.server + .requestAirdrop(accountId) + .then(function (response) { + expect(response).to.be.deep.equal(new Account(accountId, "1234")); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + + it("returns false if the account already exists", function (done) { + const friendbotUrl = "https://friendbot.stellar.org"; + const accountId = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + mockGetNetwork.call(this, friendbotUrl); + + this.axiosMock + .expects("post") + .withArgs(`${friendbotUrl}?addr=${accountId}`) + .returns( + Promise.reject({ + response: { + status: 400, + detail: + "createAccountAlreadyExist (AAAAAAAAAGT/////AAAAAQAAAAAAAAAA/////AAAAAA=)", + }, + }) + ); + + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "getLedgerEntries", + params: [ + [ + xdr.LedgerKey.account( + new xdr.LedgerKeyAccount({ + accountId: xdr.PublicKey.publicKeyTypeEd25519( + StrKey.decodeEd25519PublicKey(accountId) + ), + }) + ).toXDR("base64"), + ], + ], + }) + .returns( + Promise.resolve({ + data: { + result: { + entries: [ + { + xdr: accountLedgerEntryData(accountId, "1234").toXDR( + "base64" + ), + }, + ], + }, + }, + }) + ); + + this.server + .requestAirdrop(accountId) + .then(function (response) { + expect(response).to.be.deep.equal(new Account(accountId, "1234")); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + + it("uses custom friendbotUrl if passed", function (done) { + const friendbotUrl = "https://custom-friendbot.stellar.org"; + const accountId = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + + const result_meta_xdr = transactionMetaFor(accountId, "1234").toXDR( + "base64" + ); + this.axiosMock + .expects("post") + .withArgs(`${friendbotUrl}?addr=${accountId}`) + .returns(Promise.resolve({ data: { result_meta_xdr } })); + + this.server + .requestAirdrop(accountId, friendbotUrl) + .then(function (response) { + expect(response).to.be.deep.equal(new Account(accountId, "1234")); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + + it("rejects invalid addresses", function (done) { + const friendbotUrl = "https://friendbot.stellar.org"; + const accountId = "addr&injected=1"; + mockGetNetwork.call(this, friendbotUrl); + + this.axiosMock + .expects("post") + .withArgs(`${friendbotUrl}?addr=addr%26injected%3D1`) + .returns( + Promise.reject({ + response: { + status: 400, + type: "https://stellar.org/horizon-errors/bad_request", + title: "Bad Request", + detail: "The request you sent was invalid in some way.", + extras: { + invalid_field: "addr", + reason: + "base32 decode failed: illegal base32 data at input byte 7", + }, + }, + }) + ); + + this.server + .requestAirdrop(accountId) + .then(function (_) { + done(new Error("Should have thrown")); + }) + .catch(function (err) { + expect(err.response.extras.reason).to.include("base32 decode failed"); + done(); + }); + }); + + it("throws if there is no friendbotUrl set", function (done) { + const accountId = "addr&injected=1"; + mockGetNetwork.call(this, undefined); + + this.server + .requestAirdrop(accountId) + .then(function (_) { + done(new Error("Should have thrown")); + }) + .catch(function (err) { + expect(err.message).to.be.equal( + "No friendbot URL configured for current network" + ); + done(); + }); + }); + + it("throws if the request fails", function (done) { + const friendbotUrl = "https://friendbot.stellar.org"; + const accountId = + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + mockGetNetwork.call(this, friendbotUrl); + + this.axiosMock + .expects("post") + .withArgs(`${friendbotUrl}?addr=${accountId}`) + .returns(Promise.reject(new Error("Request failed"))); + + this.server + .requestAirdrop(accountId) + .then(function (_) { + done(new Error("Should have thrown")); + }) + .catch(function (err) { + expect(err.message).to.be.equal("Request failed"); + done(); + }); + }); +}); diff --git a/test/unit/soroban/send_transaction_test.js b/test/unit/soroban/send_transaction_test.js new file mode 100644 index 000000000..3e387be3b --- /dev/null +++ b/test/unit/soroban/send_transaction_test.js @@ -0,0 +1,69 @@ +describe("Server#sendTransaction", function () { + let keypair = SorobanClient.Keypair.random(); + let account = new SorobanClient.Account( + keypair.publicKey(), + "56199647068161" + ); + + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + let transaction = new SorobanClient.TransactionBuilder(account, { + fee: 100, + networkPassphrase: SorobanClient.Networks.TESTNET, + v1: true, + }) + .addOperation( + SorobanClient.Operation.payment({ + destination: + "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + asset: SorobanClient.Asset.native(), + amount: "100.50", + }) + ) + .setTimeout(SorobanClient.TimeoutInfinite) + .build(); + transaction.sign(keypair); + + this.transaction = transaction; + this.hash = this.transaction.hash().toString("hex"); + this.blob = transaction.toEnvelope().toXDR().toString("base64"); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("sends a transaction", function (done) { + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "sendTransaction", + params: [this.blob], + }) + .returns( + Promise.resolve({ + data: { id: 1, result: { id: this.hash, status: "PENDING" } }, + }) + ); + + this.server + .sendTransaction(this.transaction) + .then(function () { + done(); + }) + .catch(function (err) { + done(err); + }); + }); + xit("adds metadata - tx was too small and was immediately deleted"); + xit("adds metadata, order immediately fills"); + xit("adds metadata, order is open"); + xit("adds metadata, partial fill"); + xit("doesnt add metadata to non-offers"); + xit("adds metadata about offers, even if some ops are not"); + xit("submits fee bump transactions"); +}); diff --git a/test/unit/soroban/simulate_transaction_test.js b/test/unit/soroban/simulate_transaction_test.js new file mode 100644 index 000000000..c41a33e80 --- /dev/null +++ b/test/unit/soroban/simulate_transaction_test.js @@ -0,0 +1,133 @@ +describe("Server#simulateTransaction", function () { + let keypair = SorobanClient.Keypair.random(); + let account = new SorobanClient.Account( + keypair.publicKey(), + "56199647068161" + ); + + let contractId = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"; + let contract = new SorobanClient.Contract(contractId); + let address = contract.address().toScAddress(); + + const simulationResponse = { + transactionData: new SorobanClient.xdr.SorobanTransactionData({ + resources: new SorobanClient.xdr.SorobanResources({ + footprint: new SorobanClient.xdr.LedgerFootprint({ + readOnly: [], + readWrite: [], + }), + instructions: 0, + readBytes: 0, + writeBytes: 0, + extendedMetaDataSizeBytes: 0, + }), + refundableFee: SorobanClient.xdr.Int64.fromString("0"), + ext: new SorobanClient.xdr.ExtensionPoint(0), + }).toXDR("base64"), + events: [], + minResourceFee: "15", + result: { + auth: [ + new SorobanClient.xdr.SorobanAuthorizationEntry({ + // Include a credentials w/ a nonce + credentials: + new SorobanClient.xdr.SorobanCredentials.sorobanCredentialsAddress( + new SorobanClient.xdr.SorobanAddressCredentials({ + address: address, + nonce: new SorobanClient.xdr.Int64(1234), + signatureExpirationLedger: 1, + signatureArgs: [], + }) + ), + // Basic fake invocation + rootInvocation: new SorobanClient.xdr.SorobanAuthorizedInvocation({ + function: + SorobanClient.xdr.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeContractFn( + new SorobanClient.xdr.SorobanAuthorizedContractFunction({ + contractAddress: address, + functionName: "test", + args: [], + }) + ), + subInvocations: [], + }), + }).toXDR("base64"), + ], + xdr: SorobanClient.xdr.ScVal.scvU32(0).toXDR().toString("base64"), + }, + latestLedger: 3, + cost: { + cpuInsns: "0", + memBytes: "0", + }, + }; + + beforeEach(function () { + this.server = new SorobanClient.Server(serverUrl); + this.axiosMock = sinon.mock(AxiosClient); + const source = new SorobanClient.Account( + "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI", + "1" + ); + function emptyContractTransaction() { + return new SorobanClient.TransactionBuilder(source, { + fee: 100, + networkPassphrase: "Test", + v1: true, + }) + .addOperation( + SorobanClient.Operation.invokeHostFunction({ + func: new SorobanClient.xdr.HostFunction.hostFunctionTypeInvokeContract( + [] + ), + auth: [], + }) + ) + .setTimeout(SorobanClient.TimeoutInfinite) + .build(); + } + + const transaction = emptyContractTransaction(); + transaction.sign(keypair); + + this.transaction = transaction; + this.hash = this.transaction.hash().toString("hex"); + this.blob = transaction.toEnvelope().toXDR().toString("base64"); + }); + + afterEach(function () { + this.axiosMock.verify(); + this.axiosMock.restore(); + }); + + it("simulates a transaction", function (done) { + this.axiosMock + .expects("post") + .withArgs(serverUrl, { + jsonrpc: "2.0", + id: 1, + method: "simulateTransaction", + params: [this.blob], + }) + .returns( + Promise.resolve({ data: { id: 1, result: simulationResponse } }) + ); + + this.server + .simulateTransaction(this.transaction) + .then(function (response) { + expect(response).to.be.deep.equal(simulationResponse); + done(); + }) + .catch(function (err) { + done(err); + }); + }); + xit("adds metadata - tx was too small and was immediately deleted"); + xit("adds metadata, order immediately fills"); + xit("adds metadata, order is open"); + xit("adds metadata, partial fill"); + xit("doesnt add metadata to non-offers"); + xit("adds metadata about offers, even if some ops are not"); + xit("simulates fee bump transactions"); +}); From 0d7359cb0b5b0c054e32aa2bd3918682c4cc0780 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 14:44:28 -0700 Subject: [PATCH 04/14] Move files around --- test/integration/client_headers_test.js | 47 +++---------------- test/unit/{ => horizon}/browser_test.js | 0 test/unit/{ => horizon}/call_builders_test.js | 0 .../{server => }/claimable_balances.js | 0 .../{ => horizon}/federation_server_test.js | 0 .../horizon_axios_client_test.js | 0 test/unit/{ => horizon}/horizon_path_test.js | 0 test/unit/horizon/{server => }/join_test.js | 0 .../liquidity_pool_endpoints_test.js | 0 .../server_check_memo_required_test.js | 0 test/unit/{ => horizon}/server_test.js | 0 .../{ => horizon}/server_transaction_test.js | 0 .../stellar_toml_resolver_test.js | 0 test/unit/{ => horizon}/utils_test.js | 0 14 files changed, 6 insertions(+), 41 deletions(-) rename test/unit/{ => horizon}/browser_test.js (100%) rename test/unit/{ => horizon}/call_builders_test.js (100%) rename test/unit/horizon/{server => }/claimable_balances.js (100%) rename test/unit/{ => horizon}/federation_server_test.js (100%) rename test/unit/{ => horizon}/horizon_axios_client_test.js (100%) rename test/unit/{ => horizon}/horizon_path_test.js (100%) rename test/unit/horizon/{server => }/join_test.js (100%) rename test/unit/{ => horizon}/liquidity_pool_endpoints_test.js (100%) rename test/unit/{ => horizon}/server_check_memo_required_test.js (100%) rename test/unit/{ => horizon}/server_test.js (100%) rename test/unit/{ => horizon}/server_transaction_test.js (100%) rename test/unit/{ => horizon}/stellar_toml_resolver_test.js (100%) rename test/unit/{ => horizon}/utils_test.js (100%) diff --git a/test/integration/client_headers_test.js b/test/integration/client_headers_test.js index b285ab605..f82c4d7ff 100644 --- a/test/integration/client_headers_test.js +++ b/test/integration/client_headers_test.js @@ -2,8 +2,6 @@ const http = require("http"); const url = require("url"); const port = 3100; -const versionPattern = /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/; - describe("integration tests: client headers", function (done) { if (typeof window !== "undefined") { done(); @@ -14,8 +12,10 @@ describe("integration tests: client headers", function (done) { let server; const requestHandler = (request, response) => { - expect(request.headers["x-client-name"]).to.be.equal("js-stellar-sdk"); - expect(request.headers["x-client-version"]).to.match(versionPattern); + expect(request.headers["x-client-name"]).to.be.equal("js-soroban-client"); + expect(request.headers["x-client-version"]).to.match( + /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/ + ); response.end(); server.close(() => done()); }; @@ -27,44 +27,9 @@ describe("integration tests: client headers", function (done) { return; } - new StellarSdk.Server(`http://localhost:${port}`, { allowHttp: true }) - .operations() - .call(); - }); - }); - - it("sends client data via get params when streaming", function (done) { - let server; - let closeStream; - - const requestHandler = (request, response) => { - // eslint-disable-next-line node/no-deprecated-api - let query = url.parse(request.url, true).query; - expect(query["X-Client-Name"]).to.be.equal("js-stellar-sdk"); - expect(query["X-Client-Version"]).to.match(versionPattern); - response.end(); - server.close(() => { - closeStream(); - done(); - }); - }; - - server = http.createServer(requestHandler); - server.listen(port, (err) => { - if (err) { - done(err); - return; - } - - closeStream = new StellarSdk.Server(`http://localhost:${port}`, { + new SorobanClient.Server(`http://localhost:${port}`, { allowHttp: true, - }) - .operations() - .stream({ - onerror: (err) => { - done(err); - }, - }); + }).getHealth(); }); }); }); diff --git a/test/unit/browser_test.js b/test/unit/horizon/browser_test.js similarity index 100% rename from test/unit/browser_test.js rename to test/unit/horizon/browser_test.js diff --git a/test/unit/call_builders_test.js b/test/unit/horizon/call_builders_test.js similarity index 100% rename from test/unit/call_builders_test.js rename to test/unit/horizon/call_builders_test.js diff --git a/test/unit/horizon/server/claimable_balances.js b/test/unit/horizon/claimable_balances.js similarity index 100% rename from test/unit/horizon/server/claimable_balances.js rename to test/unit/horizon/claimable_balances.js diff --git a/test/unit/federation_server_test.js b/test/unit/horizon/federation_server_test.js similarity index 100% rename from test/unit/federation_server_test.js rename to test/unit/horizon/federation_server_test.js diff --git a/test/unit/horizon_axios_client_test.js b/test/unit/horizon/horizon_axios_client_test.js similarity index 100% rename from test/unit/horizon_axios_client_test.js rename to test/unit/horizon/horizon_axios_client_test.js diff --git a/test/unit/horizon_path_test.js b/test/unit/horizon/horizon_path_test.js similarity index 100% rename from test/unit/horizon_path_test.js rename to test/unit/horizon/horizon_path_test.js diff --git a/test/unit/horizon/server/join_test.js b/test/unit/horizon/join_test.js similarity index 100% rename from test/unit/horizon/server/join_test.js rename to test/unit/horizon/join_test.js diff --git a/test/unit/liquidity_pool_endpoints_test.js b/test/unit/horizon/liquidity_pool_endpoints_test.js similarity index 100% rename from test/unit/liquidity_pool_endpoints_test.js rename to test/unit/horizon/liquidity_pool_endpoints_test.js diff --git a/test/unit/server_check_memo_required_test.js b/test/unit/horizon/server_check_memo_required_test.js similarity index 100% rename from test/unit/server_check_memo_required_test.js rename to test/unit/horizon/server_check_memo_required_test.js diff --git a/test/unit/server_test.js b/test/unit/horizon/server_test.js similarity index 100% rename from test/unit/server_test.js rename to test/unit/horizon/server_test.js diff --git a/test/unit/server_transaction_test.js b/test/unit/horizon/server_transaction_test.js similarity index 100% rename from test/unit/server_transaction_test.js rename to test/unit/horizon/server_transaction_test.js diff --git a/test/unit/stellar_toml_resolver_test.js b/test/unit/horizon/stellar_toml_resolver_test.js similarity index 100% rename from test/unit/stellar_toml_resolver_test.js rename to test/unit/horizon/stellar_toml_resolver_test.js diff --git a/test/unit/utils_test.js b/test/unit/horizon/utils_test.js similarity index 100% rename from test/unit/utils_test.js rename to test/unit/horizon/utils_test.js From ebec79dce24e5b5c1fd7b1dce354cd33ea7dbbf1 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 14:47:22 -0700 Subject: [PATCH 05/14] Generalize axios client name --- src/{horizon_axios_client.ts => axios.ts} | 6 +- src/call_builder.ts | 4 +- src/index.ts | 4 +- src/server.ts | 10 +-- src/soroban/axios.ts | 81 ------------------- test/.eslintrc.js | 2 +- test/test-browser.js | 2 +- test/test-nodejs.js | 3 +- test/unit/horizon/claimable_balances.js | 2 +- test/unit/horizon/horizon_path_test.js | 2 +- test/unit/horizon/join_test.js | 2 +- .../horizon/liquidity_pool_endpoints_test.js | 2 +- .../server_check_memo_required_test.js | 2 +- test/unit/horizon/server_test.js | 4 +- test/unit/horizon/server_transaction_test.js | 2 +- 15 files changed, 23 insertions(+), 105 deletions(-) rename src/{horizon_axios_client.ts => axios.ts} (94%) delete mode 100644 src/soroban/axios.ts diff --git a/src/horizon_axios_client.ts b/src/axios.ts similarity index 94% rename from src/horizon_axios_client.ts rename to src/axios.ts index 8f105829f..22184d99f 100644 --- a/src/horizon_axios_client.ts +++ b/src/axios.ts @@ -23,7 +23,7 @@ export interface ServerTime { */ export const SERVER_TIME_MAP: Record = {}; -const HorizonAxiosClient = axios.create({ +const AxiosClient = axios.create({ headers: { "X-Client-Name": "js-stellar-sdk", "X-Client-Version": version, @@ -34,7 +34,7 @@ function _toSeconds(ms: number): number { return Math.floor(ms / 1000); } -HorizonAxiosClient.interceptors.response.use( +AxiosClient.interceptors.response.use( function interceptorHorizonResponse(response: AxiosResponse) { const hostname = URI(response.config.url!).hostname(); const serverTime = _toSeconds(Date.parse(response.headers.date)); @@ -51,7 +51,7 @@ HorizonAxiosClient.interceptors.response.use( }, ); -export default HorizonAxiosClient; +export default AxiosClient; /** * Given a hostname, get the current time of that server (i.e., use the last- diff --git a/src/call_builder.ts b/src/call_builder.ts index 88b490500..080afae25 100644 --- a/src/call_builder.ts +++ b/src/call_builder.ts @@ -3,7 +3,7 @@ import URITemplate from "urijs/src/URITemplate"; import { BadRequestError, NetworkError, NotFoundError } from "./errors"; import { Horizon } from "./horizon_api"; -import HorizonAxiosClient from "./horizon_axios_client"; +import AxiosClient from "./horizon_axios_client"; import { ServerApi } from "./server_api"; /* tslint:disable-next-line:no-var-requires */ @@ -344,7 +344,7 @@ export class CallBuilder< url = url.protocol(this.url.protocol()); } - return HorizonAxiosClient.get(url.toString()) + return AxiosClient.get(url.toString()) .then((response) => response.data) .catch(this._handleNetworkError); } diff --git a/src/index.ts b/src/index.ts index e75eff13f..195ae2288 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,10 +22,10 @@ export { STELLAR_TOML_MAX_SIZE } from "./stellar_toml_resolver"; export { - default as HorizonAxiosClient, + default as AxiosClient, SERVER_TIME_MAP, getCurrentServerTime -} from "./horizon_axios_client"; +} from "./axios"; export * from "./utils"; // expose classes and functions from stellar-base diff --git a/src/server.ts b/src/server.ts index 70f384388..0c8866798 100644 --- a/src/server.ts +++ b/src/server.ts @@ -38,7 +38,7 @@ import { TradeAggregationCallBuilder } from "./trade_aggregation_call_builder"; import { TradesCallBuilder } from "./trades_call_builder"; import { TransactionCallBuilder } from "./transaction_call_builder"; -import HorizonAxiosClient, { +import AxiosClient, { getCurrentServerTime, } from "./horizon_axios_client"; @@ -93,7 +93,7 @@ export class Server { customHeaders["X-Auth-Token"] = opts.authToken; } if (Object.keys(customHeaders).length > 0) { - HorizonAxiosClient.interceptors.request.use((config) => { + AxiosClient.interceptors.request.use((config) => { // merge the custom headers with an existing headers, where customs // override defaults config.headers = Object.assign(config.headers, customHeaders); @@ -141,7 +141,7 @@ export class Server { seconds: number, _isRetry: boolean = false, ): Promise { - // HorizonAxiosClient instead of this.ledgers so we can get at them headers + // AxiosClient instead of this.ledgers so we can get at them headers const currentTime = getCurrentServerTime(this.serverURL.hostname()); if (currentTime) { @@ -161,7 +161,7 @@ export class Server { // otherwise, retry (by calling the root endpoint) // toString automatically adds the trailing slash - await HorizonAxiosClient.get(URI(this.serverURL as any).toString()); + await AxiosClient.get(URI(this.serverURL as any).toString()); return await this.fetchTimebounds(seconds, true); } @@ -310,7 +310,7 @@ export class Server { .toString("base64"), ); - return HorizonAxiosClient.post( + return AxiosClient.post( URI(this.serverURL as any) .segment("transactions") .toString(), diff --git a/src/soroban/axios.ts b/src/soroban/axios.ts deleted file mode 100644 index 6d4eaed31..000000000 --- a/src/soroban/axios.ts +++ /dev/null @@ -1,81 +0,0 @@ -import axios, { AxiosResponse } from "axios"; -import URI from "urijs"; - -/* tslint:disable-next-line:no-var-requires */ -export const version = require("../../package.json").version; - -export interface ServerTime { - serverTime: number; - localTimeRecorded: number; -} - -/** - * keep a local map of server times - * (export this purely for testing purposes) - * - * each entry will map the server domain to the last-known time and the local - * time it was recorded, ex: - * - * "localhost:8000": { - * serverTime: 1552513039, - * localTimeRecorded: 1552513052 - * } - */ -export const SERVER_TIME_MAP: Record = {}; - -const AxiosClient = axios.create({ - headers: { - "X-Client-Name": "js-soroban-client", - "X-Client-Version": version, - }, -}); - -function _toSeconds(ms: number): number { - return Math.floor(ms / 1000); -} - -AxiosClient.interceptors.response.use(function interceptorHorizonResponse( - response: AxiosResponse, -) { - const hostname = URI(response.config.url!).hostname(); - const serverTime = _toSeconds(Date.parse(response.headers.date)); - const localTimeRecorded = _toSeconds(new Date().getTime()); - - if (!isNaN(serverTime)) { - SERVER_TIME_MAP[hostname] = { - serverTime, - localTimeRecorded, - }; - } - - return response; -}); - -export default AxiosClient; - -/** - * Given a hostname, get the current time of that server (i.e., use the last- - * recorded server time and offset it by the time since then.) If there IS no - * recorded server time, or it's been 5 minutes since the last, return null. - * @param {string} hostname Hostname of a Soroban-RPC server. - * @returns {number} The UNIX timestamp (in seconds, not milliseconds) - * representing the current time on that server, or `null` if we don't have - * a record of that time. - */ -export function getCurrentServerTime(hostname: string): number | null { - const entry = SERVER_TIME_MAP[hostname]; - - if (!entry || !entry.localTimeRecorded || !entry.serverTime) { - return null; - } - - const { serverTime, localTimeRecorded } = entry; - const currentTime = _toSeconds(new Date().getTime()); - - // if it's been more than 5 minutes from the last time, then null it out - if (currentTime - localTimeRecorded > 60 * 5) { - return null; - } - - return currentTime - localTimeRecorded + serverTime; -} diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 5aa559806..701c5d300 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -8,7 +8,7 @@ module.exports = { chai: true, sinon: true, expect: true, - HorizonAxiosClient: true, + AxiosClient: true, }, rules: { "no-unused-vars": 0, diff --git a/test/test-browser.js b/test/test-browser.js index 430811c72..1b1399bc6 100644 --- a/test/test-browser.js +++ b/test/test-browser.js @@ -1,4 +1,4 @@ /* eslint-disable no-undef */ chai.use(require("chai-as-promised")); window.axios = StellarSdk.axios; -window.HorizonAxiosClient = StellarSdk.HorizonAxiosClient; +window.AxiosClient = StellarSdk.AxiosClient; diff --git a/test/test-nodejs.js b/test/test-nodejs.js index c6f25a9cf..3bffa50ac 100644 --- a/test/test-nodejs.js +++ b/test/test-nodejs.js @@ -5,8 +5,7 @@ global.StellarSdk = require("../lib/"); global.SorobanClient = global.StellarSdk.SorobanClient; global.axios = require("axios"); -global.HorizonAxiosClient = StellarSdk.HorizonAxiosClient; -global.AxiosClient = global.SorobanClient.AxiosClient; +global.AxiosClient = StellarSdk.AxiosClient; global.serverUrl = "https://horizon-live.stellar.org:1337/api/v1/jsonrpc"; var chaiAsPromised = require("chai-as-promised"); diff --git a/test/unit/horizon/claimable_balances.js b/test/unit/horizon/claimable_balances.js index d25680b13..26d29fcb1 100644 --- a/test/unit/horizon/claimable_balances.js +++ b/test/unit/horizon/claimable_balances.js @@ -5,7 +5,7 @@ describe("ClaimableBalanceCallBuilder", function () { this.server = new StellarSdk.Server( "https://horizon-live.stellar.org:1337", ); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); diff --git a/test/unit/horizon/horizon_path_test.js b/test/unit/horizon/horizon_path_test.js index 2b62adfdc..ef536d063 100644 --- a/test/unit/horizon/horizon_path_test.js +++ b/test/unit/horizon/horizon_path_test.js @@ -1,6 +1,6 @@ describe("horizon path tests", function () { beforeEach(function () { - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); diff --git a/test/unit/horizon/join_test.js b/test/unit/horizon/join_test.js index 39853a83d..6e383bcc1 100644 --- a/test/unit/horizon/join_test.js +++ b/test/unit/horizon/join_test.js @@ -5,7 +5,7 @@ describe("Server - CallBuilder#join", function () { this.server = new StellarSdk.Server( "https://horizon-live.stellar.org:1337", ); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); }); afterEach(function () { diff --git a/test/unit/horizon/liquidity_pool_endpoints_test.js b/test/unit/horizon/liquidity_pool_endpoints_test.js index 92ab3b196..c7ab0d1af 100644 --- a/test/unit/horizon/liquidity_pool_endpoints_test.js +++ b/test/unit/horizon/liquidity_pool_endpoints_test.js @@ -9,7 +9,7 @@ const LP_URL = BASE_URL + "/liquidity_pools"; describe("/liquidity_pools tests", function () { beforeEach(function () { this.server = new StellarSdk.Server(BASE_URL); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); diff --git a/test/unit/horizon/server_check_memo_required_test.js b/test/unit/horizon/server_check_memo_required_test.js index bde7f2bb6..2365a00d9 100644 --- a/test/unit/horizon/server_check_memo_required_test.js +++ b/test/unit/horizon/server_check_memo_required_test.js @@ -106,7 +106,7 @@ function mockAccountRequest(axiosMock, id, status, data = {}) { describe("server.js check-memo-required", function () { beforeEach(function () { this.server = new StellarSdk.Server("https://horizon-testnet.stellar.org"); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); }); afterEach(function () { diff --git a/test/unit/horizon/server_test.js b/test/unit/horizon/server_test.js index 0d1ff3b44..b8bdba5b4 100644 --- a/test/unit/horizon/server_test.js +++ b/test/unit/horizon/server_test.js @@ -5,7 +5,7 @@ describe("server.js non-transaction tests", function () { this.server = new StellarSdk.Server( "https://horizon-live.stellar.org:1337", ); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); @@ -47,7 +47,7 @@ describe("server.js non-transaction tests", function () { // use MockAdapter instead of this.axiosMock // because we don't want to replace the get function // we need to use axios's one so interceptors run!! - this.axiosMockAdapter = new MockAdapter(HorizonAxiosClient); + this.axiosMockAdapter = new MockAdapter(AxiosClient); }); afterEach(function () { diff --git a/test/unit/horizon/server_transaction_test.js b/test/unit/horizon/server_transaction_test.js index 50ea7d49c..be142b145 100644 --- a/test/unit/horizon/server_transaction_test.js +++ b/test/unit/horizon/server_transaction_test.js @@ -6,7 +6,7 @@ describe("server.js transaction tests", function () { this.server = new StellarSdk.Server( "https://horizon-live.stellar.org:1337", ); - this.axiosMock = sinon.mock(HorizonAxiosClient); + this.axiosMock = sinon.mock(AxiosClient); let transaction = new StellarSdk.TransactionBuilder(account, { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET, From 4743c4481a108e5be4d5e6d8344288b204ed74da Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 15:05:28 -0700 Subject: [PATCH 06/14] Finish axios generalization --- src/call_builder.ts | 2 +- src/server.ts | 2 +- src/soroban/index.ts | 4 +- src/soroban/jsonrpc.ts | 2 +- src/soroban/server.ts | 2 +- ...os_client_test.js => axios_client_test.js} | 0 test/unit/horizon/call_builders_test.js | 9 ++-- .../{horizon_path_test.js => path_test.js} | 0 test/unit/horizon/server_test.js | 47 ++++++++----------- test/unit/soroban/get_account_test.js | 2 - .../{constructor_test.js => server_test.js} | 4 +- test/unit/{horizon => }/utils_test.js | 0 12 files changed, 29 insertions(+), 45 deletions(-) rename test/unit/{horizon/horizon_axios_client_test.js => axios_client_test.js} (100%) rename test/unit/horizon/{horizon_path_test.js => path_test.js} (100%) rename test/unit/soroban/{constructor_test.js => server_test.js} (87%) rename test/unit/{horizon => }/utils_test.js (100%) diff --git a/src/call_builder.ts b/src/call_builder.ts index 080afae25..db3a26de6 100644 --- a/src/call_builder.ts +++ b/src/call_builder.ts @@ -3,7 +3,7 @@ import URITemplate from "urijs/src/URITemplate"; import { BadRequestError, NetworkError, NotFoundError } from "./errors"; import { Horizon } from "./horizon_api"; -import AxiosClient from "./horizon_axios_client"; +import AxiosClient from "./axios"; import { ServerApi } from "./server_api"; /* tslint:disable-next-line:no-var-requires */ diff --git a/src/server.ts b/src/server.ts index 0c8866798..bed6c1001 100644 --- a/src/server.ts +++ b/src/server.ts @@ -40,7 +40,7 @@ import { TransactionCallBuilder } from "./transaction_call_builder"; import AxiosClient, { getCurrentServerTime, -} from "./horizon_axios_client"; +} from "./axios"; export const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; diff --git a/src/soroban/index.ts b/src/soroban/index.ts index 11003a0b3..07a761896 100644 --- a/src/soroban/index.ts +++ b/src/soroban/index.ts @@ -1,8 +1,6 @@ // tslint:disable-next-line: no-reference /// -export { version } from './axios'; - // Expose all types and helpers export * from "./soroban_rpc"; export * from "./transaction"; @@ -15,6 +13,6 @@ export { default as AxiosClient, SERVER_TIME_MAP, getCurrentServerTime, -} from "./axios"; +} from "../axios"; export default module.exports; diff --git a/src/soroban/jsonrpc.ts b/src/soroban/jsonrpc.ts index a1e1ea3a2..f5c4fa634 100644 --- a/src/soroban/jsonrpc.ts +++ b/src/soroban/jsonrpc.ts @@ -1,4 +1,4 @@ -import axios from "./axios"; +import axios from "axios"; import { hasOwnProperty } from "./utils"; export type Id = string | number; diff --git a/src/soroban/server.ts b/src/soroban/server.ts index b33f74ee4..029ecd708 100644 --- a/src/soroban/server.ts +++ b/src/soroban/server.ts @@ -11,7 +11,7 @@ import { } from "stellar-base"; import URI from "urijs"; -import AxiosClient from "./axios"; +import AxiosClient from "../axios"; import { Friendbot } from "./friendbot"; import * as jsonrpc from "./jsonrpc"; import { SorobanRpc } from "./soroban_rpc"; diff --git a/test/unit/horizon/horizon_axios_client_test.js b/test/unit/axios_client_test.js similarity index 100% rename from test/unit/horizon/horizon_axios_client_test.js rename to test/unit/axios_client_test.js diff --git a/test/unit/horizon/call_builders_test.js b/test/unit/horizon/call_builders_test.js index 80541b7ec..d0ef4bc3a 100644 --- a/test/unit/horizon/call_builders_test.js +++ b/test/unit/horizon/call_builders_test.js @@ -1,16 +1,15 @@ const URI = require("urijs"); -const CallBuilder = require("../../lib/call_builder").CallBuilder; +const CallBuilder = require("../../../lib/call_builder"); // bc not exported describe("CallBuilder functions", function () { it("doesn't mutate the constructor passed url argument (it clones it instead)", function () { let arg = URI("https://onedom.ain/"); + const builder = new CallBuilder(arg); builder.url.segment("one_segment"); builder.checkFilter(); - expect(arg.toString()).not.to.be.equal("https://onedom.ain/one_segment"); // https://onedom.ain/ - expect(builder.url.toString()).to.be.equal( - "https://onedom.ain/one_segment", - ); + expect(arg.toString()).not.to.equal("https://onedom.ain/one_segment"); // https://onedom.ain/ + expect(builder.url.toString()).to.equal("https://onedom.ain/one_segment"); }); }); diff --git a/test/unit/horizon/horizon_path_test.js b/test/unit/horizon/path_test.js similarity index 100% rename from test/unit/horizon/horizon_path_test.js rename to test/unit/horizon/path_test.js diff --git a/test/unit/horizon/server_test.js b/test/unit/horizon/server_test.js index b8bdba5b4..a35dffc8d 100644 --- a/test/unit/horizon/server_test.js +++ b/test/unit/horizon/server_test.js @@ -1,10 +1,25 @@ const MockAdapter = require("axios-mock-adapter"); -describe("server.js non-transaction tests", function () { - beforeEach(function () { - this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337", +describe("Horizon Server constructor", function () { + const serverUrl = 'https://horizon-live.stellar.org:1337'; + let insecureServerUrl = serverUrl.replace("https://", "http://"); + + it("throws error for insecure server", function () { + expect(() => new StellarSdk.Server(insecureServerUrl)).to.throw( + /Cannot connect to insecure horizon server/i ); + }); + + it("allow insecure server when opts.allowHttp flag is set", function () { + expect( + () => new StellarSdk.Server(insecureServerUrl, { allowHttp: true }) + ).to.not.throw(); + }); +}); + +describe("Horizon Server non-transaction tests", function () { + beforeEach(function () { + this.server = new StellarSdk.Server('https://horizon-live.stellar.org:1337'); this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); @@ -14,30 +29,6 @@ describe("server.js non-transaction tests", function () { this.axiosMock.restore(); }); - describe("Server.constructor", function () { - it("throws error for insecure server", function () { - expect( - () => new StellarSdk.Server("http://horizon-live.stellar.org:1337"), - ).to.throw(/Cannot connect to insecure horizon server/); - }); - - it("allow insecure server when opts.allowHttp flag is set", function () { - expect( - () => - new StellarSdk.Server("http://horizon-live.stellar.org:1337", { - allowHttp: true, - }), - ).to.not.throw(); - }); - - it("allow insecure server when global Config.allowHttp flag is set", function () { - StellarSdk.Config.setAllowHttp(true); - expect( - () => new StellarSdk.Server("http://horizon-live.stellar.org:1337"), - ).to.not.throw(); - }); - }); - describe("Server.fetchTimebounds", function () { let clock; diff --git a/test/unit/soroban/get_account_test.js b/test/unit/soroban/get_account_test.js index 4843823cb..346c588c6 100644 --- a/test/unit/soroban/get_account_test.js +++ b/test/unit/soroban/get_account_test.js @@ -6,8 +6,6 @@ describe("Server#getAccount", function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); - - console.log('client:', AxiosClient); }); afterEach(function () { diff --git a/test/unit/soroban/constructor_test.js b/test/unit/soroban/server_test.js similarity index 87% rename from test/unit/soroban/constructor_test.js rename to test/unit/soroban/server_test.js index a528d94ae..4cabb0bbc 100644 --- a/test/unit/soroban/constructor_test.js +++ b/test/unit/soroban/server_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server.constructor", function () { +describe("Soroban Server.constructor", function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); diff --git a/test/unit/horizon/utils_test.js b/test/unit/utils_test.js similarity index 100% rename from test/unit/horizon/utils_test.js rename to test/unit/utils_test.js From 066a8dbecb58aeb51110a5081774ceb31a96dcc0 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 15:19:47 -0700 Subject: [PATCH 07/14] Rename/unification passes test --- package.json | 1 + src/axios.ts | 6 +++--- src/index.ts | 8 ++------ src/soroban/index.ts | 5 ----- src/soroban/jsonrpc.ts | 2 +- test/unit/horizon/call_builders_test.js | 2 +- 6 files changed, 8 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index 4b3e30f4f..483b5b216 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose", "test": "yarn build && yarn test:node && yarn test:integration && yarn test:browser", "test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'", + "test:node:soroban": "yarn _nyc mocha --recursive 'test/unit/soroban/**/*.js'", "test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'", "test:browser": "karma start config/karma.conf.js", "fmt": "yarn eslint -c .eslintrc.js src/ --fix && yarn _prettier", diff --git a/src/axios.ts b/src/axios.ts index 22184d99f..b6775d6e9 100644 --- a/src/axios.ts +++ b/src/axios.ts @@ -2,7 +2,7 @@ import axios, { AxiosResponse } from "axios"; import URI from "urijs"; /* tslint:disable-next-line:no-var-requires */ -const version = require("../package.json").version; +export const version = require("../package.json").version; export interface ServerTime { serverTime: number; @@ -35,7 +35,7 @@ function _toSeconds(ms: number): number { } AxiosClient.interceptors.response.use( - function interceptorHorizonResponse(response: AxiosResponse) { + (response: AxiosResponse) => { const hostname = URI(response.config.url!).hostname(); const serverTime = _toSeconds(Date.parse(response.headers.date)); const localTimeRecorded = _toSeconds(new Date().getTime()); @@ -48,7 +48,7 @@ AxiosClient.interceptors.response.use( } return response; - }, + } ); export default AxiosClient; diff --git a/src/index.ts b/src/index.ts index 195ae2288..66cdddf11 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,6 @@ // tslint:disable-next-line: no-reference /// -/* tslint:disable:no-var-requires */ -const version = require("../package.json").version; - // Expose all types export * from "./horizon_api"; export * from "./server_api"; @@ -24,7 +21,8 @@ export { export { default as AxiosClient, SERVER_TIME_MAP, - getCurrentServerTime + getCurrentServerTime, + version } from "./axios"; export * from "./utils"; @@ -34,6 +32,4 @@ export * from "stellar-base"; // expose all Soroban stuff export * as SorobanClient from './soroban'; -export { version }; - export default module.exports; diff --git a/src/soroban/index.ts b/src/soroban/index.ts index 07a761896..68ac28367 100644 --- a/src/soroban/index.ts +++ b/src/soroban/index.ts @@ -9,10 +9,5 @@ export * from 'stellar-base'; // http classes to expose export { Server } from "./server"; -export { - default as AxiosClient, - SERVER_TIME_MAP, - getCurrentServerTime, -} from "../axios"; export default module.exports; diff --git a/src/soroban/jsonrpc.ts b/src/soroban/jsonrpc.ts index f5c4fa634..d9c8bcef0 100644 --- a/src/soroban/jsonrpc.ts +++ b/src/soroban/jsonrpc.ts @@ -1,4 +1,4 @@ -import axios from "axios"; +import {default as axios} from "../axios"; import { hasOwnProperty } from "./utils"; export type Id = string | number; diff --git a/test/unit/horizon/call_builders_test.js b/test/unit/horizon/call_builders_test.js index d0ef4bc3a..cf4828949 100644 --- a/test/unit/horizon/call_builders_test.js +++ b/test/unit/horizon/call_builders_test.js @@ -1,5 +1,5 @@ const URI = require("urijs"); -const CallBuilder = require("../../../lib/call_builder"); // bc not exported +const { CallBuilder } = require("../../../lib/call_builder"); // bc not exported describe("CallBuilder functions", function () { it("doesn't mutate the constructor passed url argument (it clones it instead)", function () { From d7517392cb4d607963fe41ea63fce374e8283429 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 15:23:02 -0700 Subject: [PATCH 08/14] Run prettier on the whole codebase --- .eslintrc.js | 12 +- package.json | 2 +- src/.eslintrc.js | 50 +- src/browser.ts | 6 +- src/index.ts | 28 +- src/soroban/browser.ts | 6 +- src/soroban/index.ts | 6 +- test/.eslintrc.js | 8 +- test/integration/apiary.js | 36 +- test/integration/client_headers_test.js | 16 +- test/integration/streaming_test.js | 44 +- test/test-browser.js | 2 +- test/test-nodejs.js | 16 +- test/unit/axios_client_test.js | 20 +- test/unit/horizon/browser_test.js | 10 +- test/unit/horizon/call_builders_test.js | 14 +- test/unit/horizon/claimable_balances.js | 114 +- test/unit/horizon/federation_server_test.js | 295 +- test/unit/horizon/join_test.js | 142 +- .../horizon/liquidity_pool_endpoints_test.js | 1242 +++---- test/unit/horizon/path_test.js | 68 +- .../server_check_memo_required_test.js | 134 +- test/unit/horizon/server_test.js | 2842 +++++++++-------- test/unit/horizon/server_transaction_test.js | 204 +- .../horizon/stellar_toml_resolver_test.js | 100 +- test/unit/soroban/get_account_test.js | 60 +- test/unit/soroban/get_contract_data_test.js | 61 +- test/unit/soroban/get_events_test.js | 166 +- test/unit/soroban/get_health_test.js | 16 +- test/unit/soroban/get_latest_ledger_test.js | 18 +- test/unit/soroban/get_network_test.js | 20 +- test/unit/soroban/get_transaction_test.js | 34 +- test/unit/soroban/request_airdrop_test.js | 148 +- test/unit/soroban/send_transaction_test.js | 40 +- test/unit/soroban/server_test.js | 8 +- .../unit/soroban/simulate_transaction_test.js | 76 +- test/unit/utils_test.js | 1446 ++++----- 37 files changed, 3746 insertions(+), 3764 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 1ad7098b9..f6ef1fe3c 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,11 +1,11 @@ module.exports = { env: { - es6: true, + es6: true }, - extends: ["airbnb-base", "prettier"], - plugins: ["@babel", "prettier", "prefer-import"], - parser: "@babel/eslint-parser", + extends: ['airbnb-base', 'prettier'], + plugins: ['@babel', 'prettier', 'prefer-import'], + parser: '@babel/eslint-parser', rules: { - "node/no-unpublished-require": 0, - }, + 'node/no-unpublished-require': 0 + } }; diff --git a/package.json b/package.json index 483b5b216..19857e764 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "_build": "yarn build:node && yarn build:browser", "_babel": "babel --extensions '.ts' --out-dir lib/ src/", "_nyc": "nyc --nycrc-path config/.nycrc", - "_prettier": "prettier --ignore-path config/.prettierignore --write './**/*.js'" + "_prettier": "prettier --config config/prettier.config.js --ignore-path config/.prettierignore --write './**/*.js'" }, "husky": { "hooks": { diff --git a/src/.eslintrc.js b/src/.eslintrc.js index 7ceb3272d..128adddd7 100644 --- a/src/.eslintrc.js +++ b/src/.eslintrc.js @@ -1,39 +1,39 @@ module.exports = { env: { - es6: true, + es6: true }, rules: { // OFF - "import/prefer-default-export": 0, - "node/no-unsupported-features/es-syntax": 0, - "node/no-unsupported-features/es-builtins": 0, + 'import/prefer-default-export': 0, + 'node/no-unsupported-features/es-syntax': 0, + 'node/no-unsupported-features/es-builtins': 0, camelcase: 0, - "class-methods-use-this": 0, - "linebreak-style": 0, - "new-cap": 0, - "no-param-reassign": 0, - "no-underscore-dangle": 0, - "no-use-before-define": 0, - "prefer-destructuring": 0, - "lines-between-class-members": 0, + 'class-methods-use-this': 0, + 'linebreak-style': 0, + 'new-cap': 0, + 'no-param-reassign': 0, + 'no-underscore-dangle': 0, + 'no-use-before-define': 0, + 'prefer-destructuring': 0, + 'lines-between-class-members': 0, // WARN - "prefer-import/prefer-import-over-require": [1], - "no-console": ["warn", { allow: ["assert"] }], - "no-debugger": 1, - "no-unused-vars": 1, - "arrow-body-style": 1, - "valid-jsdoc": [ + 'prefer-import/prefer-import-over-require': [1], + 'no-console': ['warn', { allow: ['assert'] }], + 'no-debugger': 1, + 'no-unused-vars': 1, + 'arrow-body-style': 1, + 'valid-jsdoc': [ 1, { - requireReturnDescription: false, - }, + requireReturnDescription: false + } ], - "prefer-const": 1, - "object-shorthand": 1, - "require-await": 1, + 'prefer-const': 1, + 'object-shorthand': 1, + 'require-await': 1, // ERROR - "no-unused-expressions": [2, { allowTaggedTemplates: true }], - }, + 'no-unused-expressions': [2, { allowTaggedTemplates: true }] + } }; diff --git a/src/browser.ts b/src/browser.ts index 03027026b..bbd6932ff 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -1,9 +1,9 @@ /* tslint:disable:no-var-requires */ -export * from "./index"; -export * as StellarBase from "stellar-base"; +export * from './index'; +export * as StellarBase from 'stellar-base'; -import axios from "axios"; // idk why axios is weird +import axios from 'axios'; // idk why axios is weird export { axios }; export default module.exports; diff --git a/src/index.ts b/src/index.ts index 66cdddf11..2fed0bc7f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,32 +2,32 @@ /// // Expose all types -export * from "./horizon_api"; -export * from "./server_api"; +export * from './horizon_api'; +export * from './server_api'; // stellar-sdk classes to expose -export * from "./account_response"; -export * from "./errors"; -export { Config } from "./config"; -export { Server } from "./server"; +export * from './account_response'; +export * from './errors'; +export { Config } from './config'; +export { Server } from './server'; export { FederationServer, - FEDERATION_RESPONSE_MAX_SIZE -} from "./federation_server"; + FEDERATION_RESPONSE_MAX_SIZE, +} from './federation_server'; export { StellarTomlResolver, - STELLAR_TOML_MAX_SIZE -} from "./stellar_toml_resolver"; + STELLAR_TOML_MAX_SIZE, +} from './stellar_toml_resolver'; export { default as AxiosClient, SERVER_TIME_MAP, getCurrentServerTime, - version -} from "./axios"; -export * from "./utils"; + version, +} from './axios'; +export * from './utils'; // expose classes and functions from stellar-base -export * from "stellar-base"; +export * from 'stellar-base'; // expose all Soroban stuff export * as SorobanClient from './soroban'; diff --git a/src/soroban/browser.ts b/src/soroban/browser.ts index 03027026b..bbd6932ff 100644 --- a/src/soroban/browser.ts +++ b/src/soroban/browser.ts @@ -1,9 +1,9 @@ /* tslint:disable:no-var-requires */ -export * from "./index"; -export * as StellarBase from "stellar-base"; +export * from './index'; +export * as StellarBase from 'stellar-base'; -import axios from "axios"; // idk why axios is weird +import axios from 'axios'; // idk why axios is weird export { axios }; export default module.exports; diff --git a/src/soroban/index.ts b/src/soroban/index.ts index 68ac28367..981df7b9b 100644 --- a/src/soroban/index.ts +++ b/src/soroban/index.ts @@ -2,12 +2,12 @@ /// // Expose all types and helpers -export * from "./soroban_rpc"; -export * from "./transaction"; +export * from './soroban_rpc'; +export * from './transaction'; export * from 'stellar-base'; // http classes to expose -export { Server } from "./server"; +export { Server } from './server'; export default module.exports; diff --git a/test/.eslintrc.js b/test/.eslintrc.js index 701c5d300..84f965809 100644 --- a/test/.eslintrc.js +++ b/test/.eslintrc.js @@ -1,6 +1,6 @@ module.exports = { env: { - mocha: true, + mocha: true }, globals: { StellarSdk: true, @@ -8,9 +8,9 @@ module.exports = { chai: true, sinon: true, expect: true, - AxiosClient: true, + AxiosClient: true }, rules: { - "no-unused-vars": 0, - }, + 'no-unused-vars': 0 + } }; diff --git a/test/integration/apiary.js b/test/integration/apiary.js index 7c95d40fc..c8f3bb607 100644 --- a/test/integration/apiary.js +++ b/test/integration/apiary.js @@ -3,19 +3,19 @@ // All endpoints from here are tested: // https://docs.google.com/document/d/1pXL8kr1a2vfYSap9T67R-g72B_WWbaE1YsLMa04OgoU/edit -const _ = require("lodash"); +const _ = require('lodash'); -const MOCK_SERVER = "https://private-d133c-ammmock.apiary-mock.com"; +const MOCK_SERVER = 'https://private-d133c-ammmock.apiary-mock.com'; -describe("tests the /liquidity_pools endpoint", function () { +describe('tests the /liquidity_pools endpoint', function () { const lpId = - "0569b19c75d7ecadce50501fffad6fe8ba4652455df9e1cc96dc408141124dd5"; + '0569b19c75d7ecadce50501fffad6fe8ba4652455df9e1cc96dc408141124dd5'; const server = new StellarSdk.Server(MOCK_SERVER, { allowHttp: true }); - it("GET /", function (done) { + it('GET /', function (done) { chai .request(MOCK_SERVER) - .get("/liquidity_pools") + .get('/liquidity_pools') .end(function (err, res) { if (err != null) done(err); expect(res.body).not.to.be.null; @@ -31,7 +31,7 @@ describe("tests the /liquidity_pools endpoint", function () { }); }); - it("GET /", function (done) { + it('GET /', function (done) { chai .request(MOCK_SERVER) .get(`/liquidity_pools/${lpId}`) @@ -55,7 +55,7 @@ describe("tests the /liquidity_pools endpoint", function () { effects: server.effects(), operations: server.operations(), trades: server.trades(), - transactions: server.transactions(), + transactions: server.transactions() }; Object.keys(testCases).forEach((suffix) => { @@ -77,7 +77,7 @@ describe("tests the /liquidity_pools endpoint", function () { // TransactionRecord values don't map 1-to-1 to the JSON (see // e.g. the ledger vs. ledger_attr properties), so we do a "best // effort" validation by checking that at least the keys exist. - if (suffix === "transactions") { + if (suffix === 'transactions') { record = Object.keys(record); expectedRecord = Object.keys(expectedRecord); } @@ -92,13 +92,13 @@ describe("tests the /liquidity_pools endpoint", function () { }); }); -describe("tests the /accounts endpoint", function () { +describe('tests the /accounts endpoint', function () { const server = new StellarSdk.Server(MOCK_SERVER, { allowHttp: true }); - it("GET /", function (done) { + it('GET /', function (done) { chai .request(MOCK_SERVER) - .get("/accounts") + .get('/accounts') .end(function (err, res) { if (err != null) return done(err); expect(res.body).not.to.be.null; @@ -115,13 +115,13 @@ describe("tests the /accounts endpoint", function () { }); }); - it("GET /?liquidity_pool=", function (done) { + it('GET /?liquidity_pool=', function (done) { const lpId = - "0569b19c75d7ecadce50501fffad6fe8ba4652455df9e1cc96dc408141124dd5"; + '0569b19c75d7ecadce50501fffad6fe8ba4652455df9e1cc96dc408141124dd5'; chai .request(MOCK_SERVER) - .get("/accounts") + .get('/accounts') .query({ liquidity_pool: lpId }) .end(function (err, res) { if (err != null) return done(err); @@ -139,9 +139,9 @@ describe("tests the /accounts endpoint", function () { }); }); - it("GET /", function (done) { + it('GET /', function (done) { const accountId = - "GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3"; + 'GDQNY3PBOJOKYZSRMK2S7LHHGWZIUISD4QORETLMXEWXBI7KFZZMKTL3'; chai .request(MOCK_SERVER) @@ -157,7 +157,7 @@ describe("tests the /accounts endpoint", function () { .then((resp) => { // find the pool share balance(s) const poolShares = resp.balances.filter( - (b) => b.asset_type === "liquidity_pool_shares", + (b) => b.asset_type === 'liquidity_pool_shares' ); expect(poolShares).to.have.lengthOf(1); diff --git a/test/integration/client_headers_test.js b/test/integration/client_headers_test.js index f82c4d7ff..bf76ac208 100644 --- a/test/integration/client_headers_test.js +++ b/test/integration/client_headers_test.js @@ -1,19 +1,19 @@ -const http = require("http"); -const url = require("url"); +const http = require('http'); +const url = require('url'); const port = 3100; -describe("integration tests: client headers", function (done) { - if (typeof window !== "undefined") { +describe('integration tests: client headers', function (done) { + if (typeof window !== 'undefined') { done(); return; } - it("sends client via headers", function (done) { + it('sends client via headers', function (done) { let server; const requestHandler = (request, response) => { - expect(request.headers["x-client-name"]).to.be.equal("js-soroban-client"); - expect(request.headers["x-client-version"]).to.match( + expect(request.headers['x-client-name']).to.be.equal('js-soroban-client'); + expect(request.headers['x-client-version']).to.match( /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/ ); response.end(); @@ -28,7 +28,7 @@ describe("integration tests: client headers", function (done) { } new SorobanClient.Server(`http://localhost:${port}`, { - allowHttp: true, + allowHttp: true }).getHealth(); }); }); diff --git a/test/integration/streaming_test.js b/test/integration/streaming_test.js index 080fafc1c..4d5f16bfd 100644 --- a/test/integration/streaming_test.js +++ b/test/integration/streaming_test.js @@ -1,14 +1,14 @@ -const http = require("http"); -const url = require("url"); +const http = require('http'); +const url = require('url'); const port = 3100; -describe("integration tests: streaming", function (done) { - if (typeof window !== "undefined") { +describe('integration tests: streaming', function (done) { + if (typeof window !== 'undefined') { done(); return; } - it("handles onerror", function (done) { + it('handles onerror', function (done) { let server; let closeStream; @@ -27,7 +27,7 @@ describe("integration tests: streaming", function (done) { } closeStream = new StellarSdk.Server(`http://localhost:${port}`, { - allowHttp: true, + allowHttp: true }) .operations() .stream({ @@ -35,12 +35,12 @@ describe("integration tests: streaming", function (done) { server.close(); closeStream(); done(); - }, + } }); }); }); - it("handles close message", function (done) { + it('handles close message', function (done) { let server; let closeStream; @@ -51,18 +51,18 @@ describe("integration tests: streaming", function (done) { return; } - request.once("close", (e) => { + request.once('close', (e) => { closeStream(); server.close(); done(); }); response.writeHead(200, { - "Content-Type": "text/event-stream", - "Cache-Control": "no-cache", - Connection: "keep-alive", + 'Content-Type': 'text/event-stream', + 'Cache-Control': 'no-cache', + Connection: 'keep-alive' }); - response.write("retry: 10\nevent: close\ndata: byebye\n\n"); + response.write('retry: 10\nevent: close\ndata: byebye\n\n'); }; server = http.createServer(requestHandler); @@ -73,23 +73,23 @@ describe("integration tests: streaming", function (done) { } closeStream = new StellarSdk.Server(`http://localhost:${port}`, { - allowHttp: true, + allowHttp: true }) .operations() .stream({ onmessage: (m) => { - done("unexpected message " + JSON.stringify(m)); + done('unexpected message ' + JSON.stringify(m)); }, onerror: (err) => { done(err); - }, + } }); }); }); }); -describe("end-to-end tests: real streaming", function (done) { - if (typeof window !== "undefined") { +describe('end-to-end tests: real streaming', function (done) { + if (typeof window !== 'undefined') { done(); return; } @@ -97,9 +97,9 @@ describe("end-to-end tests: real streaming", function (done) { // stream transactions from pubnet for a while and ensure that we cross a // ledger boundary (if streaming is broken, we will get stuck on a single // ledger's transaction batch). - it("streams in perpetuity", function (done) { + it('streams in perpetuity', function (done) { const DURATION = 30; - const server = new StellarSdk.Server("https://horizon.stellar.org"); + const server = new StellarSdk.Server('https://horizon.stellar.org'); this.timeout((DURATION + 5) * 1000); // pad timeout let transactions = []; @@ -118,12 +118,12 @@ describe("end-to-end tests: real streaming", function (done) { let closeHandler = server .transactions() - .cursor("now") + .cursor('now') .stream({ onmessage: (msg) => { transactions.push(msg); }, - onerror: finishTest, + onerror: finishTest }); let timeout = setTimeout(finishTest, DURATION * 1000); diff --git a/test/test-browser.js b/test/test-browser.js index 1b1399bc6..32b4ea88c 100644 --- a/test/test-browser.js +++ b/test/test-browser.js @@ -1,4 +1,4 @@ /* eslint-disable no-undef */ -chai.use(require("chai-as-promised")); +chai.use(require('chai-as-promised')); window.axios = StellarSdk.axios; window.AxiosClient = StellarSdk.AxiosClient; diff --git a/test/test-nodejs.js b/test/test-nodejs.js index 3bffa50ac..761ab160f 100644 --- a/test/test-nodejs.js +++ b/test/test-nodejs.js @@ -1,19 +1,19 @@ /* eslint-disable no-undef */ -require("@babel/register"); -global.StellarSdk = require("../lib/"); +require('@babel/register'); +global.StellarSdk = require('../lib/'); global.SorobanClient = global.StellarSdk.SorobanClient; -global.axios = require("axios"); +global.axios = require('axios'); global.AxiosClient = StellarSdk.AxiosClient; -global.serverUrl = "https://horizon-live.stellar.org:1337/api/v1/jsonrpc"; +global.serverUrl = 'https://horizon-live.stellar.org:1337/api/v1/jsonrpc'; -var chaiAsPromised = require("chai-as-promised"); -var chaiHttp = require("chai-http"); -global.chai = require("chai"); +var chaiAsPromised = require('chai-as-promised'); +var chaiHttp = require('chai-http'); +global.chai = require('chai'); global.chai.should(); global.chai.use(chaiAsPromised); global.chai.use(chaiHttp); global.expect = global.chai.expect; -global.sinon = require("sinon"); +global.sinon = require('sinon'); diff --git a/test/unit/axios_client_test.js b/test/unit/axios_client_test.js index a56e8622b..7abe2eb9f 100644 --- a/test/unit/axios_client_test.js +++ b/test/unit/axios_client_test.js @@ -1,7 +1,7 @@ const SERVER_TIME_MAP = StellarSdk.SERVER_TIME_MAP; const getCurrentServerTime = StellarSdk.getCurrentServerTime; -describe("getCurrentServerTime", () => { +describe('getCurrentServerTime', () => { let clock; beforeEach(() => { @@ -14,27 +14,27 @@ describe("getCurrentServerTime", () => { }); it("returns null when the hostname hasn't been hit", () => { - expect(getCurrentServerTime("host")).to.be.null; + expect(getCurrentServerTime('host')).to.be.null; }); - it("returns null when no time is available", () => { + it('returns null when no time is available', () => { SERVER_TIME_MAP.host = {}; - expect(getCurrentServerTime("host")).to.be.null; + expect(getCurrentServerTime('host')).to.be.null; }); - it("returns null when the old time is too old", () => { + it('returns null when the old time is too old', () => { SERVER_TIME_MAP.host = { serverTime: 10, - localTimeRecorded: 5, + localTimeRecorded: 5 }; - expect(getCurrentServerTime("host")).to.be.null; + expect(getCurrentServerTime('host')).to.be.null; }); - it("returns the delta between then and now", () => { + it('returns the delta between then and now', () => { SERVER_TIME_MAP.host = { serverTime: 10, - localTimeRecorded: 5005, + localTimeRecorded: 5005 }; - expect(getCurrentServerTime("host")).to.equal(55); + expect(getCurrentServerTime('host')).to.equal(55); }); }); diff --git a/test/unit/horizon/browser_test.js b/test/unit/horizon/browser_test.js index f750ed221..9088b80b9 100644 --- a/test/unit/horizon/browser_test.js +++ b/test/unit/horizon/browser_test.js @@ -1,11 +1,11 @@ -describe("Browser version tests", function () { - it("lodash is not exported globally", function () { - if (typeof window !== "undefined") { - expect(typeof _ === "undefined").to.be.true; +describe('Browser version tests', function () { + it('lodash is not exported globally', function () { + if (typeof window !== 'undefined') { + expect(typeof _ === 'undefined').to.be.true; } }); - it("defines globals", function() { + it('defines globals', function () { expect(StellarSdk).to.not.be.undefined; expect(SorobanClient).to.not.be.undefined; }); diff --git a/test/unit/horizon/call_builders_test.js b/test/unit/horizon/call_builders_test.js index cf4828949..984b7dd8f 100644 --- a/test/unit/horizon/call_builders_test.js +++ b/test/unit/horizon/call_builders_test.js @@ -1,15 +1,15 @@ -const URI = require("urijs"); -const { CallBuilder } = require("../../../lib/call_builder"); // bc not exported +const URI = require('urijs'); +const { CallBuilder } = require('../../../lib/call_builder'); // bc not exported -describe("CallBuilder functions", function () { +describe('CallBuilder functions', function () { it("doesn't mutate the constructor passed url argument (it clones it instead)", function () { - let arg = URI("https://onedom.ain/"); + let arg = URI('https://onedom.ain/'); const builder = new CallBuilder(arg); - builder.url.segment("one_segment"); + builder.url.segment('one_segment'); builder.checkFilter(); - expect(arg.toString()).not.to.equal("https://onedom.ain/one_segment"); // https://onedom.ain/ - expect(builder.url.toString()).to.equal("https://onedom.ain/one_segment"); + expect(arg.toString()).not.to.equal('https://onedom.ain/one_segment'); // https://onedom.ain/ + expect(builder.url.toString()).to.equal('https://onedom.ain/one_segment'); }); }); diff --git a/test/unit/horizon/claimable_balances.js b/test/unit/horizon/claimable_balances.js index 26d29fcb1..7b98290fb 100644 --- a/test/unit/horizon/claimable_balances.js +++ b/test/unit/horizon/claimable_balances.js @@ -1,9 +1,7 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("ClaimableBalanceCallBuilder", function () { +describe('ClaimableBalanceCallBuilder', function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337", + 'https://horizon-live.stellar.org:1337' ); this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); @@ -14,44 +12,44 @@ describe("ClaimableBalanceCallBuilder", function () { this.axiosMock.restore(); }); - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { let singleBalanceResponse = { _links: { self: { - href: "horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", - }, + href: 'horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072' + } }, - id: "00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", - asset: "native", - amount: "200.0000000", - sponsor: "GBVFLWXYCIGPO3455XVFIKHS66FCT5AI64ZARKS7QJN4NF7K5FOXTJNL", + id: '00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072', + asset: 'native', + amount: '200.0000000', + sponsor: 'GBVFLWXYCIGPO3455XVFIKHS66FCT5AI64ZARKS7QJN4NF7K5FOXTJNL', last_modified_ledger: 38888, claimants: [ { destination: - "GBVFLWXYCIGPO3455XVFIKHS66FCT5AI64ZARKS7QJN4NF7K5FOXTJNL", + 'GBVFLWXYCIGPO3455XVFIKHS66FCT5AI64ZARKS7QJN4NF7K5FOXTJNL', predicate: { - unconditional: true, - }, - }, + unconditional: true + } + } ], paging_token: - "38888-00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", + '38888-00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072' }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances/00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072' + ) ) .returns(Promise.resolve({ data: singleBalanceResponse })); this.server .claimableBalances() .claimableBalance( - "00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072", + '00000000929b20b72e5890ab51c24f1cc46fa01c4f318d8d33367d24dd614cfdf5491072' ) .call() .then(function (response) { @@ -67,36 +65,36 @@ describe("ClaimableBalanceCallBuilder", function () { const data = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, next: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, prev: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc", - }, + href: 'https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc' + } }, _embedded: { - records: [], - }, + records: [] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances?sponsor=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .returns(Promise.resolve({ data })); this.server .claimableBalances() - .sponsor("GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD") + .sponsor('GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD') .call() .then(function (response) { - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -108,36 +106,36 @@ describe("ClaimableBalanceCallBuilder", function () { const data = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, next: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, prev: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc", - }, + href: 'https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc' + } }, _embedded: { - records: [], - }, + records: [] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances?claimant=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .returns(Promise.resolve({ data })); this.server .claimableBalances() - .claimant("GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD") + .claimant('GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD') .call() .then(function (response) { - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -149,26 +147,26 @@ describe("ClaimableBalanceCallBuilder", function () { const data = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, next: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=asc' }, prev: { - href: "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc", - }, + href: 'https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD&cursor=&limit=10&order=desc' + } }, _embedded: { - records: [], - }, + records: [] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .returns(Promise.resolve({ data })); @@ -176,14 +174,14 @@ describe("ClaimableBalanceCallBuilder", function () { .claimableBalances() .asset( new StellarSdk.Asset( - "USD", - "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'USD', + 'GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .call() .then(function (response) { - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { diff --git a/test/unit/horizon/federation_server_test.js b/test/unit/horizon/federation_server_test.js index b8d97181f..c91ba7880 100644 --- a/test/unit/horizon/federation_server_test.js +++ b/test/unit/horizon/federation_server_test.js @@ -1,10 +1,10 @@ -const http = require("http"); +const http = require('http'); -describe("federation-server.js tests", function () { +describe('federation-server.js tests', function () { beforeEach(function () { this.server = new StellarSdk.FederationServer( - "https://acme.com:1337/federation", - "stellar.org", + 'https://acme.com:1337/federation', + 'stellar.org' ); this.axiosMock = sinon.mock(axios); @@ -15,68 +15,68 @@ describe("federation-server.js tests", function () { this.axiosMock.verify(); // also restores }); - describe("FederationServer.constructor", function () { - it("throws error for insecure server", function () { + describe('FederationServer.constructor', function () { + it('throws error for insecure server', function () { expect( () => new StellarSdk.FederationServer( - "http://acme.com:1337/federation", - "stellar.org", - ), + 'http://acme.com:1337/federation', + 'stellar.org' + ) ).to.throw(/Cannot connect to insecure federation server/); }); - it("allow insecure server when opts.allowHttp flag is set", function () { + it('allow insecure server when opts.allowHttp flag is set', function () { expect( () => new StellarSdk.FederationServer( - "http://acme.com:1337/federation", - "stellar.org", - { allowHttp: true }, - ), + 'http://acme.com:1337/federation', + 'stellar.org', + { allowHttp: true } + ) ).to.not.throw(); }); - it("allow insecure server when global Config.allowHttp flag is set", function () { + it('allow insecure server when global Config.allowHttp flag is set', function () { StellarSdk.Config.setAllowHttp(true); expect( () => new StellarSdk.FederationServer( - "http://acme.com:1337/federation", - "stellar.org", - { allowHttp: true }, - ), + 'http://acme.com:1337/federation', + 'stellar.org', + { allowHttp: true } + ) ).to.not.throw(); }); }); - describe("FederationServer.resolveAddress", function () { + describe('FederationServer.resolveAddress', function () { beforeEach(function () { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org", - ), + 'https://acme.com:1337/federation?type=name&q=bob%2Astellar.org' + ) ) .returns( Promise.resolve({ data: { - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - }, - }), + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' + } + }) ); }); - it("requests is correct", function (done) { + it('requests is correct', function (done) { this.server - .resolveAddress("bob*stellar.org") + .resolveAddress('bob*stellar.org') .then((response) => { - expect(response.stellar_address).equals("bob*stellar.org"); + expect(response.stellar_address).equals('bob*stellar.org'); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ); done(); }) @@ -85,13 +85,13 @@ describe("federation-server.js tests", function () { }); }); - it("requests is correct for username as stellar address", function (done) { + it('requests is correct for username as stellar address', function (done) { this.server - .resolveAddress("bob") + .resolveAddress('bob') .then((response) => { - expect(response.stellar_address).equals("bob*stellar.org"); + expect(response.stellar_address).equals('bob*stellar.org'); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ); done(); }) @@ -101,35 +101,35 @@ describe("federation-server.js tests", function () { }); }); - describe("FederationServer.resolveAccountId", function () { + describe('FederationServer.resolveAccountId', function () { beforeEach(function () { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://acme.com:1337/federation?type=id&q=GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - ), + 'https://acme.com:1337/federation?type=id&q=GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' + ) ) .returns( Promise.resolve({ data: { - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - }, - }), + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' + } + }) ); }); - it("requests is correct", function (done) { + it('requests is correct', function (done) { this.server .resolveAccountId( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ) .then((response) => { - expect(response.stellar_address).equals("bob*stellar.org"); + expect(response.stellar_address).equals('bob*stellar.org'); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ); done(); }) @@ -139,35 +139,35 @@ describe("federation-server.js tests", function () { }); }); - describe("FederationServer.resolveTransactionId", function () { + describe('FederationServer.resolveTransactionId', function () { beforeEach(function () { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://acme.com:1337/federation?type=txid&q=3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", - ), + 'https://acme.com:1337/federation?type=txid&q=3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889' + ) ) .returns( Promise.resolve({ data: { - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - }, - }), + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' + } + }) ); }); - it("requests is correct", function (done) { + it('requests is correct', function (done) { this.server .resolveTransactionId( - "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", + '3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889' ) .then((response) => { - expect(response.stellar_address).equals("bob*stellar.org"); + expect(response.stellar_address).equals('bob*stellar.org'); expect(response.account_id).equals( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ); done(); }) @@ -177,168 +177,167 @@ describe("federation-server.js tests", function () { }); }); - describe("FederationServer.createForDomain", function () { - it("creates correct object", function (done) { + describe('FederationServer.createForDomain', function () { + it('creates correct object', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` # The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" -`, - }), +` + }) ); - StellarSdk.FederationServer.createForDomain("acme.com").then( + StellarSdk.FederationServer.createForDomain('acme.com').then( (federationServer) => { - expect(federationServer.serverURL.protocol()).equals("https"); + expect(federationServer.serverURL.protocol()).equals('https'); expect(federationServer.serverURL.hostname()).equals( - "api.stellar.org", + 'api.stellar.org' ); - expect(federationServer.serverURL.path()).equals("/federation"); - expect(federationServer.domain).equals("acme.com"); + expect(federationServer.serverURL.path()).equals('/federation'); + expect(federationServer.domain).equals('acme.com'); done(); - }, + } ); }); - it("fails when stellar.toml does not contain federation server info", function (done) { + it('fails when stellar.toml does not contain federation server info', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ - data: "", - }), + data: '' + }) ); - StellarSdk.FederationServer.createForDomain("acme.com") + StellarSdk.FederationServer.createForDomain('acme.com') .should.be.rejectedWith( - /stellar.toml does not contain FEDERATION_SERVER field/, + /stellar.toml does not contain FEDERATION_SERVER field/ ) .and.notify(done); }); }); - describe("FederationServer.resolve", function () { - it("succeeds for a valid account ID", function (done) { + describe('FederationServer.resolve', function () { + it('succeeds for a valid account ID', function (done) { StellarSdk.FederationServer.resolve( - "GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J", + 'GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J' ) .should.eventually.deep.equal({ - account_id: - "GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J", + account_id: 'GAFSZ3VPBC2H2DVKCEWLN3PQWZW6BVDMFROWJUDAJ3KWSOKQIJ4R5W4J' }) .notify(done); }); - it("fails for invalid account ID", function (done) { - StellarSdk.FederationServer.resolve("invalid") + it('fails for invalid account ID', function (done) { + StellarSdk.FederationServer.resolve('invalid') .should.be.rejectedWith(/Invalid Account ID/) .notify(done); }); - it("succeeds for a valid Stellar address", function (done) { + it('succeeds for a valid Stellar address', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://stellar.org/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://stellar.org/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` # The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" -`, - }), +` + }) ); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://api.stellar.org/federation?type=name&q=bob%2Astellar.org", - ), + 'https://api.stellar.org/federation?type=name&q=bob%2Astellar.org' + ) ) .returns( Promise.resolve({ data: { - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - memo_type: "id", - memo: "100", - }, - }), + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS', + memo_type: 'id', + memo: '100' + } + }) ); - StellarSdk.FederationServer.resolve("bob*stellar.org") + StellarSdk.FederationServer.resolve('bob*stellar.org') .should.eventually.deep.equal({ - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - memo_type: "id", - memo: "100", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS', + memo_type: 'id', + memo: '100' }) .notify(done); }); - it("fails for invalid Stellar address", function (done) { - StellarSdk.FederationServer.resolve("bob*stellar.org*test") + it('fails for invalid Stellar address', function (done) { + StellarSdk.FederationServer.resolve('bob*stellar.org*test') .should.be.rejectedWith(/Invalid Stellar address/) .notify(done); }); - it("fails when memo is not string", function (done) { + it('fails when memo is not string', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://acme.com:1337/federation?type=name&q=bob%2Astellar.org", - ), + 'https://acme.com:1337/federation?type=name&q=bob%2Astellar.org' + ) ) .returns( Promise.resolve({ data: { - stellar_address: "bob*stellar.org", + stellar_address: 'bob*stellar.org', account_id: - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", - memo_type: "id", - memo: 100, - }, - }), + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS', + memo_type: 'id', + memo: 100 + } + }) ); this.server - .resolveAddress("bob*stellar.org") + .resolveAddress('bob*stellar.org') .should.be.rejectedWith(/memo value should be of type string/) .notify(done); }); - it("fails when response exceeds the limit", function (done) { + it('fails when response exceeds the limit', function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } var response = Array(StellarSdk.FEDERATION_RESPONSE_MAX_SIZE + 10).join( - "a", + 'a' ); let tempServer = http .createServer((req, res) => { - res.setHeader("Content-Type", "application/json; charset=UTF-8"); + res.setHeader('Content-Type', 'application/json; charset=UTF-8'); res.end(response); }) .listen(4444, () => { new StellarSdk.FederationServer( - "http://localhost:4444/federation", - "stellar.org", - { allowHttp: true }, + 'http://localhost:4444/federation', + 'stellar.org', + { allowHttp: true } ) - .resolveAddress("bob*stellar.org") + .resolveAddress('bob*stellar.org') .should.be.rejectedWith( - /federation response exceeds allowed size of [0-9]+/, + /federation response exceeds allowed size of [0-9]+/ ) .notify(done) .then(() => tempServer.close()); @@ -346,7 +345,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" }); }); - describe("FederationServer times out when response lags and timeout set", function () { + describe('FederationServer times out when response lags and timeout set', function () { afterEach(function () { StellarSdk.Config.setDefault(); }); @@ -356,15 +355,15 @@ FEDERATION_SERVER="https://api.stellar.org/federation" for (let i = 0; i < 2; i++) { if (i === 0) { StellarSdk.Config.setTimeout(1000); - message = "with global config set"; + message = 'with global config set'; } else { opts = { allowHttp: true, timeout: 1000 }; - message = "with instance opts set"; + message = 'with instance opts set'; } it(`resolveAddress times out ${message}`, function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } @@ -374,11 +373,11 @@ FEDERATION_SERVER="https://api.stellar.org/federation" }) .listen(4444, () => { new StellarSdk.FederationServer( - "http://localhost:4444/federation", - "stellar.org", - opts, + 'http://localhost:4444/federation', + 'stellar.org', + opts ) - .resolveAddress("bob*stellar.org") + .resolveAddress('bob*stellar.org') .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) .then(() => tempServer.close()); @@ -387,7 +386,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" it(`resolveAccountId times out ${message}`, function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } let tempServer = http @@ -396,12 +395,12 @@ FEDERATION_SERVER="https://api.stellar.org/federation" }) .listen(4444, () => { new StellarSdk.FederationServer( - "http://localhost:4444/federation", - "stellar.org", - opts, + 'http://localhost:4444/federation', + 'stellar.org', + opts ) .resolveAccountId( - "GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS", + 'GB5XVAABEQMY63WTHDQ5RXADGYF345VWMNPTN2GFUDZT57D57ZQTJ7PS' ) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) @@ -411,7 +410,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" it(`resolveTransactionId times out ${message}`, function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } let tempServer = http @@ -420,12 +419,12 @@ FEDERATION_SERVER="https://api.stellar.org/federation" }) .listen(4444, () => { new StellarSdk.FederationServer( - "http://localhost:4444/federation", - "stellar.org", - opts, + 'http://localhost:4444/federation', + 'stellar.org', + opts ) .resolveTransactionId( - "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", + '3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889' ) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) @@ -435,7 +434,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" it(`createForDomain times out ${message}`, function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } let tempServer = http @@ -443,7 +442,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" setTimeout(() => {}, 10000); }) .listen(4444, () => { - StellarSdk.FederationServer.createForDomain("localhost:4444", opts) + StellarSdk.FederationServer.createForDomain('localhost:4444', opts) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) .then(() => tempServer.close()); @@ -452,7 +451,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" it(`resolve times out ${message}`, function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } @@ -461,7 +460,7 @@ FEDERATION_SERVER="https://api.stellar.org/federation" setTimeout(() => {}, 10000); }) .listen(4444, () => { - StellarSdk.FederationServer.resolve("bob*localhost:4444", opts) + StellarSdk.FederationServer.resolve('bob*localhost:4444', opts) .should.eventually.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) .then(() => tempServer.close()); diff --git a/test/unit/horizon/join_test.js b/test/unit/horizon/join_test.js index 6e383bcc1..d8ef6e46a 100644 --- a/test/unit/horizon/join_test.js +++ b/test/unit/horizon/join_test.js @@ -1,9 +1,7 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server - CallBuilder#join", function () { +describe('Server - CallBuilder#join', function () { beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337", + 'https://horizon-live.stellar.org:1337' ); this.axiosMock = sinon.mock(AxiosClient); }); @@ -13,151 +11,151 @@ describe("Server - CallBuilder#join", function () { this.axiosMock.restore(); }); - describe("#join", function () { + describe('#join', function () { const transaction = { - memo: "", + memo: '', _links: { self: { - href: "https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5", + href: 'https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5' }, account: { - href: "https://horizon-live.stellar.org:1337/accounts/GBIABVWR2LOKFDMAI6QA2NGT4G54O3BC577GAWDQ6QMOUP5E3ULBBGYX", + href: 'https://horizon-live.stellar.org:1337/accounts/GBIABVWR2LOKFDMAI6QA2NGT4G54O3BC577GAWDQ6QMOUP5E3ULBBGYX' }, ledger: { - href: "https://horizon-live.stellar.org:1337/ledgers/679846", + href: 'https://horizon-live.stellar.org:1337/ledgers/679846' }, operations: { - href: "https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon-live.stellar.org:1337/transactions?order=asc\u0026cursor=2919916336320512", + href: 'https://horizon-live.stellar.org:1337/transactions?order=asc\u0026cursor=2919916336320512' }, succeeds: { - href: "https://horizon-live.stellar.org:1337/transactions?order=desc\u0026cursor=2919916336320512", - }, + href: 'https://horizon-live.stellar.org:1337/transactions?order=desc\u0026cursor=2919916336320512' + } }, - id: "de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5", - paging_token: "2919916336320512", + id: 'de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5', + paging_token: '2919916336320512', successful: true, - hash: "de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5", + hash: 'de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5', ledger: 679846, - created_at: "2019-09-12T14:24:35Z", + created_at: '2019-09-12T14:24:35Z', source_account: - "GBIABVWR2LOKFDMAI6QA2NGT4G54O3BC577GAWDQ6QMOUP5E3ULBBGYX", - source_account_sequence: "2954696981479425", + 'GBIABVWR2LOKFDMAI6QA2NGT4G54O3BC577GAWDQ6QMOUP5E3ULBBGYX', + source_account_sequence: '2954696981479425', fee_charged: 3600, max_fee: 3600, operation_count: 6, envelope_xdr: - "AAAAAFAA1tHS3KKNgEegDTTT4bv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lraePffIIDL7TiJN1gMrdZxiBTrsAJvpRqoJtmjEjL8AQ==", - ], + '5QcaEgzj+krAtiH0+iRho6gjxWIUMkTfVo28FqoBqlraePffIIDL7TiJN1gMrdZxiBTrsAJvpRqoJtmjEjL8AQ==' + ] }; const operationsResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/operations?cursor=\u0026join=transactions\u0026limit=10\u0026order=asc", + href: 'https://horizon-live.stellar.org:1337/operations?cursor=\u0026join=transactions\u0026limit=10\u0026order=asc' }, next: { - href: "https://horizon-live.stellar.org:1337/operations?cursor=2919916336320518\u0026join=transactions\u0026limit=10\u0026order=asc", + href: 'https://horizon-live.stellar.org:1337/operations?cursor=2919916336320518\u0026join=transactions\u0026limit=10\u0026order=asc' }, prev: { - href: "https://horizon-live.stellar.org:1337/operations?cursor=2919916336320518\u0026join=transactions\u0026limit=1\u0026order=asc", - }, + href: 'https://horizon-live.stellar.org:1337/operations?cursor=2919916336320518\u0026join=transactions\u0026limit=1\u0026order=asc' + } }, _embedded: { records: [ { _links: { self: { - href: "https://horizon-live.stellar.org:1337/operations/2919916336320518", + href: 'https://horizon-live.stellar.org:1337/operations/2919916336320518' }, transaction: { - href: "https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5", + href: 'https://horizon-live.stellar.org:1337/transactions/de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5' }, effects: { - href: "https://horizon-live.stellar.org:1337/operations/2919916336320518/effects", + href: 'https://horizon-live.stellar.org:1337/operations/2919916336320518/effects' }, succeeds: { - href: "https://horizon-live.stellar.org:1337/effects?order=desc\u0026cursor=2919916336320518", + href: 'https://horizon-live.stellar.org:1337/effects?order=desc\u0026cursor=2919916336320518' }, precedes: { - href: "https://horizon-live.stellar.org:1337/effects?order=asc\u0026cursor=2919916336320518", - }, + href: 'https://horizon-live.stellar.org:1337/effects?order=asc\u0026cursor=2919916336320518' + } }, - id: "2919916336320518", - paging_token: "2919916336320518", + id: '2919916336320518', + paging_token: '2919916336320518', transaction_successful: true, source_account: - "GD7PZVW3WXKEWT4XQPV57K3DARCAQ5XZE5ZWFSDTGHBMQ4U7ZWYWZLPC", - type: "path_payment", + 'GD7PZVW3WXKEWT4XQPV57K3DARCAQ5XZE5ZWFSDTGHBMQ4U7ZWYWZLPC', + type: 'path_payment', type_i: 2, - created_at: "2019-09-12T14:24:35Z", + created_at: '2019-09-12T14:24:35Z', transaction_hash: - "de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5", + 'de8ca055af7972f817e9d3f7c7a0b480de82593bc378f0e48f83b8e31985e4e5', transaction, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD", - from: "GD7PZVW3WXKEWT4XQPV57K3DARCAQ5XZE5ZWFSDTGHBMQ4U7ZWYWZLPC", - to: "GCC3LGXHBZ6NSJOJCETNRRYTNDQJGCRC3P7YC2ZQ2ER3YWVJJQ2YDUL7", - amount: "10000.0000000", + 'GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD', + from: 'GD7PZVW3WXKEWT4XQPV57K3DARCAQ5XZE5ZWFSDTGHBMQ4U7ZWYWZLPC', + to: 'GCC3LGXHBZ6NSJOJCETNRRYTNDQJGCRC3P7YC2ZQ2ER3YWVJJQ2YDUL7', + amount: '10000.0000000', path: [ { - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD", + 'GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD' }, { - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD", - }, + 'GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD' + } ], - source_amount: "10000.0000000", - source_max: "10000.0000000", - source_asset_type: "credit_alphanum4", - source_asset_code: "USD", + source_amount: '10000.0000000', + source_max: '10000.0000000', + source_asset_type: 'credit_alphanum4', + source_asset_code: 'USD', source_asset_issuer: - "GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD", - }, - ], - }, + 'GBXGR3C3VKWAJCWLF7LX5TLS4KWQKPKJ4KUOJ6T6NEBROA62TTUUM6GD' + } + ] + } }; - it("loads resources in join and avoids extra call to server", function (done) { + it('loads resources in join and avoids extra call to server', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/operations?join=transactions", - ), + 'https://horizon-live.stellar.org:1337/operations?join=transactions' + ) ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() - .join("transactions") + .join('transactions') .call() .then((response) => { const record = response.records[0]; - expect(record.transaction).to.be.a("function"); + expect(record.transaction).to.be.a('function'); record.transaction().then((transaction) => { expect(transaction).to.deep.equal(transaction); diff --git a/test/unit/horizon/liquidity_pool_endpoints_test.js b/test/unit/horizon/liquidity_pool_endpoints_test.js index c7ab0d1af..a8dbc281c 100644 --- a/test/unit/horizon/liquidity_pool_endpoints_test.js +++ b/test/unit/horizon/liquidity_pool_endpoints_test.js @@ -3,10 +3,10 @@ function copyJson(js) { return JSON.parse(JSON.stringify(js)); } -const BASE_URL = "https://horizon-live.stellar.org:1337"; -const LP_URL = BASE_URL + "/liquidity_pools"; +const BASE_URL = 'https://horizon-live.stellar.org:1337'; +const LP_URL = BASE_URL + '/liquidity_pools'; -describe("/liquidity_pools tests", function () { +describe('/liquidity_pools tests', function () { beforeEach(function () { this.server = new StellarSdk.Server(BASE_URL); this.axiosMock = sinon.mock(AxiosClient); @@ -18,66 +18,66 @@ describe("/liquidity_pools tests", function () { this.axiosMock.restore(); }); - it("can create a LiquidityPoolCallBuilder", function () { + it('can create a LiquidityPoolCallBuilder', function () { expect(this.server.liquidityPools()).not.to.be.undefined; }); const rootResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=desc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=desc' + } }, _embedded: { records: [ { - id: "1", - paging_token: "113725249324879873", + id: '1', + paging_token: '113725249324879873', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - }, - ], + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' + } + ] }, { - id: "2", - paging_token: "113725249324879874", + id: '2', + paging_token: '113725249324879874', fee_bp: 30, - type: "constant_product", - total_trustlines: "200", - total_shares: "3500", + type: 'constant_product', + total_trustlines: '200', + total_shares: '3500', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "1200.0000000", + amount: '1200.0000000', asset: - "USDC:GC5W3BH2MQRQK2H4A6LP3SXDSAAY2W2W64OWKKVNQIAOVWSAHFDEUSDC", - }, - ], - }, - ], - }, + 'USDC:GC5W3BH2MQRQK2H4A6LP3SXDSAAY2W2W64OWKKVNQIAOVWSAHFDEUSDC' + } + ] + } + ] + } }; let emptyResponse = copyJson(rootResponse); @@ -87,17 +87,17 @@ describe("/liquidity_pools tests", function () { phpResponse._embedded.records.pop(); // last elem doesn't have PHP asset const EURT = new StellarSdk.Asset( - "EURT", - "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT', + 'GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' ); const PHP = new StellarSdk.Asset( - "PHP", - "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'PHP', + 'GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' ); - it("returns the right root response", function (done) { + it('returns the right root response', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(LP_URL)) .returns(Promise.resolve({ data: rootResponse })); @@ -111,39 +111,39 @@ describe("/liquidity_pools tests", function () { .catch(done); }); - describe("filters", function () { + describe('filters', function () { const testCases = [ { assets: [StellarSdk.Asset.native()], - response: emptyResponse, + response: emptyResponse }, { assets: [EURT], - response: rootResponse, + response: rootResponse }, { assets: [PHP], - response: phpResponse, + response: phpResponse }, { assets: [EURT, PHP], - response: phpResponse, - }, + response: phpResponse + } ]; testCases.forEach((testCase) => { const queryStr = testCase.assets .map((asset) => asset.toString()) - .join(","); + .join(','); const description = testCase.assets .map((asset) => asset.getCode()) - .join(" + "); + .join(' + '); - it("filters by asset(s) " + description, function (done) { + it('filters by asset(s) ' + description, function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match(`${LP_URL}?reserves=${encodeURIComponent(queryStr)}`), + sinon.match(`${LP_URL}?reserves=${encodeURIComponent(queryStr)}`) ) .returns(Promise.resolve({ data: testCase.response })); @@ -153,7 +153,7 @@ describe("/liquidity_pools tests", function () { .call() .then((pools) => { expect(pools.records).to.deep.equal( - testCase.response._embedded.records, + testCase.response._embedded.records ); done(); }) @@ -161,11 +161,11 @@ describe("/liquidity_pools tests", function () { }); }); - it("filters by account", function (done) { + it('filters by account', function (done) { const accountId = - "GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S"; + 'GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S'; this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}?account=${accountId}`)) .returns(Promise.resolve({ data: rootResponse })); @@ -181,43 +181,43 @@ describe("/liquidity_pools tests", function () { }); }); - describe("querying a specific pool", function () { + describe('querying a specific pool', function () { const lpId = - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a"; + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a'; - it("checks for valid IDs", function () { + it('checks for valid IDs', function () { expect(() => - this.server.liquidityPools().liquidityPoolId("nonsense"), + this.server.liquidityPools().liquidityPoolId('nonsense') ).to.throw(); expect(() => - this.server.liquidityPools().liquidityPoolId(lpId), + this.server.liquidityPools().liquidityPoolId(lpId) ).not.to.throw(); }); - it("filters by specific ID", function (done) { + it('filters by specific ID', function (done) { const poolResponse = { id: lpId, - paging_token: "113725249324879873", + paging_token: '113725249324879873', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - }, - ], + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' + } + ] }; this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}`)) .returns(Promise.resolve({ data: poolResponse })); @@ -235,151 +235,151 @@ describe("/liquidity_pools tests", function () { const poolOpsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=desc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/operations?cursor=113725249324879873&limit=10&order=desc' + } }, _embedded: { records: [ { - id: "3697472920621057", - paging_token: "3697472920621057", + id: '3697472920621057', + paging_token: '3697472920621057', transaction_successful: true, source_account: - "GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L", - type: "liquidity_pool_deposit", + 'GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L', + type: 'liquidity_pool_deposit', type_i: 22, - created_at: "2021-11-18T03:47:47Z", + created_at: '2021-11-18T03:47:47Z', transaction_hash: - "43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378", + '43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378', liquidity_pool_id: - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a", + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a', reserves_max: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "1000.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '1000.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "3000.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '3000.0000005' + } ], - min_price: "0.2680000", + min_price: '0.2680000', min_price_r: { n: 67, - d: 250, + d: 250 }, - max_price: "0.3680000", + max_price: '0.3680000', max_price_r: { n: 73, - d: 250, + d: 250 }, reserves_deposited: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } ], - shares_received: "1000", + shares_received: '1000' }, { - id: "3697472920621057", - paging_token: "3697472920621057", + id: '3697472920621057', + paging_token: '3697472920621057', transaction_successful: true, source_account: - "GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L", - type: "liquidity_pool_withdraw", + 'GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L', + type: 'liquidity_pool_withdraw', type_i: 23, - created_at: "2021-11-18T03:47:47Z", + created_at: '2021-11-18T03:47:47Z', transaction_hash: - "43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378", + '43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378', liquidity_pool_id: - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a", + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a', reserves_min: [ { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - min: "1000.0000005", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + min: '1000.0000005' }, { asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - min: "3000.0000005", - }, + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + min: '3000.0000005' + } ], - shares: "200", + shares: '200', reserves_received: [ { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "993.0000005", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '993.0000005' }, { asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - }, - ], + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005' + } + ] }, { - id: "157639717969326081", - paging_token: "157639717969326081", + id: '157639717969326081', + paging_token: '157639717969326081', transaction_successful: true, source_account: - "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "change_trust", + 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'change_trust', type_i: 6, - created_at: "2021-08-04T20:01:24Z", + created_at: '2021-08-04T20:01:24Z', transaction_hash: - "941f2fa2101d1265696a3c7d35e7688cd210324114e96b64a386ab55f65e488f", - asset_type: "liquidity_pool_shares", + '941f2fa2101d1265696a3c7d35e7688cd210324114e96b64a386ab55f65e488f', + asset_type: 'liquidity_pool_shares', liquidity_pool_id: - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a", - limit: "1000", - trustor: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a', + limit: '1000', + trustor: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG' }, { - id: "157235845014249474-0", - paging_token: "157235845014249474-0", - ledger_close_time: "2021-07-29T21:10:53Z", - trade_type: "liquidity_pool", - base_liquidity_pool_id: "abcdef", + id: '157235845014249474-0', + paging_token: '157235845014249474-0', + ledger_close_time: '2021-07-29T21:10:53Z', + trade_type: 'liquidity_pool', + base_liquidity_pool_id: 'abcdef', liquidity_pool_fee_bp: 30, - base_amount: "0.0002007", - base_asset_type: "native", + base_amount: '0.0002007', + base_asset_type: 'native', counter_account: - "GDW634JZX3VMEF2RZTCJTT34RITIMNX46QOGTYHCJEJL3MM7BLOQ6HOW", - counter_amount: "0.0022300", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "VZT", + 'GDW634JZX3VMEF2RZTCJTT34RITIMNX46QOGTYHCJEJL3MM7BLOQ6HOW', + counter_amount: '0.0022300', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'VZT', counter_asset_issuer: - "GBENYXZDFFR2J4F4DB3YPBBAM244TXYOTIOOUQI5DBT3OKUU4ZJ2M7NO", + 'GBENYXZDFFR2J4F4DB3YPBBAM244TXYOTIOOUQI5DBT3OKUU4ZJ2M7NO', base_is_seller: false, price: { - n: "10000000", - d: "899997", - }, - }, - ], - }, + n: '10000000', + d: '899997' + } + } + ] + } }; - it("retrieves its operations", function (done) { + it('retrieves its operations', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/operations`)) .returns(Promise.resolve({ data: poolOpsResponse })); @@ -389,7 +389,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolOps) => { expect(poolOps.records).to.deep.equal( - poolOpsResponse._embedded.records, + poolOpsResponse._embedded.records ); done(); }) @@ -399,79 +399,79 @@ describe("/liquidity_pools tests", function () { const poolTxsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=desc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/transactions?cursor=113725249324879873&limit=10&order=desc' + } }, _embedded: { records: [ { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908' }, account: { - href: "https://private-33c60-amm3.apiary-mock.com/accounts/GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", + href: 'https://private-33c60-amm3.apiary-mock.com/accounts/GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7' }, ledger: { - href: "https://private-33c60-amm3.apiary-mock.com/ledgers/895788", + href: 'https://private-33c60-amm3.apiary-mock.com/ledgers/895788' }, operations: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/operations", - templated: true, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/operations', + templated: true }, effects: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/effects", - templated: true, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/effects', + templated: true }, precedes: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions?order=asc&cursor=3847380164161536", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions?order=asc&cursor=3847380164161536' }, succeeds: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions?order=desc&cursor=3847380164161536", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions?order=desc&cursor=3847380164161536' }, transaction: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908' + } }, - id: "2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", - paging_token: "3847380164161536", + id: '2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908', + paging_token: '3847380164161536', successful: true, - hash: "2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", + hash: '2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908', ledger: 895788, - created_at: "2021-08-09T20:53:11Z", + created_at: '2021-08-09T20:53:11Z', source_account: - "GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", - source_account_sequence: "3847371574214658", + 'GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7', + source_account_sequence: '3847371574214658', fee_account: - "GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", - fee_charged: "10000", - max_fee: "10001", + 'GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7', + fee_charged: '10000', + max_fee: '10001', operation_count: 1, envelope_xdr: - "AAAAAgAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAJxEADasqAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAADwb7DcD9mf5rBUnI78yWbQTnWrh3YfIrkekWXPblTpQAAAAGAAAAAVNFQwAAAAAAm6XFaVsf8OSuS9C9gMplyTjagE9jAnnqwxSDJ6fin6IAsaK8LsUAAAAAAAAAAAAB9uVOlAAAAECXmRsoXmRiJjUrtbkDZYRnzac5s1CVV4g2RlIgBIuQty21npz3A1VhUcSmAx+GmsyGxVFvIrcdstTawJlmy9kF", - result_xdr: "AAAAAAAAJxAAAAAAAAAAAQAAAAAAAAAGAAAAAAAAAAA=", + 'AAAAAgAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAJxEADasqAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAADwb7DcD9mf5rBUnI78yWbQTnWrh3YfIrkekWXPblTpQAAAAGAAAAAVNFQwAAAAAAm6XFaVsf8OSuS9C9gMplyTjagE9jAnnqwxSDJ6fin6IAsaK8LsUAAAAAAAAAAAAB9uVOlAAAAECXmRsoXmRiJjUrtbkDZYRnzac5s1CVV4g2RlIgBIuQty21npz3A1VhUcSmAx+GmsyGxVFvIrcdstTawJlmy9kF', + result_xdr: 'AAAAAAAAJxAAAAAAAAAAAQAAAAAAAAAGAAAAAAAAAAA=', result_meta_xdr: - "AAAAAgAAAAIAAAADAA2rLAAAAAAAAAAADwb7DcD9mf5rBUnI78yWbQTnWrh3YfIrkekWXPblTpQAAAAAGtJNDAANqy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9uVOlAAAAAAa0k0MAA2rKgAAAAIAAAABAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAADassAAAAAQAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAFTRUMAAAAAAJulxWlbH/DkrkvQvYDKZck42oBPYwJ56sMUgyen4p+iAAAAAAAAAAAAsaK8LsUAAAAAAAEAAAAAAAAAAAAAAAA=', fee_meta_xdr: - "AAAAAgAAAAMADasrAAAAAAAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAAa0nQcAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEADassAAAAAAAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAAa0k0MAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", - memo_type: "none", + 'AAAAAgAAAAMADasrAAAAAAAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAAa0nQcAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEADassAAAAAAAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAAa0k0MAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'none', signatures: [ - "l5kbKF5kYiY1K7W5A2WEZ82nObNQlVeINkZSIASLkLcttZ6c9wNVYVHEpgMfhprMhsVRbyK3HbLU2sCZZsvZBQ==", - ], - }, - ], - }, + 'l5kbKF5kYiY1K7W5A2WEZ82nObNQlVeINkZSIASLkLcttZ6c9wNVYVHEpgMfhprMhsVRbyK3HbLU2sCZZsvZBQ==' + ] + } + ] + } }; - it("retrieves its transactions", function (done) { + it('retrieves its transactions', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/transactions`)) .returns(Promise.resolve({ data: poolTxsResponse })); @@ -481,7 +481,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTxs) => { expect(poolTxs.records).to.deep.equal( - poolTxsResponse._embedded.records, + poolTxsResponse._embedded.records ); done(); }) @@ -491,263 +491,263 @@ describe("/liquidity_pools tests", function () { const poolEffectsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a/effects?cursor=113725249324879873&limit=10&order=asc' + } }, _embedded: { records: [ { _links: { operation: { - href: "https://private-33c60-amm3.apiary-mock.com/operations/3849085266190337", + href: 'https://private-33c60-amm3.apiary-mock.com/operations/3849085266190337' }, succeeds: { - href: "https://private-33c60-amm3.apiary-mock.com/effects?order=desc&cursor=3849085266190337-1", + href: 'https://private-33c60-amm3.apiary-mock.com/effects?order=desc&cursor=3849085266190337-1' }, precedes: { - href: "https://private-33c60-amm3.apiary-mock.com/effects?order=asc&cursor=3849085266190337-1", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/effects?order=asc&cursor=3849085266190337-1' + } }, - id: "0000000012884905986-0000000001", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_deposited", + id: '0000000012884905986-0000000001', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_deposited', type_i: 81, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_deposited: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } ], - shares_received: "1000", + shares_received: '1000' }, { - id: "0000000012884905986-0000000002", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_withdrew", + id: '0000000012884905986-0000000002', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_withdrew', type_i: 82, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "299", - total_shares: "4000", + type: 'constant_product', + total_trustlines: '299', + total_shares: '4000', reserves: [ { - amount: "7.0000005", + amount: '7.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "1.0000000", + amount: '1.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_received: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "993.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '993.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005' + } ], - shares_redeemed: "1000", + shares_redeemed: '1000' }, { - id: "0000000012884905986-0000000003", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_trade", + id: '0000000012884905986-0000000003', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_trade', type_i: 83, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, sold: { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, bought: { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } }, { - id: "0000000012884905986-0000000004", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_created", + id: '0000000012884905986-0000000004', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_created', type_i: 84, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "1", - total_shares: "0", + type: 'constant_product', + total_trustlines: '1', + total_shares: '0', reserves: [ { - amount: "0", + amount: '0', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "0", + amount: '0', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], - }, + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] + } }, { - id: "0000000012884905986-0000000005", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_removed", + id: '0000000012884905986-0000000005', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_removed', type_i: 85, - created_at: "2021-11-18T03:15:54Z", - liquidity_pool_id: "abcdef", + created_at: '2021-11-18T03:15:54Z', + liquidity_pool_id: 'abcdef' }, { - id: "0000000012884905986-0000000006", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_revoked", + id: '0000000012884905986-0000000006', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_revoked', type_i: 86, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "299", - total_shares: "4000", + type: 'constant_product', + total_trustlines: '299', + total_shares: '4000', reserves: [ { - amount: "7.0000005", + amount: '7.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "1.0000000", + amount: '1.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_revoked: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "993.0000005", - claimable_balance_id: "cbid1235", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '993.0000005', + claimable_balance_id: 'cbid1235' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - claimable_balance_id: "idcbd1234", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005', + claimable_balance_id: 'idcbd1234' + } ], - shares_revoked: "1000", + shares_revoked: '1000' }, { - id: "0000000012884905986-0000000007", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_created", + id: '0000000012884905986-0000000007', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_created', type_i: 20, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "1000", + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '1000' }, { - id: "0000000012884905986-0000000008", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_updated", + id: '0000000012884905986-0000000008', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_updated', type_i: 22, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "2000", + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '2000' }, { - id: "0000000012884905986-0000000009", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_removed", + id: '0000000012884905986-0000000009', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_removed', type_i: 21, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "0.0000000", - }, - ], - }, + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '0.0000000' + } + ] + } }; - it("retrieves its effects", function (done) { + it('retrieves its effects', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/effects`)) .returns(Promise.resolve({ data: poolEffectsResponse })); @@ -757,7 +757,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolEffects) => { expect(poolEffects.records).to.deep.equal( - poolEffectsResponse._embedded.records, + poolEffectsResponse._embedded.records ); done(); }) @@ -767,63 +767,63 @@ describe("/liquidity_pools tests", function () { const poolTradesResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4/trades?cursor=113725249324879873&limit=10&order=asc' + } }, _embedded: { records: [ { _links: { self: { - href: "", + href: '' }, base: { - href: "https://private-33c60-amm3.apiary-mock.com/accounts/GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G", + href: 'https://private-33c60-amm3.apiary-mock.com/accounts/GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G' }, counter: { - href: "https://private-33c60-amm3.apiary-mock.com/accounts/GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L", + href: 'https://private-33c60-amm3.apiary-mock.com/accounts/GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L' }, operation: { - href: "https://private-33c60-amm3.apiary-mock.com/operations/3697472920621057", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/operations/3697472920621057' + } }, - id: "3697472920621057-0", - paging_token: "3697472920621057-0", - ledger_close_time: "2015-11-18T03:47:47Z", - offer_id: "9", - base_offer_id: "9", + id: '3697472920621057-0', + paging_token: '3697472920621057-0', + ledger_close_time: '2015-11-18T03:47:47Z', + offer_id: '9', + base_offer_id: '9', base_account: - "GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G", - base_amount: "10.0000000", - base_asset_type: "native", + 'GAVH5JM5OKXGMQDS7YPRJ4MQCPXJUGH26LYQPQJ4SOMOJ4SXY472ZM7G', + base_amount: '10.0000000', + base_asset_type: 'native', counter_liquidity_pool: - "3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4", - liquidity_pool_fee_bp: "30", - counter_amount: "2.6700000", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + '3b476aff8a406a6ec3b61d5c038009cef85f2ddfaf616822dc4fec92845149b4', + liquidity_pool_fee_bp: '30', + counter_amount: '2.6700000', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "267", - d: "1000", + n: '267', + d: '1000' }, - trade_type: "liquidity_pool", - }, - ], - }, + trade_type: 'liquidity_pool' + } + ] + } }; - it("retrieves its trades", function (done) { + it('retrieves its trades', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/trades`)) .returns(Promise.resolve({ data: poolTradesResponse })); @@ -833,7 +833,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTrades) => { expect(poolTrades.records).to.deep.equal( - poolTradesResponse._embedded.records, + poolTradesResponse._embedded.records ); done(); }) @@ -841,156 +841,156 @@ describe("/liquidity_pools tests", function () { }); }); - describe("querying a specific pool", function () { + describe('querying a specific pool', function () { const lpId = - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a"; + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a'; const poolOpsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=desc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/operations?cursor=113725249324879873&limit=10&order=desc' + } }, _embedded: { records: [ { - id: "3697472920621057", - paging_token: "3697472920621057", + id: '3697472920621057', + paging_token: '3697472920621057', transaction_successful: true, source_account: - "GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L", - type: "liquidity_pool_deposit", + 'GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L', + type: 'liquidity_pool_deposit', type_i: 22, - created_at: "2021-11-18T03:47:47Z", + created_at: '2021-11-18T03:47:47Z', transaction_hash: - "43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378", + '43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378', liquidity_pool_id: - "ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a", + 'ae44a51f6191ce24414fbd1326e93ccb0ae656f07fc1e37602b11d0802f74b9a', reserves_max: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "1000.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '1000.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "3000.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '3000.0000005' + } ], - min_price: "0.2680000", + min_price: '0.2680000', min_price_r: { n: 67, - d: 250, + d: 250 }, - max_price: "0.3680000", + max_price: '0.3680000', max_price_r: { n: 73, - d: 250, + d: 250 }, reserves_deposited: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } ], - shares_received: "1000", + shares_received: '1000' }, { - id: "3697472920621057", - paging_token: "3697472920621057", + id: '3697472920621057', + paging_token: '3697472920621057', transaction_successful: true, source_account: - "GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L", - type: "liquidity_pool_withdraw", + 'GBB4JST32UWKOLGYYSCEYBHBCOFL2TGBHDVOMZP462ET4ZRD4ULA7S2L', + type: 'liquidity_pool_withdraw', type_i: 23, - created_at: "2021-11-18T03:47:47Z", + created_at: '2021-11-18T03:47:47Z', transaction_hash: - "43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378", - liquidity_pool_id: "1", + '43ed5ce19190822ec080b67c3ccbab36a56bc34102b1a21d3ee690ed3bc23378', + liquidity_pool_id: '1', reserves_min: [ { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - min: "1000.0000005", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + min: '1000.0000005' }, { asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - min: "3000.0000005", - }, + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + min: '3000.0000005' + } ], - shares: "200", + shares: '200', reserves_received: [ { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "993.0000005", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '993.0000005' }, { asset: - "PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - }, - ], + 'PHP:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005' + } + ] }, { - id: "157639717969326081", - paging_token: "157639717969326081", + id: '157639717969326081', + paging_token: '157639717969326081', transaction_successful: true, source_account: - "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "change_trust", + 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'change_trust', type_i: 6, - created_at: "2021-08-04T20:01:24Z", + created_at: '2021-08-04T20:01:24Z', transaction_hash: - "941f2fa2101d1265696a3c7d35e7688cd210324114e96b64a386ab55f65e488f", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "1", - limit: "1000", - trustor: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", + '941f2fa2101d1265696a3c7d35e7688cd210324114e96b64a386ab55f65e488f', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: '1', + limit: '1000', + trustor: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG' }, { - id: "157235845014249474-0", - paging_token: "157235845014249474-0", - ledger_close_time: "2021-07-29T21:10:53Z", - trade_type: "liquidity_pool", - base_liquidity_pool_id: "abcdef", + id: '157235845014249474-0', + paging_token: '157235845014249474-0', + ledger_close_time: '2021-07-29T21:10:53Z', + trade_type: 'liquidity_pool', + base_liquidity_pool_id: 'abcdef', liquidity_pool_fee_bp: 30, - base_amount: "0.0002007", - base_asset_type: "native", + base_amount: '0.0002007', + base_asset_type: 'native', counter_account: - "GDW634JZX3VMEF2RZTCJTT34RITIMNX46QOGTYHCJEJL3MM7BLOQ6HOW", - counter_amount: "0.0022300", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "VZT", + 'GDW634JZX3VMEF2RZTCJTT34RITIMNX46QOGTYHCJEJL3MM7BLOQ6HOW', + counter_amount: '0.0022300', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'VZT', counter_asset_issuer: - "GBENYXZDFFR2J4F4DB3YPBBAM244TXYOTIOOUQI5DBT3OKUU4ZJ2M7NO", + 'GBENYXZDFFR2J4F4DB3YPBBAM244TXYOTIOOUQI5DBT3OKUU4ZJ2M7NO', base_is_seller: false, price: { - n: "10000000", - d: "899997", - }, - }, - ], - }, + n: '10000000', + d: '899997' + } + } + ] + } }; - it("retrieves its operations", function (done) { + it('retrieves its operations', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/operations`)) .returns(Promise.resolve({ data: poolOpsResponse })); @@ -1000,7 +1000,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolOps) => { expect(poolOps.records).to.deep.equal( - poolOpsResponse._embedded.records, + poolOpsResponse._embedded.records ); done(); }) @@ -1010,79 +1010,79 @@ describe("/liquidity_pools tests", function () { const poolTxsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=desc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools/1/transactions?cursor=113725249324879873&limit=10&order=desc' + } }, _embedded: { records: [ { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908' }, account: { - href: "https://private-33c60-amm3.apiary-mock.com/accounts/GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", + href: 'https://private-33c60-amm3.apiary-mock.com/accounts/GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7' }, ledger: { - href: "https://private-33c60-amm3.apiary-mock.com/ledgers/895788", + href: 'https://private-33c60-amm3.apiary-mock.com/ledgers/895788' }, operations: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/operations", - templated: true, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/operations', + templated: true }, effects: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/effects", - templated: true, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908/effects', + templated: true }, precedes: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions?order=asc&cursor=3847380164161536", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions?order=asc&cursor=3847380164161536' }, succeeds: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions?order=desc&cursor=3847380164161536", + href: 'https://private-33c60-amm3.apiary-mock.com/transactions?order=desc&cursor=3847380164161536' }, transaction: { - href: "https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/transactions/2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908' + } }, - id: "2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", - paging_token: "3847380164161536", + id: '2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908', + paging_token: '3847380164161536', successful: true, - hash: "2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908", + hash: '2ff47e1bafe68639276b2a8df0a73597ee0c062fbcc72d121af314fe7851c908', ledger: 895788, - created_at: "2021-08-09T20:53:11Z", + created_at: '2021-08-09T20:53:11Z', source_account: - "GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", - source_account_sequence: "3847371574214658", + 'GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7', + source_account_sequence: '3847371574214658', fee_account: - "GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7", - fee_charged: "10000", - max_fee: "10001", + 'GAHQN6YNYD6ZT7TLAVE4R36MSZWQJZ22XB3WD4RLSHURMXHW4VHJIDF7', + fee_charged: '10000', + max_fee: '10001', operation_count: 1, envelope_xdr: - "AAAAAgAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAJxEADasqAAAAAgAAAAAAAAAAAAAAAQAAAAEAAAAADwb7DcD9mf5rBUnI78yWbQTnWrh3YfIrkekWXPblTpQAAAAGAAAAAVNFQwAAAAAAm6XFaVsf8OSuS9C9gMplyTjagE9jAnnqwxSDJ6fin6IAsaK8LsUAAAAAAAAAAAAB9uVOlAAAAECXmRsoXmRiJjUrtbkDZYRnzac5s1CVV4g2RlIgBIuQty21npz3A1VhUcSmAx+GmsyGxVFvIrcdstTawJlmy9kF", - result_xdr: "AAAAAAAAJxAAAAAAAAAAAQAAAAAAAAAGAAAAAAAAAAA=", + 'AAAAAg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a0nQcAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEADassAAAAAAAAAAAPBvsNwP2Z/msFScjvzJZtBOdauHdh8iuR6RZc9uVOlAAAAAAa0k0MAA2rKgAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'none', signatures: [ - "l5kbKF5kYiY1K7W5A2WEZ82nObNQlVeINkZSIASLkLcttZ6c9wNVYVHEpgMfhprMhsVRbyK3HbLU2sCZZsvZBQ==", - ], - }, - ], - }, + 'l5kbKF5kYiY1K7W5A2WEZ82nObNQlVeINkZSIASLkLcttZ6c9wNVYVHEpgMfhprMhsVRbyK3HbLU2sCZZsvZBQ==' + ] + } + ] + } }; - it("retrieves its transactions", function (done) { + it('retrieves its transactions', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/transactions`)) .returns(Promise.resolve({ data: poolTxsResponse })); @@ -1092,7 +1092,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolTxs) => { expect(poolTxs.records).to.deep.equal( - poolTxsResponse._embedded.records, + poolTxsResponse._embedded.records ); done(); }) @@ -1102,263 +1102,263 @@ describe("/liquidity_pools tests", function () { const poolFxsResponse = { _links: { self: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc' }, next: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc", + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc' }, prev: { - href: "https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/liquidity_pools?cursor=113725249324879873&limit=10&order=asc' + } }, _embedded: { records: [ { _links: { operation: { - href: "https://private-33c60-amm3.apiary-mock.com/operations/3849085266190337", + href: 'https://private-33c60-amm3.apiary-mock.com/operations/3849085266190337' }, succeeds: { - href: "https://private-33c60-amm3.apiary-mock.com/effects?order=desc&cursor=3849085266190337-1", + href: 'https://private-33c60-amm3.apiary-mock.com/effects?order=desc&cursor=3849085266190337-1' }, precedes: { - href: "https://private-33c60-amm3.apiary-mock.com/effects?order=asc&cursor=3849085266190337-1", - }, + href: 'https://private-33c60-amm3.apiary-mock.com/effects?order=asc&cursor=3849085266190337-1' + } }, - id: "0000000012884905986-0000000001", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_deposited", + id: '0000000012884905986-0000000001', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_deposited', type_i: 81, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_deposited: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } ], - shares_received: "1000", + shares_received: '1000' }, { - id: "0000000012884905986-0000000002", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_withdrew", + id: '0000000012884905986-0000000002', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_withdrew', type_i: 82, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "299", - total_shares: "4000", + type: 'constant_product', + total_trustlines: '299', + total_shares: '4000', reserves: [ { - amount: "7.0000005", + amount: '7.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "1.0000000", + amount: '1.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_received: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "993.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '993.0000005' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005' + } ], - shares_redeemed: "1000", + shares_redeemed: '1000' }, { - id: "0000000012884905986-0000000003", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_trade", + id: '0000000012884905986-0000000003', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_trade', type_i: 83, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "300", - total_shares: "5000", + type: 'constant_product', + total_trustlines: '300', + total_shares: '5000', reserves: [ { - amount: "1000.0000005", + amount: '1000.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "2000.0000000", + amount: '2000.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, sold: { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "983.0000005", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '983.0000005' }, bought: { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2378.0000005", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2378.0000005' + } }, { - id: "0000000012884905986-0000000004", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_created", + id: '0000000012884905986-0000000004', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_created', type_i: 84, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "1", - total_shares: "0", + type: 'constant_product', + total_trustlines: '1', + total_shares: '0', reserves: [ { - amount: "0", + amount: '0', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "0", + amount: '0', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], - }, + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] + } }, { - id: "0000000012884905986-0000000005", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_removed", + id: '0000000012884905986-0000000005', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_removed', type_i: 85, - created_at: "2021-11-18T03:15:54Z", - liquidity_pool_id: "abcdef", + created_at: '2021-11-18T03:15:54Z', + liquidity_pool_id: 'abcdef' }, { - id: "0000000012884905986-0000000006", - paging_token: "12884905986-2", - account: "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - type: "liquidity_pool_revoked", + id: '0000000012884905986-0000000006', + paging_token: '12884905986-2', + account: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + type: 'liquidity_pool_revoked', type_i: 86, - created_at: "2021-11-18T03:15:54Z", + created_at: '2021-11-18T03:15:54Z', liquidity_pool: { - id: "abcdef", + id: 'abcdef', fee_bp: 30, - type: "constant_product", - total_trustlines: "299", - total_shares: "4000", + type: 'constant_product', + total_trustlines: '299', + total_shares: '4000', reserves: [ { - amount: "7.0000005", + amount: '7.0000005', asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S' }, { - amount: "1.0000000", + amount: '1.0000000', asset: - "PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP", - }, - ], + 'PHP:GBUQWP3BOUZX34TOND2QV7QQ7K7VJTG6VSE7WMLBTMDJLLAW7YKGU6EP' + } + ] }, reserves_revoked: [ { asset: - "JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - amount: "993.0000005", - claimable_balance_id: "cbid1235", + 'JPY:GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', + amount: '993.0000005', + claimable_balance_id: 'cbid1235' }, { asset: - "EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S", - amount: "2478.0000005", - claimable_balance_id: "idcbd1234", - }, + 'EURT:GAP5LETOV6YIE62YAM56STDANPRDO7ZFDBGSNHJQIYGGKSMOZAHOOS2S', + amount: '2478.0000005', + claimable_balance_id: 'idcbd1234' + } ], - shares_revoked: "1000", + shares_revoked: '1000' }, { - id: "0000000012884905986-0000000007", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_created", + id: '0000000012884905986-0000000007', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_created', type_i: 20, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "1000", + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '1000' }, { - id: "0000000012884905986-0000000008", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_updated", + id: '0000000012884905986-0000000008', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_updated', type_i: 22, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "2000", + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '2000' }, { - id: "0000000012884905986-0000000009", - paging_token: "157639717969326081-1", - account: "GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG", - type: "trustline_removed", + id: '0000000012884905986-0000000009', + paging_token: '157639717969326081-1', + account: 'GBBWI7TEVQBPEUXKYNGI3GBAH7EHFEREONKK3UK56ZSLJIDIYHQJCVSG', + type: 'trustline_removed', type_i: 21, - created_at: "2021-08-04T20:01:24Z", - asset_type: "liquidity_pool_shares", - liquidity_pool_id: "abcdef", - limit: "0.0000000", - }, - ], - }, + created_at: '2021-08-04T20:01:24Z', + asset_type: 'liquidity_pool_shares', + liquidity_pool_id: 'abcdef', + limit: '0.0000000' + } + ] + } }; - it("retrieves its effects", function (done) { + it('retrieves its effects', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`${LP_URL}/${lpId}/effects`)) .returns(Promise.resolve({ data: poolFxsResponse })); @@ -1368,7 +1368,7 @@ describe("/liquidity_pools tests", function () { .call() .then((poolFxs) => { expect(poolFxs.records).to.deep.equal( - poolFxsResponse._embedded.records, + poolFxsResponse._embedded.records ); done(); }) diff --git a/test/unit/horizon/path_test.js b/test/unit/horizon/path_test.js index ef536d063..e51110f1d 100644 --- a/test/unit/horizon/path_test.js +++ b/test/unit/horizon/path_test.js @@ -1,4 +1,4 @@ -describe("horizon path tests", function () { +describe('horizon path tests', function () { beforeEach(function () { this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); @@ -16,20 +16,20 @@ describe("horizon path tests", function () { data: { url: serverUrl, random: Math.round(1000 * Math.random()), - endpoint: "bogus", - }, + endpoint: 'bogus' + } }; function prepareAxios(axiosMock, endpoint) { randomResult.endpoint = endpoint; axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(serverUrl + endpoint)) .returns(Promise.resolve(randomResult)); } - it("server.accounts() " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/accounts"); + it('server.accounts() ' + serverUrl, function (done) { + prepareAxios(this.axiosMock, '/accounts'); server .accounts() .call() @@ -40,18 +40,18 @@ describe("horizon path tests", function () { it( "server.accounts().accountId('fooAccountId') " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/accounts/fooAccountId"); + prepareAxios(this.axiosMock, '/accounts/fooAccountId'); server .accounts() - .accountId("fooAccountId") + .accountId('fooAccountId') .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - }, + } ); - it("server.transactions() " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/transactions"); + it('server.transactions() ' + serverUrl, function (done) { + prepareAxios(this.axiosMock, '/transactions'); server .transactions() .call() @@ -60,20 +60,20 @@ describe("horizon path tests", function () { }); it( - "server.transactions().includeFailed(true) " + serverUrl, + 'server.transactions().includeFailed(true) ' + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/transactions?include_failed=true"); + prepareAxios(this.axiosMock, '/transactions?include_failed=true'); server .transactions() .includeFailed(true) .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - }, + } ); - it("server.operations().includeFailed(true) " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/operations?include_failed=true"); + it('server.operations().includeFailed(true) ' + serverUrl, function (done) { + prepareAxios(this.axiosMock, '/operations?include_failed=true'); server .operations() .includeFailed(true) @@ -85,59 +85,59 @@ describe("horizon path tests", function () { it( "server.transactions().transaction('fooTransactionId') " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/transactions/fooTransactionId"); + prepareAxios(this.axiosMock, '/transactions/fooTransactionId'); server .transactions() - .transaction("fooTransactionId") + .transaction('fooTransactionId') .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - }, + } ); it( "server.transactions().forAccount('fooAccountId') " + serverUrl, function (done) { - prepareAxios(this.axiosMock, "/accounts/fooAccountId/transactions"); + prepareAxios(this.axiosMock, '/accounts/fooAccountId/transactions'); server .transactions() - .forAccount("fooAccountId") + .forAccount('fooAccountId') .call() .should.eventually.deep.equal(randomResult.data) .notify(done); - }, + } ); - it("server.submitTransaction() " + serverUrl, function (done) { - randomResult.endpoint = "post"; + it('server.submitTransaction() ' + serverUrl, function (done) { + randomResult.endpoint = 'post'; let keypair = StellarSdk.Keypair.random(); let account = new StellarSdk.Account( keypair.publicKey(), - "56199647068161", + '56199647068161' ); let fakeTransaction = new StellarSdk.TransactionBuilder(account, { fee: 100, - networkPassphrase: StellarSdk.Networks.TESTNET, + networkPassphrase: StellarSdk.Networks.TESTNET }) .addOperation( StellarSdk.Operation.payment({ destination: keypair.publicKey(), asset: StellarSdk.Asset.native(), - amount: "100.50", - }), + amount: '100.50' + }) ) .setTimeout(StellarSdk.TimeoutInfinite) .build(); fakeTransaction.sign(keypair); let tx = encodeURIComponent( - fakeTransaction.toEnvelope().toXDR().toString("base64"), + fakeTransaction.toEnvelope().toXDR().toString('base64') ); this.axiosMock - .expects("post") - .withArgs(sinon.match(serverUrl + "/transactions", `tx=${tx}`)) + .expects('post') + .withArgs(sinon.match(serverUrl + '/transactions', `tx=${tx}`)) .returns(Promise.resolve(randomResult)); server @@ -150,13 +150,13 @@ describe("horizon path tests", function () { let serverUrls = []; //server url without folder path. - serverUrls.push("https://acme.com:1337"); + serverUrls.push('https://acme.com:1337'); //server url folder path. - serverUrls.push("https://acme.com:1337/folder"); + serverUrls.push('https://acme.com:1337/folder'); //server url folder and subfolder path. - serverUrls.push("https://acme.com:1337/folder/subfolder"); + serverUrls.push('https://acme.com:1337/folder/subfolder'); for (var index = 0; index < serverUrls.length; index++) { var serverUrl = serverUrls[index]; diff --git a/test/unit/horizon/server_check_memo_required_test.js b/test/unit/horizon/server_check_memo_required_test.js index 2365a00d9..2dc2a46b3 100644 --- a/test/unit/horizon/server_check_memo_required_test.js +++ b/test/unit/horizon/server_check_memo_required_test.js @@ -2,20 +2,20 @@ function buildTransaction(destination, operations = [], builderOpts = {}) { let txBuilderOpts = { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET, - v1: true, + v1: true }; Object.assign(txBuilderOpts, builderOpts); let keypair = StellarSdk.Keypair.random(); - let account = new StellarSdk.Account(keypair.publicKey(), "56199647068161"); + let account = new StellarSdk.Account(keypair.publicKey(), '56199647068161'); let transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ).addOperation( StellarSdk.Operation.payment({ destination: destination, asset: StellarSdk.Asset.native(), - amount: "100.50", - }), + amount: '100.50' + }) ); operations.forEach((op) => (transaction = transaction.addOperation(op))); @@ -26,9 +26,9 @@ function buildTransaction(destination, operations = [], builderOpts = {}) { if (builderOpts.feeBump) { return StellarSdk.TransactionBuilder.buildFeeBumpTransaction( keypair, - "200", + '200', transaction, - txBuilderOpts.networkPassphrase, + txBuilderOpts.networkPassphrase ); } else { return transaction; @@ -40,40 +40,40 @@ function buildAccount(id, data = {}) { _links: { data: { href: `https://horizon-testnet.stellar.org/accounts/${id}/data/{key}`, - templated: true, - }, + templated: true + } }, id: id, account_id: id, - sequence: "3298702387052545", + sequence: '3298702387052545', subentry_count: 1, last_modified_ledger: 768061, thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, - auth_immutable: false, + auth_immutable: false }, balances: [ { - balance: "9999.9999900", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", - asset_type: "native", - }, + balance: '9999.9999900', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', + asset_type: 'native' + } ], signers: [ { weight: 1, key: id, - type: "ed25519_public_key", - }, + type: 'ed25519_public_key' + } ], - data: data, + data: data }; } @@ -83,12 +83,12 @@ function mockAccountRequest(axiosMock, id, status, data = {}) { switch (status) { case 404: response = Promise.reject({ - response: { status: 404, statusText: "NotFound", data: {} }, + response: { status: 404, statusText: 'NotFound', data: {} } }); break; case 400: response = Promise.reject({ - response: { status: 400, statusText: "BadRequestError", data: {} }, + response: { status: 400, statusText: 'BadRequestError', data: {} } }); break; default: @@ -97,15 +97,15 @@ function mockAccountRequest(axiosMock, id, status, data = {}) { } axiosMock - .expects("get") + .expects('get') .withArgs(sinon.match(`https://horizon-testnet.stellar.org/accounts/${id}`)) .returns(response) .once(); } -describe("server.js check-memo-required", function () { +describe('server.js check-memo-required', function () { beforeEach(function () { - this.server = new StellarSdk.Server("https://horizon-testnet.stellar.org"); + this.server = new StellarSdk.Server('https://horizon-testnet.stellar.org'); this.axiosMock = sinon.mock(AxiosClient); }); @@ -114,10 +114,10 @@ describe("server.js check-memo-required", function () { this.axiosMock.restore(); }); - it("fails if memo is required", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + it('fails if memo is required', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 200, { - "config.memo_required": "MQ==", + 'config.memo_required': 'MQ==' }); let transaction = buildTransaction(accountId); @@ -125,24 +125,24 @@ describe("server.js check-memo-required", function () { .checkMemoRequired(transaction) .then( function () { - expect.fail("promise should have failed"); + expect.fail('promise should have failed'); }, function (err) { expect(err).to.be.instanceOf(StellarSdk.AccountRequiresMemoError); expect(err.accountId).to.eq(accountId); expect(err.operationIndex).to.eq(0); done(); - }, + } ) .catch(function (err) { done(err); }); }); - it("fee bump - fails if memo is required", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + it('fee bump - fails if memo is required', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 200, { - "config.memo_required": "MQ==", + 'config.memo_required': 'MQ==' }); let transaction = buildTransaction(accountId, [], { feeBump: true }); @@ -150,14 +150,14 @@ describe("server.js check-memo-required", function () { .checkMemoRequired(transaction) .then( function () { - expect.fail("promise should have failed"); + expect.fail('promise should have failed'); }, function (err) { expect(err).to.be.instanceOf(StellarSdk.AccountRequiresMemoError); expect(err.accountId).to.eq(accountId); expect(err.operationIndex).to.eq(0); done(); - }, + } ) .catch(function (err) { done(err); @@ -165,7 +165,7 @@ describe("server.js check-memo-required", function () { }); it("returns false if account doesn't exist", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 404, {}); let transaction = buildTransaction(accountId); @@ -179,8 +179,8 @@ describe("server.js check-memo-required", function () { }); }); - it("returns false if data field is not present", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + it('returns false if data field is not present', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 200, {}); let transaction = buildTransaction(accountId); @@ -194,8 +194,8 @@ describe("server.js check-memo-required", function () { }); }); - it("returns err with client errors", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + it('returns err with client errors', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 400, {}); let transaction = buildTransaction(accountId); @@ -203,12 +203,12 @@ describe("server.js check-memo-required", function () { .checkMemoRequired(transaction) .then( function () { - expect.fail("promise should have failed"); + expect.fail('promise should have failed'); }, function (err) { expect(err).to.be.instanceOf(StellarSdk.NetworkError); done(); - }, + } ) .catch(function (err) { done(err); @@ -216,15 +216,15 @@ describe("server.js check-memo-required", function () { }); it("doesn't repeat account check if the destination is more than once", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 200, {}); let operations = [ StellarSdk.Operation.payment({ destination: accountId, asset: StellarSdk.Asset.native(), - amount: "100.50", - }), + amount: '100.50' + }) ]; let transaction = buildTransaction(accountId, operations); @@ -239,52 +239,52 @@ describe("server.js check-memo-required", function () { }); }); - it("other operations", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; + it('other operations', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; mockAccountRequest(this.axiosMock, accountId, 200, {}); const destinations = [ - "GASGNGGXDNJE5C2O7LDCATIVYSSTZKB24SHYS6F4RQT4M4IGNYXB4TIV", - "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB", - "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ", + 'GASGNGGXDNJE5C2O7LDCATIVYSSTZKB24SHYS6F4RQT4M4IGNYXB4TIV', + 'GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB', + 'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ' ]; const usd = new StellarSdk.Asset( - "USD", - "GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB", + 'USD', + 'GBBM6BKZPEHWYO3E3YKREDPQXMS4VK35YLNU7NFBRI26RAN7GI5POFBB' ); const eur = new StellarSdk.Asset( - "EUR", - "GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL", + 'EUR', + 'GDTNXRLOJD2YEBPKK7KCMR7J33AAG5VZXHAJTHIG736D6LVEFLLLKPDL' ); const liquidityPoolAsset = new StellarSdk.LiquidityPoolAsset(eur, usd, 30); let operations = [ StellarSdk.Operation.accountMerge({ - destination: destinations[0], + destination: destinations[0] }), StellarSdk.Operation.pathPaymentStrictReceive({ sendAsset: StellarSdk.Asset.native(), - sendMax: "5.0000000", + sendMax: '5.0000000', destination: destinations[1], destAsset: StellarSdk.Asset.native(), - destAmount: "5.50", - path: [usd, eur], + destAmount: '5.50', + path: [usd, eur] }), StellarSdk.Operation.pathPaymentStrictSend({ sendAsset: StellarSdk.Asset.native(), - sendAmount: "5.0000000", + sendAmount: '5.0000000', destination: destinations[2], destAsset: StellarSdk.Asset.native(), - destMin: "5.50", - path: [usd, eur], + destMin: '5.50', + path: [usd, eur] }), StellarSdk.Operation.changeTrust({ - asset: usd, + asset: usd }), StellarSdk.Operation.changeTrust({ - asset: liquidityPoolAsset, - }), + asset: liquidityPoolAsset + }) ]; destinations.forEach((d) => mockAccountRequest(this.axiosMock, d, 200, {})); @@ -300,9 +300,9 @@ describe("server.js check-memo-required", function () { done(err); }); }); - it("checks for memo required by default", function (done) { - let accountId = "GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA"; - let memo = StellarSdk.Memo.text("42"); + it('checks for memo required by default', function (done) { + let accountId = 'GAYHAAKPAQLMGIJYMIWPDWCGUCQ5LAWY4Q7Q3IKSP57O7GUPD3NEOSEA'; + let memo = StellarSdk.Memo.text('42'); let transaction = buildTransaction(accountId, [], { memo }); this.server .checkMemoRequired(transaction) diff --git a/test/unit/horizon/server_test.js b/test/unit/horizon/server_test.js index a35dffc8d..485848dfa 100644 --- a/test/unit/horizon/server_test.js +++ b/test/unit/horizon/server_test.js @@ -1,25 +1,27 @@ -const MockAdapter = require("axios-mock-adapter"); +const MockAdapter = require('axios-mock-adapter'); -describe("Horizon Server constructor", function () { +describe('Horizon Server constructor', function () { const serverUrl = 'https://horizon-live.stellar.org:1337'; - let insecureServerUrl = serverUrl.replace("https://", "http://"); + let insecureServerUrl = serverUrl.replace('https://', 'http://'); - it("throws error for insecure server", function () { + it('throws error for insecure server', function () { expect(() => new StellarSdk.Server(insecureServerUrl)).to.throw( /Cannot connect to insecure horizon server/i ); }); - it("allow insecure server when opts.allowHttp flag is set", function () { + it('allow insecure server when opts.allowHttp flag is set', function () { expect( () => new StellarSdk.Server(insecureServerUrl, { allowHttp: true }) ).to.not.throw(); }); }); -describe("Horizon Server non-transaction tests", function () { +describe('Horizon Server non-transaction tests', function () { beforeEach(function () { - this.server = new StellarSdk.Server('https://horizon-live.stellar.org:1337'); + this.server = new StellarSdk.Server( + 'https://horizon-live.stellar.org:1337' + ); this.axiosMock = sinon.mock(AxiosClient); StellarSdk.Config.setDefault(); }); @@ -29,7 +31,7 @@ describe("Horizon Server non-transaction tests", function () { this.axiosMock.restore(); }); - describe("Server.fetchTimebounds", function () { + describe('Server.fetchTimebounds', function () { let clock; beforeEach(function () { @@ -48,9 +50,9 @@ describe("Horizon Server non-transaction tests", function () { // the next two tests are run in a deliberate order!! // don't change the order!! - it("fetches falls back to local time if fetch is bad", function (done) { + it('fetches falls back to local time if fetch is bad', function (done) { this.axiosMockAdapter - .onGet("https://horizon-live.stellar.org:1337/") + .onGet('https://horizon-live.stellar.org:1337/') .reply(200, {}, {}); this.server @@ -64,15 +66,15 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("fetches if nothing is recorded", function (done) { + it('fetches if nothing is recorded', function (done) { this.axiosMockAdapter - .onGet("https://horizon-live.stellar.org:1337/") + .onGet('https://horizon-live.stellar.org:1337/') .reply( 200, {}, { - date: "Wed, 13 Mar 2019 22:15:07 GMT", - }, + date: 'Wed, 13 Mar 2019 22:15:07 GMT' + } ); this.server @@ -81,7 +83,7 @@ describe("Horizon Server non-transaction tests", function () { expect(serverTime).to.eql({ minTime: 0, // this is server time 1552515307 plus 20 - maxTime: 1552515327, + maxTime: 1552515327 }); done(); @@ -92,50 +94,50 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Server.fetchBaseFee", function () { + describe('Server.fetchBaseFee', function () { let response = { - last_ledger: "256736", - last_ledger_base_fee: "888", - ledger_capacity_usage: "0.18", + last_ledger: '256736', + last_ledger_base_fee: '888', + ledger_capacity_usage: '0.18', max_fee: { - max: "2000", - min: "100", - mode: "2000", - p10: "100", - p20: "100", - p30: "100", - p40: "300", - p50: "650", - p60: "2000", - p70: "2000", - p80: "2000", - p90: "2000", - p95: "2000", - p99: "2000", + max: '2000', + min: '100', + mode: '2000', + p10: '100', + p20: '100', + p30: '100', + p40: '300', + p50: '650', + p60: '2000', + p70: '2000', + p80: '2000', + p90: '2000', + p95: '2000', + p99: '2000' }, fee_charged: { - min: "100", - max: "100", - mode: "100", - p10: "100", - p20: "100", - p30: "100", - p40: "100", - p50: "100", - p60: "100", - p70: "100", - p80: "100", - p90: "100", - p95: "100", - p99: "100", - }, + min: '100', + max: '100', + mode: '100', + p10: '100', + p20: '100', + p30: '100', + p40: '100', + p50: '100', + p60: '100', + p70: '100', + p80: '100', + p90: '100', + p95: '100', + p99: '100' + } }; - it("returns the base reserve", function (done) { + it('returns the base reserve', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), + sinon.match('https://horizon-live.stellar.org:1337/fee_stats') ) .returns(Promise.resolve({ data: response })); @@ -150,11 +152,11 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("returns default value (100) if last_ledger_base_fee is missing", function (done) { + it('returns default value (100) if last_ledger_base_fee is missing', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), + sinon.match('https://horizon-live.stellar.org:1337/fee_stats') ) .returns(Promise.resolve({ data: {} })); @@ -170,50 +172,50 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Server.feeStats", function () { + describe('Server.feeStats', function () { let response = { - last_ledger: "256736", - last_ledger_base_fee: "100", - ledger_capacity_usage: "0.18", + last_ledger: '256736', + last_ledger_base_fee: '100', + ledger_capacity_usage: '0.18', max_fee: { - max: "2000", - min: "100", - mode: "2000", - p10: "100", - p20: "100", - p30: "100", - p40: "300", - p50: "650", - p60: "2000", - p70: "2000", - p80: "2000", - p90: "2000", - p95: "2000", - p99: "2000", + max: '2000', + min: '100', + mode: '2000', + p10: '100', + p20: '100', + p30: '100', + p40: '300', + p50: '650', + p60: '2000', + p70: '2000', + p80: '2000', + p90: '2000', + p95: '2000', + p99: '2000' }, fee_charged: { - min: "100", - max: "100", - mode: "100", - p10: "100", - p20: "100", - p30: "100", - p40: "100", - p50: "100", - p60: "100", - p70: "100", - p80: "100", - p90: "100", - p95: "100", - p99: "100", - }, + min: '100', + max: '100', + mode: '100', + p10: '100', + p20: '100', + p30: '100', + p40: '100', + p50: '100', + p60: '100', + p70: '100', + p80: '100', + p90: '100', + p95: '100', + p99: '100' + } }; - it("returns the base reserve", function (done) { + it('returns the base reserve', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/fee_stats"), + sinon.match('https://horizon-live.stellar.org:1337/fee_stats') ) .returns(Promise.resolve({ data: response })); @@ -229,7 +231,7 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Server.loadAccount", function () { + describe('Server.loadAccount', function () { //prettier-ignore let accountResponse = { "_links": { @@ -311,36 +313,36 @@ describe("Horizon Server non-transaction tests", function () { "data": {} }; - it("returns AccountResponse object", function (done) { + it('returns AccountResponse object', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS", - ), + 'https://horizon-live.stellar.org:1337/accounts/GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS' + ) ) .returns(Promise.resolve({ data: accountResponse })); this.server - .loadAccount("GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS") + .loadAccount('GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS') .then((response) => { // Response data expect(response.account_id).to.be.equal( - "GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS", + 'GBAH7FQMC3CZJ4WD6GE7G7YXCIU36LC2IHXQ7D5MQAUO4PODOWIVLSFS' ); expect(response.subentry_count).to.be.equal(5); - expect(response.transactions).to.be.a("function"); - expect(response.operations).to.be.a("function"); - expect(response.payments).to.be.a("function"); - expect(response.effects).to.be.a("function"); - expect(response.offers).to.be.a("function"); + expect(response.transactions).to.be.a('function'); + expect(response.operations).to.be.a('function'); + expect(response.payments).to.be.a('function'); + expect(response.effects).to.be.a('function'); + expect(response.offers).to.be.a('function'); expect(Object.keys(response.flags).length).to.be.equal(4); // AccountResponse methods - expect(response.sequenceNumber()).to.be.equal("5387216134078475"); - expect(response.sequence).to.be.equal("5387216134078475"); + expect(response.sequenceNumber()).to.be.equal('5387216134078475'); + expect(response.sequence).to.be.equal('5387216134078475'); response.incrementSequenceNumber(); - expect(response.sequenceNumber()).to.be.equal("5387216134078476"); - expect(response.sequence).to.be.equal("5387216134078476"); + expect(response.sequenceNumber()).to.be.equal('5387216134078476'); + expect(response.sequence).to.be.equal('5387216134078476'); done(); }) .catch(function (err) { @@ -349,59 +351,59 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Server._sendResourceRequest", function () { - describe("requests all ledgers", function () { + describe('Server._sendResourceRequest', function () { + describe('requests all ledgers', function () { let ledgersResponse = { _embedded: { records: [ { _links: { effects: { - href: "/ledgers/1/effects{?cursor,limit,order}", - templated: true, + href: '/ledgers/1/effects{?cursor,limit,order}', + templated: true }, operations: { - href: "/ledgers/1/operations{?cursor,limit,order}", - templated: true, + href: '/ledgers/1/operations{?cursor,limit,order}', + templated: true }, self: { - href: "/ledgers/1", + href: '/ledgers/1' }, transactions: { - href: "/ledgers/1/transactions{?cursor,limit,order}", - templated: true, - }, + href: '/ledgers/1/transactions{?cursor,limit,order}', + templated: true + } }, - id: "63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99", - paging_token: "4294967296", - hash: "63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99", + id: '63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99', + paging_token: '4294967296', + hash: '63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99', sequence: 1, transaction_count: 0, operation_count: 0, tx_set_operation_count: 0, - closed_at: "1970-01-01T00:00:00Z", - }, - ], + closed_at: '1970-01-01T00:00:00Z' + } + ] }, _links: { next: { - href: "/ledgers?order=asc\u0026limit=1\u0026cursor=4294967296", + href: '/ledgers?order=asc\u0026limit=1\u0026cursor=4294967296' }, prev: { - href: "/ledgers?order=desc\u0026limit=1\u0026cursor=4294967296", + href: '/ledgers?order=desc\u0026limit=1\u0026cursor=4294967296' }, self: { - href: "/ledgers?order=asc\u0026limit=1\u0026cursor=", - }, - }, + href: '/ledgers?order=asc\u0026limit=1\u0026cursor=' + } + } }; - describe("without options", function () { - it("requests the correct endpoint", function (done) { + describe('without options', function () { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers"), + sinon.match('https://horizon-live.stellar.org:1337/ledgers') ) .returns(Promise.resolve({ data: ledgersResponse })); @@ -410,10 +412,10 @@ describe("Horizon Server non-transaction tests", function () { .call() .then((response) => { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records, + ledgersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -422,58 +424,58 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("with options", function () { + describe('with options', function () { beforeEach(function () { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers?limit=1&cursor=b&order=asc", - ), + 'https://horizon-live.stellar.org:1337/ledgers?limit=1&cursor=b&order=asc' + ) ) .returns(Promise.resolve({ data: ledgersResponse })); }); - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { this.server .ledgers() - .limit("1") - .cursor("b") - .order("asc") + .limit('1') + .cursor('b') + .order('asc') .call() .then((response) => { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records, + ledgersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }); }); - it("can call .next() on the result to retrieve the next page", function (done) { + it('can call .next() on the result to retrieve the next page', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers?order=asc&limit=1&cursor=4294967296", - ), + 'https://horizon-live.stellar.org:1337/ledgers?order=asc&limit=1&cursor=4294967296' + ) ) .returns(Promise.resolve({ data: ledgersResponse })); this.server .ledgers() - .limit("1") - .cursor("b") - .order("asc") + .limit('1') + .cursor('b') + .order('asc') .call() .then(function (page) { page.next().then(function (response) { expect(response.records).to.be.deep.equal( - ledgersResponse._embedded.records, + ledgersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }); }); @@ -481,46 +483,46 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("requests a single ledger", function () { + describe('requests a single ledger', function () { let singleLedgerResponse = { _links: { effects: { - href: "/ledgers/1/effects{?cursor,limit,order}", - templated: true, + href: '/ledgers/1/effects{?cursor,limit,order}', + templated: true }, operations: { - href: "/ledgers/1/operations{?cursor,limit,order}", - templated: true, + href: '/ledgers/1/operations{?cursor,limit,order}', + templated: true }, self: { - href: "/ledgers/1", + href: '/ledgers/1' }, transactions: { - href: "/ledgers/1/transactions{?cursor,limit,order}", - templated: true, - }, + href: '/ledgers/1/transactions{?cursor,limit,order}', + templated: true + } }, - id: "63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99", - paging_token: "4294967296", - hash: "63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99", + id: '63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99', + paging_token: '4294967296', + hash: '63d98f536ee68d1b27b5b89f23af5311b7569a24faf1403ad0b52b633b07be99', sequence: 1, transaction_count: 0, operation_count: 0, tx_set_operation_count: 0, - closed_at: "1970-01-01T00:00:00Z", + closed_at: '1970-01-01T00:00:00Z' }; - describe("for a non existent ledger", function () { - it("throws a NotFoundError", function (done) { + describe('for a non existent ledger', function () { + it('throws a NotFoundError', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers/1"), + sinon.match('https://horizon-live.stellar.org:1337/ledgers/1') ) .returns( Promise.reject({ - response: { status: 404, statusText: "NotFound", data: {} }, - }), + response: { status: 404, statusText: 'NotFound', data: {} } + }) ); this.server @@ -539,18 +541,18 @@ describe("Horizon Server non-transaction tests", function () { }); }); }); - describe("without options", function () { - it("requests the correct endpoint", function (done) { + describe('without options', function () { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/ledgers/1"), + sinon.match('https://horizon-live.stellar.org:1337/ledgers/1') ) .returns(Promise.resolve({ data: singleLedgerResponse })); this.server .ledgers() - .ledger("1") + .ledger('1') .call() .then(function (response) { expect(response).to.be.deep.equal(singleLedgerResponse); @@ -562,23 +564,23 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("with options", function () { - it("requests the correct endpoint", function (done) { + describe('with options', function () { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/1?limit=1&cursor=b&order=asc", - ), + 'https://horizon-live.stellar.org:1337/ledgers/1?limit=1&cursor=b&order=asc' + ) ) .returns(Promise.resolve({ data: singleLedgerResponse })); this.server .ledgers() - .ledger("1") - .limit("1") - .cursor("b") - .order("asc") + .ledger('1') + .limit('1') + .cursor('b') + .order('asc') .call() .then(function (response) { expect(response).to.be.deep.equal(singleLedgerResponse); @@ -591,92 +593,92 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("requests a sub resource", function (done) { + describe('requests a sub resource', function (done) { let transactionsResponse = { _links: { self: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026limit=1\u0026cursor=", + href: 'https://horizon.stellar.org/transactions?order=desc\u0026limit=1\u0026cursor=' }, next: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026limit=1\u0026cursor=34156680904183808", + href: 'https://horizon.stellar.org/transactions?order=desc\u0026limit=1\u0026cursor=34156680904183808' }, prev: { - href: "https://horizon.stellar.org/transactions?order=asc\u0026limit=1\u0026cursor=34156680904183808", - }, + href: 'https://horizon.stellar.org/transactions?order=asc\u0026limit=1\u0026cursor=34156680904183808' + } }, _embedded: { records: [ { _links: { self: { - href: "https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1", + href: 'https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1' }, account: { - href: "https://horizon.stellar.org/accounts/GBURK32BMC7XORYES62HDKY7VTA5MO7JYBDH7KTML4EPN4BV2MIRQOVR", + href: 'https://horizon.stellar.org/accounts/GBURK32BMC7XORYES62HDKY7VTA5MO7JYBDH7KTML4EPN4BV2MIRQOVR' }, ledger: { - href: "https://horizon.stellar.org/ledgers/7952722", + href: 'https://horizon.stellar.org/ledgers/7952722' }, operations: { - href: "https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon.stellar.org/transactions?order=asc\u0026cursor=34156680904183808", + href: 'https://horizon.stellar.org/transactions?order=asc\u0026cursor=34156680904183808' }, succeeds: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026cursor=34156680904183808", - }, + href: 'https://horizon.stellar.org/transactions?order=desc\u0026cursor=34156680904183808' + } }, - id: "c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1", - paging_token: "34156680904183808", - hash: "c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1", + id: 'c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1', + paging_token: '34156680904183808', + hash: 'c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1', ledger: 7952722, - created_at: "2016-12-09T12:36:51Z", + created_at: '2016-12-09T12:36:51Z', source_account: - "GBURK32BMC7XORYES62HDKY7VTA5MO7JYBDH7KTML4EPN4BV2MIRQOVR", - source_account_sequence: "25631492944168311", + 'GBURK32BMC7XORYES62HDKY7VTA5MO7JYBDH7KTML4EPN4BV2MIRQOVR', + source_account_sequence: '25631492944168311', fee_charged: 3600, max_fee: 3600, operation_count: 4, envelope_xdr: - "AAAAAGkVb0Fgv3dHBJe0casfrMHWO+nARn+qbF8I9vA10xEYAAABkABbD7UAAAV3AAAAAAAAAA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oYQw/PdJZHUk74JVWRHDPwcqzGP+lSJljl6ABBRPqXewP1jAzpgY+vicDeLR/35/HyDyeAG7H0Aw==", - ], - }, - ], - }, + 'pox1kE2/f2oYQw/PdJZHUk74JVWRHDPwcqzGP+lSJljl6ABBRPqXewP1jAzpgY+vicDeLR/35/HyDyeAG7H0Aw==' + ] + } + ] + } }; - describe("without options", function () { - it("requests the correct endpoint", function (done) { + describe('without options', function () { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions", - ), + 'https://horizon-live.stellar.org:1337/ledgers/7952722/transactions' + ) ) .returns(Promise.resolve({ data: transactionsResponse })); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations/, - ), + /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations/ + ) ) .returns(Promise.resolve({ data: { operations: [] } })); @@ -686,12 +688,12 @@ describe("Horizon Server non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records, + transactionsResponse._embedded.records ); - expect(response.records[0].ledger).to.be.a("function"); + expect(response.records[0].ledger).to.be.a('function'); expect(response.records[0].ledger_attr).to.be.equal(7952722); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); response.records[0] .operations() @@ -708,39 +710,39 @@ describe("Horizon Server non-transaction tests", function () { }); }); }); - describe("with options", function () { - it("requests the correct endpoint", function (done) { + describe('with options', function () { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/7952722/transactions?cursor=b&limit=1&order=asc", - ), + 'https://horizon-live.stellar.org:1337/ledgers/7952722/transactions?cursor=b&limit=1&order=asc' + ) ) .returns(Promise.resolve({ data: transactionsResponse })); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations\?limit=1/, - ), + /^https:\/\/horizon.stellar.org\/transactions\/c585b8764b28be678c482f8b6e87e76e4b5f28043c53f4dcb7b724b4b2efebc1\/operations\?limit=1/ + ) ) .returns(Promise.resolve({ data: { operations: [] } })); this.server .transactions() - .forLedger("7952722") - .cursor("b") - .limit("1") - .order("asc") + .forLedger('7952722') + .cursor('b') + .limit('1') + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records, + transactionsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); response.records[0] .operations({ limit: 1 }) .then(function (response) { @@ -759,88 +761,88 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Server._parseResult", function () { - it("creates link functions", function () { + describe('Server._parseResult', function () { + it('creates link functions', function () { var callBuilder = this.server.ledgers(); var json = callBuilder._parseResponse({ _links: { test: function () { - return "hi"; - }, - }, + return 'hi'; + } + } }); - expect(typeof json.test).to.be.equal("function"); + expect(typeof json.test).to.be.equal('function'); }); }); - describe("Smoke tests for the rest of the builders", function () { - describe("TransactionCallBuilder", function () { - it("#transaction - requests the correct endpoint", function (done) { + describe('Smoke tests for the rest of the builders', function () { + describe('TransactionCallBuilder', function () { + it('#transaction - requests the correct endpoint', function (done) { let singleTranssactionResponse = { _links: { self: { - href: "https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", + href: 'https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0' }, account: { - href: "https://horizon-testnet.stellar.org/accounts/GBCCHT5P34DMK2LTN4SPHBAJCXYFNUEWSM7SDSWEXJA7NN6CA3HNHTM6", + href: 'https://horizon-testnet.stellar.org/accounts/GBCCHT5P34DMK2LTN4SPHBAJCXYFNUEWSM7SDSWEXJA7NN6CA3HNHTM6' }, ledger: { - href: "https://horizon-testnet.stellar.org/ledgers/121879", + href: 'https://horizon-testnet.stellar.org/ledgers/121879' }, operations: { - href: "https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon-testnet.stellar.org/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon-testnet.stellar.org/transactions?order=asc&cursor=523466319077376", + href: 'https://horizon-testnet.stellar.org/transactions?order=asc&cursor=523466319077376' }, succeeds: { - href: "https://horizon-testnet.stellar.org/transactions?order=desc&cursor=523466319077376", - }, + href: 'https://horizon-testnet.stellar.org/transactions?order=desc&cursor=523466319077376' + } }, - id: "6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", - paging_token: "523466319077376", + id: '6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0', + paging_token: '523466319077376', successful: true, - hash: "6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", + hash: '6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0', ledger: 121879, - created_at: "2020-02-06T01:57:18Z", + created_at: '2020-02-06T01:57:18Z', source_account: - "GBCCHT5P34DMK2LTN4SPHBAJCXYFNUEWSM7SDSWEXJA7NN6CA3HNHTM6", - source_account_sequence: "523406189527045", + 'GBCCHT5P34DMK2LTN4SPHBAJCXYFNUEWSM7SDSWEXJA7NN6CA3HNHTM6', + source_account_sequence: '523406189527045', fee_paid: 100, fee_charged: 100, max_fee: 100, operation_count: 1, envelope_xdr: - "AAAAAEQjz6/fBsVpc28k84QJFfBW0JaTPyHKxLpB9rfCBs7TAAAAZAAB3AkAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAMBwd6tPbAYimyr/BzBgOosIbrnrzfxfS/gmfqoDSx0IAAAAAHc1lAAAAAAAAAAABwgbO0wAAAECl/OULPE7Q3ikmwIYeECFtxVH4rh8lmk465QLIeHEeEcbYhaTfgfe8VAwKsYf4YqK+YKiSiI0BqJKDr6CeI3QJ", - result_xdr: "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=", + 'AAAAAEQjz6/fBsVpc28k84QJFfBW0JaTPyHKxLpB9rfCBs7TAAAAZAAB3AkAAAAFAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAMBwd6tPbAYimyr/BzBgOosIbrnrzfxfS/gmfqoDSx0IAAAAAHc1lAAAAAAAAAAABwgbO0wAAAECl/OULPE7Q3ikmwIYeECFtxVH4rh8lmk465QLIeHEeEcbYhaTfgfe8VAwKsYf4YqK+YKiSiI0BqJKDr6CeI3QJ', + result_xdr: 'AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAA=', result_meta_xdr: - "AAAAAQAAAAIAAAADAAHcFwAAAAAAAAAARCPPr98GxWlzbyTzhAkV8FbQlpM/IcrEukH2t8IGztMAAAAW0UFSDAAB3AkAAAAEAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAABAAHcFwAAAAAAAAAARCPPr98GxWlzbyTzhAkV8FbQlpM/IcrEukH2t8IGztMAAAAW0UFSDAAB3AkAAAAFAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAB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AAAAAA==', fee_meta_xdr: - "AAAAAgAAAAMAAdwUAAAAAAAAAABEI8+v3wbFaXNvJPOECRXwVtCWkz8hysS6Qfa3wgbO0wAAABbRQVJwAAHcCQAAAAQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAdwXAAAAAAAAAABEI8+v3wbFaXNvJPOECRXwVtCWkz8hysS6Qfa3wgbO0wAAABbRQVIMAAHcCQAAAAQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", - memo_type: "none", + 'AAAAAgAAAAMAAdwUAAAAAAAAAABEI8+v3wbFaXNvJPOECRXwVtCWkz8hysS6Qfa3wgbO0wAAABbRQVJwAAHcCQAAAAQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAdwXAAAAAAAAAABEI8+v3wbFaXNvJPOECRXwVtCWkz8hysS6Qfa3wgbO0wAAABbRQVIMAAHcCQAAAAQAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'none', signatures: [ - "pfzlCzxO0N4pJsCGHhAhbcVR+K4fJZpOOuUCyHhxHhHG2IWk34H3vFQMCrGH+GKivmCokoiNAaiSg6+gniN0CQ==", - ], + 'pfzlCzxO0N4pJsCGHhAhbcVR+K4fJZpOOuUCyHhxHhHG2IWk34H3vFQMCrGH+GKivmCokoiNAaiSg6+gniN0CQ==' + ] }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", - ), + 'https://horizon-live.stellar.org:1337/transactions/6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0' + ) ) .returns(Promise.resolve({ data: singleTranssactionResponse })); this.server .transactions() .transaction( - "6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0", + '6bbd8cbd90498a26210a21ec599702bead8f908f412455da300318aba36831b0' ) .call() .then(function (response) { @@ -855,198 +857,198 @@ describe("Horizon Server non-transaction tests", function () { const transactionsResponse = { _links: { self: { - href: "https://horizon.stellar.org/transactions?cursor=\u0026limit=3\u0026order=asc", + href: 'https://horizon.stellar.org/transactions?cursor=\u0026limit=3\u0026order=asc' }, next: { - href: "https://horizon.stellar.org/transactions?cursor=33736968114176\u0026limit=3\u0026order=asc", + href: 'https://horizon.stellar.org/transactions?cursor=33736968114176\u0026limit=3\u0026order=asc' }, prev: { - href: "https://horizon.stellar.org/transactions?cursor=12884905984\u0026limit=3\u0026order=desc", - }, + href: 'https://horizon.stellar.org/transactions?cursor=12884905984\u0026limit=3\u0026order=desc' + } }, _embedded: { records: [ { - memo: "hello world", + memo: 'hello world', _links: { self: { - href: "https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", + href: 'https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889' }, account: { - href: "https://horizon.stellar.org/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", + href: 'https://horizon.stellar.org/accounts/GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7' }, ledger: { - href: "https://horizon.stellar.org/ledgers/3", + href: 'https://horizon.stellar.org/ledgers/3' }, operations: { - href: "https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon.stellar.org/transactions?order=asc\u0026cursor=12884905984", + href: 'https://horizon.stellar.org/transactions?order=asc\u0026cursor=12884905984' }, succeeds: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026cursor=12884905984", - }, + href: 'https://horizon.stellar.org/transactions?order=desc\u0026cursor=12884905984' + } }, - id: "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", - paging_token: "12884905984", + id: '3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889', + paging_token: '12884905984', successful: true, - hash: "3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889", + hash: '3389e9f0f1a65f19736cacf544c2e825313e8447f569233bb8db39aa607c8889', ledger: 3, - created_at: "2015-09-30T17:15:54Z", + created_at: '2015-09-30T17:15:54Z', source_account: - "GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7", - source_account_sequence: "1", + 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7', + source_account_sequence: '1', fee_charged: 300, max_fee: 300, operation_count: 3, envelope_xdr: - "AAAAAAGUcmKO5465JxTSLQOQljwk2SfqAJmZSG6JH6wtqpwhAAABLAAAAAAAAAABAAAAAAAAAAEAAAALaGVsbG8gd29ybGQAAAAAAwAAAAAAAAAAAAAAABbxCy3mLg3hiTqX4VUEEp60pFOrJNxYM1JtxXTwXhY2AAAAAAvrwgAAAAAAAAAAAQAAAAAW8Qst5i4N4Yk6l+FVBBKetKRTqyTcWDNSbcV08F4WNgAAAAAN4Lazj4x61AAAAAAAAAAFAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABLaqcIQAAAEBKwqWy3TaOxoGnfm9eUjfTRBvPf34dvDA0Nf+B8z4zBob90UXtuCqmQqwMCyH+okO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CWPCTZJ+oAmZlIbokfrC2qnCEAAAAAC+vCAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=', fee_meta_xdr: - "AAAAAgAAAAMAAAABAAAAAAAAAAABlHJijueOuScU0i0DkJY8JNkn6gCZmUhuiR+sLaqcIQ3gtrOnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAABlHJijueOuScU0i0DkJY8JNkn6gCZmUhuiR+sLaqcIQ3gtrOnY/7UAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==", - memo_type: "text", + 'AAAAAgAAAAMAAAABAAAAAAAAAAABlHJijueOuScU0i0DkJY8JNkn6gCZmUhuiR+sLaqcIQ3gtrOnZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAAADAAAAAAAAAAABlHJijueOuScU0i0DkJY8JNkn6gCZmUhuiR+sLaqcIQ3gtrOnY/7UAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'text', signatures: [ - "SsKlst02jsaBp35vXlI300Qbz39+HbwwNDX/gfM+MwaG/dFF7bgqpkKsDAsh/qJDiN3NOW695IZB9Mj+JAsHBA==", - ], + 'SsKlst02jsaBp35vXlI300Qbz39+HbwwNDX/gfM+MwaG/dFF7bgqpkKsDAsh/qJDiN3NOW695IZB9Mj+JAsHBA==' + ] }, { - memo: "testpool,faucet,sdf", + memo: 'testpool,faucet,sdf', _links: { self: { - href: "https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a", + href: 'https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a' }, account: { - href: "https://horizon.stellar.org/accounts/GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB", + href: 'https://horizon.stellar.org/accounts/GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB' }, ledger: { - href: "https://horizon.stellar.org/ledgers/7841", + href: 'https://horizon.stellar.org/ledgers/7841' }, operations: { - href: "https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon.stellar.org/transactions?order=asc\u0026cursor=33676838572032", + href: 'https://horizon.stellar.org/transactions?order=asc\u0026cursor=33676838572032' }, succeeds: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026cursor=33676838572032", - }, + href: 'https://horizon.stellar.org/transactions?order=desc\u0026cursor=33676838572032' + } }, - id: "2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a", - paging_token: "33676838572032", + id: '2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a', + paging_token: '33676838572032', successful: true, - hash: "2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a", + hash: '2db4b22ca018119c5027a80578813ffcf582cda4aa9e31cd92b43cf1bda4fc5a', ledger: 7841, - created_at: "2015-10-01T04:15:01Z", + created_at: '2015-10-01T04:15:01Z', source_account: - "GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB", - source_account_sequence: "12884901890", + 'GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB', + source_account_sequence: '12884901890', fee_charged: 300, max_fee: 300, operation_count: 3, envelope_xdr: - "AAAAABbxCy3mLg3hiTqX4VUEEp60pFOrJNxYM1JtxXTwXhY2AAABLAAAAAMAAAACAAAAAAAAAAEAAAATdGVzdHBvb2wsZmF1Y2V0LHNkZgAAAAADAAAAAAAAAAAAAAAAH6Ue1GOPj6Hb/ROPyIFCJpQPMujihEIvJSfK0UfMDIgAAAAAC+vCAAAAAAAAAAAAAAAAALMw4P7yJTyqj6ptNh7BPyXEoT+zVwTcU4JVbGyonvgbAAAAAAvrwgAAAAAAAAAAAAAAAABJlwu05Op/5x1uyrweYsyR6pTTos33hRNZe5IF6blnzwAAAAAL68IAAAAAAAAAAAHwXhY2AAAAQDSBB5eNEKkWIoQbZ1YQabJuE5mW/AKhrHTxw9H3m/sai90YcaZlsAe3ueO9jExjSZF289ZcR4vc0wFw1p/WyAc=", + 'AAAAABbxCy3mLg3hiTqX4VUEEp60pFOrJNxYM1JtxXTwXhY2AAABLAAAAAMAAAACAAAAAAAAAAEAAAATdGVzdHBvb2wsZmF1Y2V0LHNkZgAAAAADAAAAAAAAAAAAAAAAH6Ue1GOPj6Hb/ROPyIFCJpQPMujihEIvJSfK0UfMDIgAAAAAC+vCAAAAAAAAAAAAAAAAALMw4P7yJTyqj6ptNh7BPyXEoT+zVwTcU4JVbGyonvgbAAAAAAvrwgAAAAAAAAAAAAAAAABJlwu05Op/5x1uyrweYsyR6pTTos33hRNZe5IF6blnzwAAAAAL68IAAAAAAAAAAAHwXhY2AAAAQDSBB5eNEKkWIoQbZ1YQabJuE5mW/AKhrHTxw9H3m/sai90YcaZlsAe3ueO9jExjSZF289ZcR4vc0wFw1p/WyAc=', result_xdr: - "AAAAAAAAASwAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAAAA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AAAwAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAB6hAAAAAAAAAAAW8Qst5i4N4Yk6l+FVBBKetKRTqyTcWDNSbcV08F4WNg3gtrObeDp8AAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'text', signatures: [ - "NIEHl40QqRYihBtnVhBpsm4TmZb8AqGsdPHD0feb+xqL3RhxpmWwB7e5472MTGNJkXbz1lxHi9zTAXDWn9bIBw==", - ], + 'NIEHl40QqRYihBtnVhBpsm4TmZb8AqGsdPHD0feb+xqL3RhxpmWwB7e5472MTGNJkXbz1lxHi9zTAXDWn9bIBw==' + ] }, { - memo: "", + memo: '', _links: { self: { - href: "https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a", + href: 'https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a' }, account: { - href: "https://horizon.stellar.org/accounts/GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB", + href: 'https://horizon.stellar.org/accounts/GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB' }, ledger: { - href: "https://horizon.stellar.org/ledgers/7855", + href: 'https://horizon.stellar.org/ledgers/7855' }, operations: { - href: "https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a/operations{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a/operations{?cursor,limit,order}', + templated: true }, effects: { - href: "https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a/effects{?cursor,limit,order}", - templated: true, + href: 'https://horizon.stellar.org/transactions/3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "https://horizon.stellar.org/transactions?order=asc\u0026cursor=33736968114176", + href: 'https://horizon.stellar.org/transactions?order=asc\u0026cursor=33736968114176' }, succeeds: { - href: "https://horizon.stellar.org/transactions?order=desc\u0026cursor=33736968114176", - }, + href: 'https://horizon.stellar.org/transactions?order=desc\u0026cursor=33736968114176' + } }, - id: "3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a", - paging_token: "33736968114176", + id: '3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a', + paging_token: '33736968114176', successful: true, - hash: "3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a", + hash: '3ce2aca2fed36da2faea31352c76c5e412348887a4c119b1e90de8d1b937396a', ledger: 7855, - created_at: "2015-10-01T04:16:11Z", + created_at: '2015-10-01T04:16:11Z', source_account: - "GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB", - source_account_sequence: "12884901891", + 'GALPCCZN4YXA3YMJHKL6CVIECKPLJJCTVMSNYWBTKJW4K5HQLYLDMZTB', + source_account_sequence: '12884901891', fee_charged: 100, max_fee: 100, operation_count: 1, envelope_xdr: - "AAAAABbxCy3mLg3hiTqX4VUEEp60pFOrJNxYM1JtxXTwXhY2AAAAZAAAAAMAAAADAAAAAAAAAAEAAAAAAAAAAQAAAAAAAAAFAAAAAQAAAAAfpR7UY4+Podv9E4/IgUImlA8y6OKEQi8lJ8rRR8wMiAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwXhY2AAAAQNbDcWsR3s3z8Qzqatcdc/k2L4LXWJMA6eXac8dbXkAdc4ppH25isGC5OwvG06Vwvc3Ce3/r2rYcBP3vxhx18A8=", - result_xdr: "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAFAAAAAAAAAAA=", + 'AAAAABbxCy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B6hAAAAAAAAAAAW8Qst5i4N4Yk6l+FVBBKetKRTqyTcWDNSbcV08F4WNg3gtrN3tPR8AAAAAwAAAAIAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAEAAB6vAAAAAAAAAAAW8Qst5i4N4Yk6l+FVBBKetKRTqyTcWDNSbcV08F4WNg3gtrN3tPQYAAAAAwAAAAMAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA==', + memo_type: 'text', signatures: [ - "1sNxaxHezfPxDOpq1x1z+TYvgtdYkwDp5dpzx1teQB1zimkfbmKwYLk7C8bTpXC9zcJ7f+vathwE/e/GHHXwDw==", - ], - }, - ], - }, + '1sNxaxHezfPxDOpq1x1z+TYvgtdYkwDp5dpzx1teQB1zimkfbmKwYLk7C8bTpXC9zcJ7f+vathwE/e/GHHXwDw==' + ] + } + ] + } }; - it("forClaimableBalance() requests the correct endpoint", function (done) { + it('forClaimableBalance() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/transactions", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/transactions' + ) ) .returns(Promise.resolve({ data: transactionsResponse })); this.server .transactions() .forClaimableBalance( - "000000000102030000000000000000000000000000000000000000000000000000000000", + '000000000102030000000000000000000000000000000000000000000000000000000000' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - transactionsResponse._embedded.records, + transactionsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1055,76 +1057,76 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("AccountCallBuilder", function () { - it("requests the correct endpoint", function (done) { + describe('AccountCallBuilder', function () { + it('requests the correct endpoint', function (done) { let singleAccountResponse = { _links: { effects: { - href: "/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects{?cursor,limit,order}", - templated: true, + href: '/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects{?cursor,limit,order}', + templated: true }, offers: { - href: "/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers{?cursor,limit,order}", - templated: true, + href: '/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers{?cursor,limit,order}', + templated: true }, operations: { - href: "/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/operations{?cursor,limit,order}", - templated: true, + href: '/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/operations{?cursor,limit,order}', + templated: true }, self: { - href: "/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + href: '/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K' }, transactions: { - href: "/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/transactions{?cursor,limit,order}", - templated: true, - }, + href: '/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/transactions{?cursor,limit,order}', + templated: true + } }, - id: "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", - paging_token: "146028892161", + id: 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', + paging_token: '146028892161', account_id: - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', sequence: 146028888090, subentry_count: 0, inflation_destination: null, - home_domain: "", + home_domain: '', thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, + auth_clawback_enabled: false }, balances: [ { - asset_type: "native", - balance: "9760000.3997400", - }, + asset_type: 'native', + balance: '9760000.3997400' + } ], signers: [ { public_key: - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", - weight: 1, - }, - ], + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', + weight: 1 + } + ] }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", - ), + 'https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K' + ) ) .returns(Promise.resolve({ data: singleAccountResponse })); this.server .accounts() - .accountId("GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K") + .accountId('GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K') .call() .then(function (response) { expect(response).to.be.deep.equal(singleAccountResponse); @@ -1139,123 +1141,123 @@ describe("Horizon Server non-transaction tests", function () { let accountsForSignerResponse = { _links: { self: { - href: "/accounts?cursor=&limit=10&order=asc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts?cursor=&limit=10&order=asc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, next: { - href: "/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=asc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=asc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, prev: { - href: "/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=desc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - }, + href: '/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=desc&signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' + } }, _embedded: { records: [ { _links: { self: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, transactions: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/transactions{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/transactions{?cursor,limit,order}', + templated: true }, operations: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/operations{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/operations{?cursor,limit,order}', + templated: true }, payments: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/payments{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/payments{?cursor,limit,order}', + templated: true }, effects: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/effects{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/effects{?cursor,limit,order}', + templated: true }, offers: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/offers{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/offers{?cursor,limit,order}', + templated: true }, trades: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/trades{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/trades{?cursor,limit,order}', + templated: true }, data: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/data/{key}", - templated: true, - }, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/data/{key}', + templated: true + } }, - id: "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + id: 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', account_id: - "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - sequence: "4233832731508737", + 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', + sequence: '4233832731508737', subentry_count: 1, last_modified_ledger: 986912, - last_modified_time: "1970-01-01T00:00:00Z", + last_modified_time: '1970-01-01T00:00:00Z', thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, + auth_clawback_enabled: false }, balances: [ { - balance: "0.0000000", - limit: "450.0000000", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", + balance: '0.0000000', + limit: '450.0000000', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', last_modified_ledger: 986912, is_authorized: true, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GDUEG67IE5TJUVWRRTMXDP3Q6EMMZJ6HL5OMWLBYOIUIZEUW2T2PBPJH", + 'GDUEG67IE5TJUVWRRTMXDP3Q6EMMZJ6HL5OMWLBYOIUIZEUW2T2PBPJH' }, { - balance: "9999.9999900", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", - asset_type: "native", - }, + balance: '9999.9999900', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', + asset_type: 'native' + } ], signers: [ { weight: 1, - key: "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - type: "ed25519_public_key", - }, + key: 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', + type: 'ed25519_public_key' + } ], data: {}, paging_token: - "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - }, - ], - }, + 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - ), + 'https://horizon-live.stellar.org:1337/accounts?signer=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' + ) ) .returns(Promise.resolve({ data: accountsForSignerResponse })); this.server .accounts() - .forSigner("GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42") + .forSigner('GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForSignerResponse._embedded.records, + accountsForSignerResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1267,110 +1269,110 @@ describe("Horizon Server non-transaction tests", function () { let accountsForAssetResponse = { _links: { self: { - href: "/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=\u0026limit=10\u0026order=asc", + href: '/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=\u0026limit=10\u0026order=asc' }, next: { - href: "/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=GC4J73PTB5WN7MOJWOAECPHRCV2UU3WCY37L3BNY6RZVKE23JGQYJMJ6\u0026limit=10\u0026order=asc", + href: '/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=GC4J73PTB5WN7MOJWOAECPHRCV2UU3WCY37L3BNY6RZVKE23JGQYJMJ6\u0026limit=10\u0026order=asc' }, prev: { - href: "/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667\u0026limit=10\u0026order=desc", - }, + href: '/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD\u0026cursor=GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667\u0026limit=10\u0026order=desc' + } }, _embedded: { records: [ { _links: { self: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667' }, transactions: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/transactions{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/transactions{?cursor,limit,order}', + templated: true }, operations: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/operations{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/operations{?cursor,limit,order}', + templated: true }, payments: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/payments{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/payments{?cursor,limit,order}', + templated: true }, effects: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/effects{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/effects{?cursor,limit,order}', + templated: true }, offers: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/offers{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/offers{?cursor,limit,order}', + templated: true }, trades: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/trades{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/trades{?cursor,limit,order}', + templated: true }, data: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/data/{key}", - templated: true, - }, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/data/{key}', + templated: true + } }, - id: "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", + id: 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', account_id: - "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - sequence: "3902600558673934", + 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', + sequence: '3902600558673934', subentry_count: 3, last_modified_ledger: 983682, - last_modified_time: "1970-01-01T00:00:00Z", + last_modified_time: '1970-01-01T00:00:00Z', thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, + auth_clawback_enabled: false }, balances: [ { - balance: "0.0000000", - limit: "25.0000000", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", + balance: '0.0000000', + limit: '25.0000000', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', last_modified_ledger: 983682, is_authorized: true, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", + 'GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' }, { - balance: "9999.9998600", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", - asset_type: "native", - }, + balance: '9999.9998600', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', + asset_type: 'native' + } ], signers: [ { weight: 1, - key: "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - type: "ed25519_public_key", - }, + key: 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', + type: 'ed25519_public_key' + } ], data: {}, paging_token: - "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - }, - ], - }, + 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667' + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'https://horizon-live.stellar.org:1337/accounts?asset=USD%3AGDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .returns(Promise.resolve({ data: accountsForAssetResponse })); @@ -1378,17 +1380,17 @@ describe("Horizon Server non-transaction tests", function () { .accounts() .forAsset( new StellarSdk.Asset( - "USD", - "GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD", - ), + 'USD', + 'GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD' + ) ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForAssetResponse._embedded.records, + accountsForAssetResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1400,127 +1402,127 @@ describe("Horizon Server non-transaction tests", function () { let accountsForSponsor = { _links: { self: { - href: "/accounts?cursor=&limit=10&order=asc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts?cursor=&limit=10&order=asc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, next: { - href: "/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=asc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=asc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, prev: { - href: "/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=desc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - }, + href: '/accounts?cursor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42&limit=10&order=desc&sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' + } }, _embedded: { records: [ { _links: { self: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, transactions: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/transactions{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/transactions{?cursor,limit,order}', + templated: true }, operations: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/operations{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/operations{?cursor,limit,order}', + templated: true }, payments: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/payments{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/payments{?cursor,limit,order}', + templated: true }, effects: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/effects{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/effects{?cursor,limit,order}', + templated: true }, offers: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/offers{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/offers{?cursor,limit,order}', + templated: true }, trades: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/trades{?cursor,limit,order}", - templated: true, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/trades{?cursor,limit,order}', + templated: true }, data: { - href: "/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/data/{key}", - templated: true, - }, + href: '/accounts/GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42/data/{key}', + templated: true + } }, - id: "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + id: 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', account_id: - "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - sequence: "4233832731508737", + 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', + sequence: '4233832731508737', subentry_count: 1, last_modified_ledger: 986912, - last_modified_time: "1970-01-01T00:00:00Z", + last_modified_time: '1970-01-01T00:00:00Z', thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, + auth_clawback_enabled: false }, balances: [ { - balance: "0.0000000", - limit: "450.0000000", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", + balance: '0.0000000', + limit: '450.0000000', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', last_modified_ledger: 986912, is_authorized: true, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GDUEG67IE5TJUVWRRTMXDP3Q6EMMZJ6HL5OMWLBYOIUIZEUW2T2PBPJH", + 'GDUEG67IE5TJUVWRRTMXDP3Q6EMMZJ6HL5OMWLBYOIUIZEUW2T2PBPJH', sponsor: - "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' }, { - balance: "9999.9999900", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", - asset_type: "native", - }, + balance: '9999.9999900', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', + asset_type: 'native' + } ], signers: [ { weight: 1, - key: "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - type: "ed25519_public_key", - }, + key: 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', + type: 'ed25519_public_key' + } ], data: {}, paging_token: - "GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", + 'GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42', num_sponsoring: 0, - num_sponsored: 3, - }, - ], - }, + num_sponsored: 3 + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42", - ), + 'https://horizon-live.stellar.org:1337/accounts?sponsor=GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42' + ) ) .returns(Promise.resolve({ data: accountsForSponsor })); this.server .accounts() - .sponsor("GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42") + .sponsor('GBCR5OVQ54S2EKHLBZMK6VYMTXZHXN3T45Y6PRX4PX4FXDMJJGY4FD42') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForSponsor._embedded.records, + accountsForSponsor._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1532,152 +1534,152 @@ describe("Horizon Server non-transaction tests", function () { const accountsForAssetResponse = { _links: { self: { - href: "/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=&limit=10&order=asc", + href: '/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=&limit=10&order=asc' }, next: { - href: "/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=GC4J73PTB5WN7MOJWOAECPHRCV2UU3WCY37L3BNY6RZVKE23JGQYJMJ6&limit=10&order=asc", + href: '/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=GC4J73PTB5WN7MOJWOAECPHRCV2UU3WCY37L3BNY6RZVKE23JGQYJMJ6&limit=10&order=asc' }, prev: { - href: "/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667&limit=10&order=desc", - }, + href: '/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7&cursor=GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667&limit=10&order=desc' + } }, _embedded: { records: [ { _links: { self: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667' }, transactions: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/transactions{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/transactions{?cursor,limit,order}', + templated: true }, operations: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/operations{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/operations{?cursor,limit,order}', + templated: true }, payments: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/payments{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/payments{?cursor,limit,order}', + templated: true }, effects: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/effects{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/effects{?cursor,limit,order}', + templated: true }, offers: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/offers{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/offers{?cursor,limit,order}', + templated: true }, trades: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/trades{?cursor,limit,order}", - templated: true, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/trades{?cursor,limit,order}', + templated: true }, data: { - href: "/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/data/{key}", - templated: true, - }, + href: '/accounts/GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667/data/{key}', + templated: true + } }, - id: "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", + id: 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', account_id: - "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - sequence: "3902600558673934", + 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', + sequence: '3902600558673934', subentry_count: 3, last_modified_ledger: 983682, - last_modified_time: "1970-01-01T00:00:00Z", + last_modified_time: '1970-01-01T00:00:00Z', thresholds: { low_threshold: 0, med_threshold: 0, - high_threshold: 0, + high_threshold: 0 }, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, + auth_clawback_enabled: false }, balances: [ { liquidity_pool_id: - "dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", - asset_type: "liquidity_pool_shares", - balance: "10", - limit: "10000", + 'dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7', + asset_type: 'liquidity_pool_shares', + balance: '10', + limit: '10000', last_modified_ledger: 7877447, is_authorized: true, is_authorized_to_maintain_liabilities: false, - is_clawback_enabled: false, + is_clawback_enabled: false }, { - balance: "0.0000000", - limit: "922337203685.4775807", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", + balance: '0.0000000', + limit: '922337203685.4775807', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', last_modified_ledger: 983682, is_authorized: true, is_authorized_to_maintain_liabilities: false, is_clawback_enabled: false, - asset_type: "credit_alphanum4", - asset_code: "ARST", + asset_type: 'credit_alphanum4', + asset_code: 'ARST', asset_issuer: - "GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO", + 'GB7TAYRUZGE6TVT7NHP5SMIZRNQA6PLM423EYISAOAP3MKYIQMVYP2JO' }, { - balance: "0.0000000", - limit: "922337203685.4775807", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", + balance: '0.0000000', + limit: '922337203685.4775807', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', last_modified_ledger: 983682, is_authorized: true, is_authorized_to_maintain_liabilities: false, is_clawback_enabled: false, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ", + 'GCEZWKCA5VLDNRLN3RPRJMRZOX3Z6G5CHCGSNFHEYVXM3XOJMDS674JZ' }, { - balance: "9999.9998600", - buying_liabilities: "0.0000000", - selling_liabilities: "0.0000000", - asset_type: "native", - }, + balance: '9999.9998600', + buying_liabilities: '0.0000000', + selling_liabilities: '0.0000000', + asset_type: 'native' + } ], signers: [ { weight: 1, - key: "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - type: "ed25519_public_key", - }, + key: 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667', + type: 'ed25519_public_key' + } ], data: {}, paging_token: - "GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667", - }, - ], - }, + 'GBPFGVESMB7HSTQREV354WA4UDGAPS2NCB5DZQ7K2VZM3PSX4TDCV667' + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", - ), + 'https://horizon-live.stellar.org:1337/accounts?liquidity_pool=dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7' + ) ) .returns(Promise.resolve({ data: accountsForAssetResponse })); this.server .accounts() .forLiquidityPool( - "dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", + 'dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - accountsForAssetResponse._embedded.records, + accountsForAssetResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1686,43 +1688,43 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("OfferCallBuilder", function () { + describe('OfferCallBuilder', function () { const offersResponse = { _embedded: { - records: [], + records: [] }, _links: { next: { - href: "/offers", + href: '/offers' }, prev: { - href: "/offers", + href: '/offers' }, self: { - href: "/offers", - }, - }, + href: '/offers' + } + } }; - it("without params requests the correct endpoint", function (done) { + it('without params requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?order=asc", - ), + 'https://horizon-live.stellar.org:1337/offers?order=asc' + ) ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() - .order("asc") + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records, + offersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1730,52 +1732,52 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("single offer requests the correct endpoint", function (done) { + it('single offer requests the correct endpoint', function (done) { const offerResponse = { _links: { self: { - href: "https://horizon.stellar.org/offers/12345", + href: 'https://horizon.stellar.org/offers/12345' }, offer_maker: { - href: "https://horizon.stellar.org/accounts/GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K", - }, + href: 'https://horizon.stellar.org/accounts/GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K' + } }, id: 12345, - paging_token: "12345", - seller: "GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K", + paging_token: '12345', + seller: 'GCK4WSNF3F6ZNCMK6BU77ZCZ3NMF3JGU2U3ZAPKXYBKYYCJA72FDBY7K', selling: { - asset_type: "credit_alphanum4", - asset_code: "NGNT", + asset_type: 'credit_alphanum4', + asset_code: 'NGNT', asset_issuer: - "GAWODAROMJ33V5YDFY3NPYTHVYQG7MJXVJ2ND3AOGIHYRWINES6ACCPD", + 'GAWODAROMJ33V5YDFY3NPYTHVYQG7MJXVJ2ND3AOGIHYRWINES6ACCPD' }, buying: { - asset_type: "native", + asset_type: 'native' }, - amount: "21611.9486669", + amount: '21611.9486669', price_r: { n: 52836797, - d: 1396841783, + d: 1396841783 }, - price: "0.0378259", + price: '0.0378259', last_modified_ledger: 28285404, - last_modified_time: "2020-02-18T17:00:56Z", + last_modified_time: '2020-02-18T17:00:56Z' }; this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/offers/12345"), + sinon.match('https://horizon-live.stellar.org:1337/offers/12345') ) .returns(Promise.resolve({ data: offerResponse })); this.server .offers() - .offer("12345") + .offer('12345') .call() .then(function (response) { expect(response).to.be.deep.equal(offerResponse); - expect(response.self).to.be.a("function"); + expect(response.self).to.be.a('function'); done(); }) .catch(function (err) { @@ -1783,120 +1785,120 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forAccount requests the correct endpoint", function (done) { + it('forAccount requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers?order=asc", - ), + 'https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/offers?order=asc' + ) ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() .forAccount( - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K' ) - .order("asc") + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records, + offersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { done(err); }); }); - it("selling requests the correct endpoint", function (done) { + it('selling requests the correct endpoint', function (done) { const selling = new StellarSdk.Asset( - "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", + 'USD', + 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' ); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", - ), + 'https://horizon-live.stellar.org:1337/offers?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc' + ) ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() .selling(selling) - .order("asc") + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records, + offersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { done(err); }); }); - it("buying requests the correct endpoint", function (done) { + it('buying requests the correct endpoint', function (done) { const buying = new StellarSdk.Asset( - "COP", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", + 'COP', + 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' ); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?buying_asset_type=credit_alphanum4&buying_asset_code=COP&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", - ), + 'https://horizon-live.stellar.org:1337/offers?buying_asset_type=credit_alphanum4&buying_asset_code=COP&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc' + ) ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() .buying(buying) - .order("asc") + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records, + offersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { done(err); }); }); - it("sponsor requests the correct endpoint", function (done) { + it('sponsor requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/offers?sponsor=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc", - ), + 'https://horizon-live.stellar.org:1337/offers?sponsor=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&order=asc' + ) ) .returns(Promise.resolve({ data: offersResponse })); this.server .offers() - .sponsor("GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG") - .order("asc") + .sponsor('GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG') + .order('asc') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - offersResponse._embedded.records, + offersResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -1905,30 +1907,30 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("OrderbookCallBuilder", function () { + describe('OrderbookCallBuilder', function () { let orderBookResponse = { bids: [], asks: [], base: { - asset_type: "native", - asset_code: "", - asset_issuer: "", + asset_type: 'native', + asset_code: '', + asset_issuer: '' }, counter: { - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", - }, + 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' + } }; - it("requests the correct endpoint native/credit", function (done) { + it('requests the correct endpoint native/credit', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=native&buying_asset_type=credit_alphanum4&buying_asset_code=USD&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", - ), + 'https://horizon-live.stellar.org:1337/order_book?selling_asset_type=native&buying_asset_type=credit_alphanum4&buying_asset_code=USD&buying_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' + ) ) .returns(Promise.resolve({ data: orderBookResponse })); @@ -1936,9 +1938,9 @@ describe("Horizon Server non-transaction tests", function () { .orderbook( StellarSdk.Asset.native(), new StellarSdk.Asset( - "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", - ), + 'USD', + 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' + ) ) .call() .then(function (response) { @@ -1950,23 +1952,23 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("requests the correct endpoint credit/native", function (done) { + it('requests the correct endpoint credit/native', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&buying_asset_type=native", - ), + 'https://horizon-live.stellar.org:1337/order_book?selling_asset_type=credit_alphanum4&selling_asset_code=USD&selling_asset_issuer=GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG&buying_asset_type=native' + ) ) .returns(Promise.resolve({ data: orderBookResponse })); this.server .orderbook( new StellarSdk.Asset( - "USD", - "GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG", + 'USD', + 'GDVDKQFP665JAO7A2LSHNLQIUNYNAAIGJ6FYJVMG4DT3YJQQJSRBLQDG' ), - StellarSdk.Asset.native(), + StellarSdk.Asset.native() ) .call() .then(function (response) { @@ -1979,63 +1981,63 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("TradesCallBuilder", function () { - it("trades() requests the correct endpoint (no filters)", function (done) { + describe('TradesCallBuilder', function () { + it('trades() requests the correct endpoint (no filters)', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&cursor=", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&cursor=64199539053039617-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&cursor=64199539053039617-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&cursor=64199539053039617-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", + href: 'https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W' }, counter: { - href: "https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", + href: 'https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199539053039617", - }, - }, - id: "64199539053039617-0", - paging_token: "64199539053039617-0", - ledger_close_time: "2017-12-07T16:45:19Z", - offer_id: "278232", - trade_type: "orderbook", + href: 'https://horizon-live.stellar.org:1337/operations/64199539053039617' + } + }, + id: '64199539053039617-0', + paging_token: '64199539053039617-0', + ledger_close_time: '2017-12-07T16:45:19Z', + offer_id: '278232', + trade_type: 'orderbook', base_account: - "GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", - base_amount: "1269.2134875", - base_asset_type: "native", + 'GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W', + base_amount: '1269.2134875', + base_asset_type: 'native', counter_account: - "GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", - counter_amount: "19637.5167985", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + 'GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN', + counter_amount: '19637.5167985', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") - .withArgs(sinon.match("https://horizon-live.stellar.org:1337/trades")) + .expects('get') + .withArgs(sinon.match('https://horizon-live.stellar.org:1337/trades')) .returns(Promise.resolve({ data: tradesResponse })); this.server @@ -2043,7 +2045,7 @@ describe("Horizon Server non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2052,65 +2054,65 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for assets", function (done) { + it('trades() requests the correct endpoint for assets', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=asc&limit=10&cursor=", + href: 'https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=asc&limit=10&cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=asc&limit=10&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=asc&limit=10&cursor=64199539053039617-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=desc&limit=10&cursor=64199539053039617-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM&order=desc&limit=10&cursor=64199539053039617-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", + href: 'https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W' }, counter: { - href: "https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", + href: 'https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199539053039617", - }, - }, - id: "64199539053039617-0", - paging_token: "64199539053039617-0", - ledger_close_time: "2017-12-07T16:45:19Z", - offer_id: "278232", - trade_type: "orderbook", + href: 'https://horizon-live.stellar.org:1337/operations/64199539053039617' + } + }, + id: '64199539053039617-0', + paging_token: '64199539053039617-0', + ledger_close_time: '2017-12-07T16:45:19Z', + offer_id: '278232', + trade_type: 'orderbook', base_account: - "GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", - base_amount: "1269.2134875", - base_asset_type: "native", + 'GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W', + base_amount: '1269.2134875', + base_asset_type: 'native', counter_account: - "GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", - counter_amount: "19637.5167985", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + 'GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN', + counter_amount: '19637.5167985', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - ), + 'https://horizon-live.stellar.org:1337/trades?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=JPY&counter_asset_issuer=GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM' + ) ) .returns(Promise.resolve({ data: tradesResponse })); @@ -2119,14 +2121,14 @@ describe("Horizon Server non-transaction tests", function () { .forAssetPair( StellarSdk.Asset.native(), new StellarSdk.Asset( - "JPY", - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", - ), + 'JPY', + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM' + ) ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2135,75 +2137,75 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for offer", function (done) { + it('trades() requests the correct endpoint for offer', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=asc&limit=10&cursor=", + href: 'https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=asc&limit=10&cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=asc&limit=10&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=asc&limit=10&cursor=64199539053039617-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=desc&limit=10&cursor=64199539053039617-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?offer_id=278232&order=desc&limit=10&cursor=64199539053039617-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", + href: 'https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W' }, counter: { - href: "https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", + href: 'https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199539053039617", - }, - }, - id: "64199539053039617-0", - paging_token: "64199539053039617-0", - ledger_close_time: "2017-12-07T16:45:19Z", - offer_id: "278232", - trade_type: "orderbook", + href: 'https://horizon-live.stellar.org:1337/operations/64199539053039617' + } + }, + id: '64199539053039617-0', + paging_token: '64199539053039617-0', + ledger_close_time: '2017-12-07T16:45:19Z', + offer_id: '278232', + trade_type: 'orderbook', base_account: - "GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", - base_amount: "1269.2134875", - base_asset_type: "native", + 'GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W', + base_amount: '1269.2134875', + base_asset_type: 'native', counter_account: - "GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", - counter_amount: "19637.5167985", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + 'GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN', + counter_amount: '19637.5167985', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?offer_id=278232", - ), + 'https://horizon-live.stellar.org:1337/trades?offer_id=278232' + ) ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() - .forOffer("278232") + .forOffer('278232') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2212,72 +2214,72 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for account", function (done) { + it('trades() requests the correct endpoint for account', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=&limit=10&order=asc' }, next: { - href: "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=77434489365606401-1&limit=10&order=asc", + href: 'https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=77434489365606401-1&limit=10&order=asc' }, prev: { - href: "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=77434489365606401-1&limit=10&order=desc", - }, + href: 'https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades?cursor=77434489365606401-1&limit=10&order=desc' + } }, _embedded: { records: [ { _links: { self: { - href: "", + href: '' }, seller: { - href: "https://horizon-live.stellar.org:1337/accounts/GBDTBUKFHJOEAFAVNPGIY65CBIH75DYEZ5VQXOE7YHZM7AJKDNEOW5JG", + href: 'https://horizon-live.stellar.org:1337/accounts/GBDTBUKFHJOEAFAVNPGIY65CBIH75DYEZ5VQXOE7YHZM7AJKDNEOW5JG' }, buyer: { - href: "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY", + href: 'https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/77434489365606401", - }, + href: 'https://horizon-live.stellar.org:1337/operations/77434489365606401' + } }, - id: "77434489365606401-1", - paging_token: "77434489365606401-1", - offer_id: "", - trade_type: "orderbook", + id: '77434489365606401-1', + paging_token: '77434489365606401-1', + offer_id: '', + trade_type: 'orderbook', seller: - "GBDTBUKFHJOEAFAVNPGIY65CBIH75DYEZ5VQXOE7YHZM7AJKDNEOW5JG", - sold_amount: "", - sold_asset_type: "", + 'GBDTBUKFHJOEAFAVNPGIY65CBIH75DYEZ5VQXOE7YHZM7AJKDNEOW5JG', + sold_amount: '', + sold_asset_type: '', buyer: - "GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY", - bought_amount: "", - bought_asset_type: "", - created_at: "2018-05-23T22:42:28Z", - }, - ], - }, + 'GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY', + bought_amount: '', + bought_asset_type: '', + created_at: '2018-05-23T22:42:28Z' + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades", - ), + 'https://horizon-live.stellar.org:1337/accounts/GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY/trades' + ) ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() .forAccount( - "GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY", + 'GABJBA4HI4LVKWAYORE7SOAAZMVXDHI566JBSD25O5TRDM7LVID6YOXY' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2286,80 +2288,80 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for paging", function (done) { + it('trades() requests the correct endpoint for paging', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199676491993090-0", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199676491993090-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?order=desc&limit=1&cursor=64199676491993090-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?order=desc&limit=1&cursor=64199676491993090-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GBBHSWC3XSUFKEFDPQO346BCLM3EAJHICWRVSVIQOG4YBIH3A2VCJ6G2", + href: 'https://horizon-live.stellar.org:1337/accounts/GBBHSWC3XSUFKEFDPQO346BCLM3EAJHICWRVSVIQOG4YBIH3A2VCJ6G2' }, counter: { - href: "https://horizon-live.stellar.org:1337/accounts/GDBXANSAUQ5WBFSA6LFQXR5PYVYAQ3T4KI4LHZ3YAAEFI3BS2Z3SFRVG", + href: 'https://horizon-live.stellar.org:1337/accounts/GDBXANSAUQ5WBFSA6LFQXR5PYVYAQ3T4KI4LHZ3YAAEFI3BS2Z3SFRVG' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199676491993090", - }, - }, - id: "64199676491993090-0", - paging_token: "64199676491993090-0", - ledger_close_time: "2017-12-07T16:47:59Z", - offer_id: "278245", - trade_type: "orderbook", + href: 'https://horizon-live.stellar.org:1337/operations/64199676491993090' + } + }, + id: '64199676491993090-0', + paging_token: '64199676491993090-0', + ledger_close_time: '2017-12-07T16:47:59Z', + offer_id: '278245', + trade_type: 'orderbook', base_account: - "GBBHSWC3XSUFKEFDPQO346BCLM3EAJHICWRVSVIQOG4YBIH3A2VCJ6G2", - base_amount: "0.0000128", - base_asset_type: "credit_alphanum4", - base_asset_code: "BTC", + 'GBBHSWC3XSUFKEFDPQO346BCLM3EAJHICWRVSVIQOG4YBIH3A2VCJ6G2', + base_amount: '0.0000128', + base_asset_type: 'credit_alphanum4', + base_asset_code: 'BTC', base_asset_issuer: - "GBSTRH4QOTWNSVA6E4HFERETX4ZLSR3CIUBLK7AXYII277PFJC4BBYOG", + 'GBSTRH4QOTWNSVA6E4HFERETX4ZLSR3CIUBLK7AXYII277PFJC4BBYOG', counter_account: - "GDBXANSAUQ5WBFSA6LFQXR5PYVYAQ3T4KI4LHZ3YAAEFI3BS2Z3SFRVG", - counter_amount: "0.0005000", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "ETH", + 'GDBXANSAUQ5WBFSA6LFQXR5PYVYAQ3T4KI4LHZ3YAAEFI3BS2Z3SFRVG', + counter_amount: '0.0005000', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'ETH', counter_asset_issuer: - "GBSTRH4QOTWNSVA6E4HFERETX4ZLSR3CIUBLK7AXYII277PFJC4BBYOG", + 'GBSTRH4QOTWNSVA6E4HFERETX4ZLSR3CIUBLK7AXYII277PFJC4BBYOG', base_is_seller: false, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0", - ), + 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=1&cursor=64199539053039617-0' + ) ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() - .order("asc") - .limit("1") - .cursor("64199539053039617-0") + .order('asc') + .limit('1') + .cursor('64199539053039617-0') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2368,75 +2370,75 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for type orderbook", function (done) { + it('trades() requests the correct endpoint for type orderbook', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=orderbook&cursor=", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=orderbook&cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=orderbook&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=orderbook&cursor=64199539053039617-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&trade_type=orderbook&cursor=64199539053039617-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&trade_type=orderbook&cursor=64199539053039617-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", + href: 'https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W' }, counter: { - href: "https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", + href: 'https://horizon-live.stellar.org:1337/accounts/GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199539053039617", - }, - }, - id: "64199539053039617-0", - paging_token: "64199539053039617-0", - ledger_close_time: "2017-12-07T16:45:19Z", - offer_id: "278232", - trade_type: "orderbook", + href: 'https://horizon-live.stellar.org:1337/operations/64199539053039617' + } + }, + id: '64199539053039617-0', + paging_token: '64199539053039617-0', + ledger_close_time: '2017-12-07T16:45:19Z', + offer_id: '278232', + trade_type: 'orderbook', base_account: - "GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", - base_amount: "1269.2134875", - base_asset_type: "native", + 'GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W', + base_amount: '1269.2134875', + base_asset_type: 'native', counter_account: - "GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN", - counter_amount: "19637.5167985", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + 'GC6APVH2HCFB7QLSTG3U55IYSW7ZRNSCTOZZYZJCNHWX2FONCNJNULYN', + counter_amount: '19637.5167985', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?trade_type=orderbook", - ), + 'https://horizon-live.stellar.org:1337/trades?trade_type=orderbook' + ) ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() - .forType("orderbook") + .forType('orderbook') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2445,76 +2447,76 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("trades() requests the correct endpoint for type liquidity_pool", function (done) { + it('trades() requests the correct endpoint for type liquidity_pool', function (done) { let tradesResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=liquidity_pool&cursor=", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=liquidity_pool&cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=liquidity_pool&cursor=64199539053039617-0", + href: 'https://horizon-live.stellar.org:1337/trades?order=asc&limit=200&trade_type=liquidity_pool&cursor=64199539053039617-0' }, prev: { - href: "https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&trade_type=liquidity_pool&cursor=64199539053039617-0", - }, + href: 'https://horizon-live.stellar.org:1337/trades?order=desc&limit=200&trade_type=liquidity_pool&cursor=64199539053039617-0' + } }, _embedded: { records: [ { _links: { base: { - href: "https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", + href: 'https://horizon-live.stellar.org:1337/accounts/GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W' }, counter: { - href: "https://horizon-live.stellar.org:1337/liquidity_pool/dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", + href: 'https://horizon-live.stellar.org:1337/liquidity_pool/dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7' }, operation: { - href: "https://horizon-live.stellar.org:1337/operations/64199539053039617", - }, - }, - id: "64199539053039617-0", - paging_token: "64199539053039617-0", - ledger_close_time: "2017-12-07T16:45:19Z", - offer_id: "4616800602922426369", - trade_type: "liquidity_pool", + href: 'https://horizon-live.stellar.org:1337/operations/64199539053039617' + } + }, + id: '64199539053039617-0', + paging_token: '64199539053039617-0', + ledger_close_time: '2017-12-07T16:45:19Z', + offer_id: '4616800602922426369', + trade_type: 'liquidity_pool', liquidity_pool_fee_bp: 30, base_account: - "GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W", - base_amount: "1269.2134875", - base_asset_type: "native", + 'GB7JKG66CJN3ACX5DX43FOZTTSOI7GZUP547I3BSXIJVUX3NRYUXHE6W', + base_amount: '1269.2134875', + base_asset_type: 'native', counter_liquidity_pool_id: - "dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7", - counter_amount: "19637.5167985", - counter_asset_type: "credit_alphanum4", - counter_asset_code: "JPY", + 'dd7b1ab831c273310ddbec6f97870aa83c2fbd78ce22aded37ecbf4f3380fac7', + counter_amount: '19637.5167985', + counter_asset_type: 'credit_alphanum4', + counter_asset_code: 'JPY', counter_asset_issuer: - "GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM", + 'GBVAOIACNSB7OVUXJYC5UE2D4YK2F7A24T7EE5YOMN4CE6GCHUTOUQXM', base_is_seller: true, price: { - n: "1", - d: "2", - }, - }, - ], - }, + n: '1', + d: '2' + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trades?trade_type=liquidity_pool", - ), + 'https://horizon-live.stellar.org:1337/trades?trade_type=liquidity_pool' + ) ) .returns(Promise.resolve({ data: tradesResponse })); this.server .trades() - .forType("liquidity_pool") + .forType('liquidity_pool') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradesResponse._embedded.records, + tradesResponse._embedded.records ); done(); }) @@ -2524,151 +2526,151 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("StrictReceivePathCallBuilder", function () { + describe('StrictReceivePathCallBuilder', function () { let pathsResponse = { _embedded: { records: [ { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [], - source_amount: "30.0000000", - source_asset_code: "USD", + source_amount: '30.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' }, { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [ { - asset_code: "1", + asset_code: '1', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", - }, + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' + } ], - source_amount: "20.0000000", - source_asset_code: "USD", + source_amount: '20.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' }, { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [ { - asset_code: "21", + asset_code: '21', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' }, { - asset_code: "22", + asset_code: '22', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", - }, + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' + } ], - source_amount: "20.0000000", - source_asset_code: "USD", + source_amount: '20.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", - }, - ], + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' + } + ] }, _links: { self: { - href: "/paths/strict-receive", - }, - }, + href: '/paths/strict-receive' + } + } }; - it("requests the correct endpoint when source is an account", function (done) { + it('requests the correct endpoint when source is an account', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/paths/strict-receive?source_account=GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - ), + 'https://horizon-live.stellar.org:1337/paths/strict-receive?source_account=GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' + ) ) .returns(Promise.resolve({ data: pathsResponse })); this.server .strictReceivePaths( - "GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP", + 'GARSFJNXJIHO6ULUBK3DBYKVSIZE7SC72S5DYBCHU7DKL22UXKVD7MXP', new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), - "20.0", + '20.0' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records, + pathsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { done(err); }); }); - it("requests the correct endpoint when source is a list of assets", function (done) { + it('requests the correct endpoint when source is a list of assets', function (done) { let destinationAssets = encodeURIComponent( - "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - `https://horizon-live.stellar.org:1337/paths/strict-receive?source_assets=${destinationAssets}&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN`, - ), + `https://horizon-live.stellar.org:1337/paths/strict-receive?source_assets=${destinationAssets}&destination_amount=20.0&destination_asset_type=credit_alphanum4&destination_asset_code=EUR&destination_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN` + ) ) .returns(Promise.resolve({ data: pathsResponse })); let assets = [ StellarSdk.Asset.native(), new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), new StellarSdk.Asset( - "USD", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - ), + 'USD', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' + ) ]; this.server .strictReceivePaths( assets, new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), - "20.0", + '20.0' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records, + pathsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -2677,151 +2679,151 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("PathStrictSendCallBuilder", function () { + describe('PathStrictSendCallBuilder', function () { let pathsResponse = { _embedded: { records: [ { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [], - source_amount: "30.0000000", - source_asset_code: "USD", + source_amount: '30.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' }, { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [ { - asset_code: "1", + asset_code: '1', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", - }, + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' + } ], - source_amount: "20.0000000", - source_asset_code: "USD", + source_amount: '20.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' }, { - destination_amount: "20.0000000", - destination_asset_code: "EUR", + destination_amount: '20.0000000', + destination_asset_code: 'EUR', destination_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - destination_asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + destination_asset_type: 'credit_alphanum4', path: [ { - asset_code: "21", + asset_code: '21', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' }, { - asset_code: "22", + asset_code: '22', asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - asset_type: "credit_alphanum4", - }, + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + asset_type: 'credit_alphanum4' + } ], - source_amount: "20.0000000", - source_asset_code: "USD", + source_amount: '20.0000000', + source_asset_code: 'USD', source_asset_issuer: - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - source_asset_type: "credit_alphanum4", - }, - ], + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN', + source_asset_type: 'credit_alphanum4' + } + ] }, _links: { self: { - href: "/paths/strict-send", - }, - }, + href: '/paths/strict-send' + } + } }; - it("requests the correct endpoint when destination is account", function (done) { + it('requests the correct endpoint when destination is account', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_account=GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V", - ), + 'https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_account=GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V' + ) ) .returns(Promise.resolve({ data: pathsResponse })); this.server .strictSendPaths( new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), - "20.0", - "GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V", + '20.0', + 'GAEDTJ4PPEFVW5XV2S7LUXBEHNQMX5Q2GM562RJGOQG7GVCE5H3HIB4V' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records, + pathsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { done(err); }); }); - it("requests the correct endpoint when destination is a list of assets", function (done) { + it('requests the correct endpoint when destination is a list of assets', function (done) { let destinationAssets = encodeURIComponent( - "native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'native,EUR:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN,USD:GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - `https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_assets=${destinationAssets}`, - ), + `https://horizon-live.stellar.org:1337/paths/strict-send?source_asset_type=credit_alphanum4&source_asset_code=EUR&source_asset_issuer=GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN&source_amount=20.0&destination_assets=${destinationAssets}` + ) ) .returns(Promise.resolve({ data: pathsResponse })); let assets = [ StellarSdk.Asset.native(), new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), new StellarSdk.Asset( - "USD", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", - ), + 'USD', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' + ) ]; this.server .strictSendPaths( new StellarSdk.Asset( - "EUR", - "GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN", + 'EUR', + 'GDSBCQO34HWPGUGQSP3QBFEXVTSR2PW46UIGTHVWGWJGQKH3AFNHXHXN' ), - "20.0", - assets, + '20.0', + assets ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - pathsResponse._embedded.records, + pathsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -2830,64 +2832,64 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("EffectCallBuilder", function () { + describe('EffectCallBuilder', function () { let effectsResponse = { _embedded: { records: [ { _links: { operation: { - href: "/operations/146028892161", + href: '/operations/146028892161' }, precedes: { - href: "/effects?cursor=146028892161-1\u0026order=asc", + href: '/effects?cursor=146028892161-1\u0026order=asc' }, succeeds: { - href: "/effects?cursor=146028892161-1\u0026order=desc", - }, + href: '/effects?cursor=146028892161-1\u0026order=desc' + } }, account: - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", - paging_token: "146028892161-1", - starting_balance: "10000000.0", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', + paging_token: '146028892161-1', + starting_balance: '10000000.0', type: 0, - type_s: "account_created", - }, - ], + type_s: 'account_created' + } + ] }, _links: { next: { - href: "/effects?order=asc\u0026limit=1\u0026cursor=146028892161-1", + href: '/effects?order=asc\u0026limit=1\u0026cursor=146028892161-1' }, prev: { - href: "/effects?order=desc\u0026limit=1\u0026cursor=146028892161-1", + href: '/effects?order=desc\u0026limit=1\u0026cursor=146028892161-1' }, self: { - href: "/effects?order=asc\u0026limit=1\u0026cursor=", - }, - }, + href: '/effects?order=asc\u0026limit=1\u0026cursor=' + } + } }; - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/effects?cursor=b", - ), + 'https://horizon-live.stellar.org:1337/effects?cursor=b' + ) ) .returns(Promise.resolve({ data: effectsResponse })); this.server .effects() - .cursor("b") + .cursor('b') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records, + effectsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -2895,28 +2897,28 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forAccount() requests the correct endpoint", function (done) { + it('forAccount() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/effects", - ), + 'https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/effects' + ) ) .returns(Promise.resolve({ data: effectsResponse })); this.server .effects() .forAccount( - "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE", + 'GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records, + effectsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -2924,28 +2926,28 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forTransaction() requests the correct endpoint", function (done) { + it('forTransaction() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae/effects", - ), + 'https://horizon-live.stellar.org:1337/transactions/ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae/effects' + ) ) .returns(Promise.resolve({ data: effectsResponse })); this.server .effects() .forTransaction( - "ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae", + 'ef37d6770c40c3bdb6adba80759f2819971396d1c3dfb7b5611f63ad72a9a4ae' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - effectsResponse._embedded.records, + effectsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -2953,82 +2955,82 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("rejects two filters", function (done) { + it('rejects two filters', function (done) { expect(() => - this.server.effects().forOperation("blah").forLedger("234").call(), + this.server.effects().forOperation('blah').forLedger('234').call() ).to.throw(/Too many filters/); done(); }); }); - describe("OperationCallBuilder", function () { + describe('OperationCallBuilder', function () { let operationsResponse = { _embedded: { records: [ { _links: { effects: { - href: "/operations/146028892161/effects{?cursor,limit,order}", - templated: true, + href: '/operations/146028892161/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "/operations?cursor=146028892161\u0026order=asc", + href: '/operations?cursor=146028892161\u0026order=asc' }, self: { - href: "/operations/146028892161", + href: '/operations/146028892161' }, succeeds: { - href: "/operations?cursor=146028892161\u0026order=desc", + href: '/operations?cursor=146028892161\u0026order=desc' }, transaction: { - href: "/transactions/991534d902063b7715cd74207bef4e7bd7aa2f108f62d3eba837ce6023b2d4f3", - }, + href: '/transactions/991534d902063b7715cd74207bef4e7bd7aa2f108f62d3eba837ce6023b2d4f3' + } }, account: - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', funder: - "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", + 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', id: 146028892161, - paging_token: "146028892161", - starting_balance: "10000000.0", + paging_token: '146028892161', + starting_balance: '10000000.0', type: 0, - type_s: "create_account", - }, - ], + type_s: 'create_account' + } + ] }, _links: { next: { - href: "/operations?order=asc\u0026limit=1\u0026cursor=146028892161", + href: '/operations?order=asc\u0026limit=1\u0026cursor=146028892161' }, prev: { - href: "/operations?order=desc\u0026limit=1\u0026cursor=146028892161", + href: '/operations?order=desc\u0026limit=1\u0026cursor=146028892161' }, self: { - href: "/operations?order=asc\u0026limit=1\u0026cursor=", - }, - }, + href: '/operations?order=asc\u0026limit=1\u0026cursor=' + } + } }; - it("operation() requests the correct endpoint", function (done) { + it('operation() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/operations/123456789", - ), + 'https://horizon-live.stellar.org:1337/operations/123456789' + ) ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() - .operation("123456789") + .operation('123456789') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records, + operationsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3036,28 +3038,28 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forAccount() requests the correct endpoint", function (done) { + it('forAccount() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/operations", - ), + 'https://horizon-live.stellar.org:1337/accounts/GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE/operations' + ) ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() .forAccount( - "GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE", + 'GCGHCFUB6JKQE42C76BK2LYB3EHKP4WQJE624WTSL3CU2PPDYE5RBMJE' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records, + operationsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3065,28 +3067,28 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forClaimableBalance() requests the correct endpoint", function (done) { + it('forClaimableBalance() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/operations", - ), + 'https://horizon-live.stellar.org:1337/claimable_balances/000000000102030000000000000000000000000000000000000000000000000000000000/operations' + ) ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() .forClaimableBalance( - "000000000102030000000000000000000000000000000000000000000000000000000000", + '000000000102030000000000000000000000000000000000000000000000000000000000' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records, + operationsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3094,13 +3096,13 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forLedger() requests the correct endpoint", function (done) { + it('forLedger() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/123456789/operations", - ), + 'https://horizon-live.stellar.org:1337/ledgers/123456789/operations' + ) ) .returns(Promise.resolve({ data: operationsResponse })); @@ -3110,10 +3112,10 @@ describe("Horizon Server non-transaction tests", function () { .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records, + operationsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3121,26 +3123,26 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forTransaction() requests the correct endpoint", function (done) { + it('forTransaction() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/blah/operations", - ), + 'https://horizon-live.stellar.org:1337/transactions/blah/operations' + ) ) .returns(Promise.resolve({ data: operationsResponse })); this.server .operations() - .forTransaction("blah") + .forTransaction('blah') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - operationsResponse._embedded.records, + operationsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3149,76 +3151,76 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("PaymentCallBuilder", function () { + describe('PaymentCallBuilder', function () { let paymentsResponse = { _embedded: { records: [ { _links: { effects: { - href: "/operations/146028892161/effects{?cursor,limit,order}", - templated: true, + href: '/operations/146028892161/effects{?cursor,limit,order}', + templated: true }, precedes: { - href: "/operations?cursor=146028892161\u0026order=asc", + href: '/operations?cursor=146028892161\u0026order=asc' }, self: { - href: "/operations/146028892161", + href: '/operations/146028892161' }, succeeds: { - href: "/operations?cursor=146028892161\u0026order=desc", + href: '/operations?cursor=146028892161\u0026order=desc' }, transaction: { - href: "/transactions/991534d902063b7715cd74207bef4e7bd7aa2f108f62d3eba837ce6023b2d4f3", - }, + href: '/transactions/991534d902063b7715cd74207bef4e7bd7aa2f108f62d3eba837ce6023b2d4f3' + } }, account: - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K', funder: - "GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H", + 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H', id: 146028892161, - paging_token: "146028892161", - starting_balance: "10000000.0", + paging_token: '146028892161', + starting_balance: '10000000.0', type: 0, - type_s: "create_account", - }, - ], + type_s: 'create_account' + } + ] }, _links: { next: { - href: "/payments?order=asc\u0026limit=1\u0026cursor=146028892161", + href: '/payments?order=asc\u0026limit=1\u0026cursor=146028892161' }, prev: { - href: "/payments?order=desc\u0026limit=1\u0026cursor=146028892161", + href: '/payments?order=desc\u0026limit=1\u0026cursor=146028892161' }, self: { - href: "/payments?order=asc\u0026limit=1\u0026cursor=", - }, - }, + href: '/payments?order=asc\u0026limit=1\u0026cursor=' + } + } }; - it("forAccount() requests the correct endpoint", function (done) { + it('forAccount() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/payments", - ), + 'https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/payments' + ) ) .returns(Promise.resolve({ data: paymentsResponse })); this.server .payments() .forAccount( - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records, + paymentsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3226,26 +3228,26 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forLedger() requests the correct endpoint", function (done) { + it('forLedger() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/ledgers/123456789/payments", - ), + 'https://horizon-live.stellar.org:1337/ledgers/123456789/payments' + ) ) .returns(Promise.resolve({ data: paymentsResponse })); this.server .payments() - .forLedger("123456789") + .forLedger('123456789') .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records, + paymentsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3253,28 +3255,28 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("forTransaction() requests the correct endpoint", function (done) { + it('forTransaction() requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/transactions/77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731/payments", - ), + 'https://horizon-live.stellar.org:1337/transactions/77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731/payments' + ) ) .returns(Promise.resolve({ data: paymentsResponse })); this.server .payments() .forTransaction( - "77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731", + '77277606902d80a03a892536ebff8466726a4e55c3923ec2d3eeb3aa5bdc3731' ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - paymentsResponse._embedded.records, + paymentsResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3283,23 +3285,23 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("FriendbotCallBuilder", function () { + describe('FriendbotCallBuilder', function () { let friendbotResponse = { - ledger: 2, + ledger: 2 }; - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/friendbot?addr=GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K", - ), + 'https://horizon-live.stellar.org:1337/friendbot?addr=GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K' + ) ) .returns(Promise.resolve({ data: friendbotResponse })); this.server - .friendbot("GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K") + .friendbot('GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K') .call() .then(function (response) { expect(response.ledger).to.be.equal(friendbotResponse.ledger); @@ -3311,65 +3313,65 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("TradeAggregationCallBuilder", function () { + describe('TradeAggregationCallBuilder', function () { let tradeAggregationResponse = { _links: { self: { - href: "https://horizon.stellar.org/trade_aggregations?base_asset_type=native\u0026counter_asset_type=credit_alphanum4\u0026counter_asset_code=BTC\u0026counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH\u0026start_time=1512689100000\u0026end_time=1512775500000\u0026resolution=300000", + href: 'https://horizon.stellar.org/trade_aggregations?base_asset_type=native\u0026counter_asset_type=credit_alphanum4\u0026counter_asset_code=BTC\u0026counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH\u0026start_time=1512689100000\u0026end_time=1512775500000\u0026resolution=300000' }, next: { - href: "https://horizon.stellar.org/trade_aggregations?base_asset_type=native\u0026counter_asset_code=BTC\u0026counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH\u0026counter_asset_type=credit_alphanum4\u0026end_time=1512775500000\u0026resolution=300000\u0026start_time=1512765000000", + href: 'https://horizon.stellar.org/trade_aggregations?base_asset_type=native\u0026counter_asset_code=BTC\u0026counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH\u0026counter_asset_type=credit_alphanum4\u0026end_time=1512775500000\u0026resolution=300000\u0026start_time=1512765000000' }, prev: { - href: "", - }, + href: '' + } }, _embedded: { records: [ { timestamp: 1512731100000, trade_count: 2, - base_volume: "341.8032786", - counter_volume: "0.0041700", - avg: "0.0000122", - high: "0.0000122", - low: "0.0000122", - open: "0.0000122", - close: "0.0000122", + base_volume: '341.8032786', + counter_volume: '0.0041700', + avg: '0.0000122', + high: '0.0000122', + low: '0.0000122', + open: '0.0000122', + close: '0.0000122' }, { timestamp: 1512732300000, trade_count: 1, - base_volume: "233.6065573", - counter_volume: "0.0028500", - avg: "0.0000122", - high: "0.0000122", - low: "0.0000122", - open: "0.0000122", - close: "0.0000122", + base_volume: '233.6065573', + counter_volume: '0.0028500', + avg: '0.0000122', + high: '0.0000122', + low: '0.0000122', + open: '0.0000122', + close: '0.0000122' }, { timestamp: 1512764700000, trade_count: 1, - base_volume: "451.0000000", - counter_volume: "0.0027962", - avg: "0.0000062", - high: "0.0000062", - low: "0.0000062", - open: "0.0000062", - close: "0.0000062", - }, - ], - }, + base_volume: '451.0000000', + counter_volume: '0.0027962', + avg: '0.0000062', + high: '0.0000062', + low: '0.0000062', + open: '0.0000062', + close: '0.0000062' + } + ] + } }; - it("requests the correct endpoint native/credit", function (done) { + it('requests the correct endpoint native/credit', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=BTC&counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&start_time=1512689100000&end_time=1512775500000&resolution=300000", - ), + 'https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=native&counter_asset_type=credit_alphanum4&counter_asset_code=BTC&counter_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&start_time=1512689100000&end_time=1512775500000&resolution=300000' + ) ) .returns(Promise.resolve({ data: tradeAggregationResponse })); @@ -3377,21 +3379,21 @@ describe("Horizon Server non-transaction tests", function () { .tradeAggregation( StellarSdk.Asset.native(), new StellarSdk.Asset( - "BTC", - "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH", + 'BTC', + 'GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH' ), 1512689100000, 1512775500000, 300000, - 0, + 0 ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradeAggregationResponse._embedded.records, + tradeAggregationResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3399,35 +3401,35 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("requests the correct endpoint credit/native", function (done) { + it('requests the correct endpoint credit/native', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=credit_alphanum4&base_asset_code=BTC&base_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&counter_asset_type=native&start_time=1512689100000&end_time=1512775500000&resolution=300000", - ), + 'https://horizon-live.stellar.org:1337/trade_aggregations?base_asset_type=credit_alphanum4&base_asset_code=BTC&base_asset_issuer=GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH&counter_asset_type=native&start_time=1512689100000&end_time=1512775500000&resolution=300000' + ) ) .returns(Promise.resolve({ data: tradeAggregationResponse })); this.server .tradeAggregation( new StellarSdk.Asset( - "BTC", - "GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH", + 'BTC', + 'GATEMHCCKCY67ZUCKTROYN24ZYT5GK4EQZ65JJLDHKHRUZI3EUEKMTCH' ), StellarSdk.Asset.native(), 1512689100000, 1512775500000, 300000, - 0, + 0 ) .call() .then(function (response) { expect(response.records).to.be.deep.equal( - tradeAggregationResponse._embedded.records, + tradeAggregationResponse._embedded.records ); - expect(response.next).to.be.a("function"); - expect(response.prev).to.be.a("function"); + expect(response.next).to.be.a('function'); + expect(response.prev).to.be.a('function'); done(); }) .catch(function (err) { @@ -3436,75 +3438,75 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("AssetsCallBuilder", function () { - it("requests the correct endpoint", function (done) { + describe('AssetsCallBuilder', function () { + it('requests the correct endpoint', function (done) { let assetsResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=", + href: 'https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=' }, next: { - href: "https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12", + href: 'https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12' }, prev: { - href: "https://horizon-live.stellar.org:1337/assets?order=desc\u0026limit=1\u0026cursor=9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12", - }, + href: 'https://horizon-live.stellar.org:1337/assets?order=desc\u0026limit=1\u0026cursor=9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12' + } }, _embedded: { records: [ { _links: { toml: { - href: "", - }, + href: '' + } }, - asset_type: "credit_alphanum12", - asset_code: "9HORIZONS", + asset_type: 'credit_alphanum12', + asset_code: '9HORIZONS', asset_issuer: - "GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW", + 'GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW', paging_token: - "9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12", + '9HORIZONS_GB2HXY7UEDCSHOWZ4553QFGFILNU73OFS2P4HU5IB3UUU66TWPBPVTGW_credit_alphanum12', accounts: { authorized: 2, authorized_to_maintain_liabilities: 1, - unauthorized: 0, + unauthorized: 0 }, num_claimable_balances: 3, num_contracts: 2, balances: { - authorized: "1000000.0000000", - authorized_to_maintain_liabilities: "500000.0000000", - unauthorized: "0.0000000", + authorized: '1000000.0000000', + authorized_to_maintain_liabilities: '500000.0000000', + unauthorized: '0.0000000' }, - claimable_balances_amount: "0.0000000", - contracts_amount: "1000.0000000", - amount: "1000000.0000000", + claimable_balances_amount: '0.0000000', + contracts_amount: '1000.0000000', + amount: '1000000.0000000', num_accounts: 2, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, - }, - }, - ], - }, + auth_clawback_enabled: false + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( - sinon.match("https://horizon-live.stellar.org:1337/assets?limit=1"), + sinon.match('https://horizon-live.stellar.org:1337/assets?limit=1') ) .returns(Promise.resolve({ data: assetsResponse })); this.server .assets() - .limit("1") + .limit('1') .call() .then(function (response) { expect(response.records).to.be.equal( - assetsResponse._embedded.records, + assetsResponse._embedded.records ); done(); }) @@ -3513,76 +3515,76 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("requests the correct endpoint (asset_code)", function (done) { + it('requests the correct endpoint (asset_code)', function (done) { let assetsCodeResponse = { _links: { self: { - href: "https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=\u0026asset_code=USD", + href: 'https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=\u0026asset_code=USD' }, next: { - href: "https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4\u0026asset_code=USD", + href: 'https://horizon-live.stellar.org:1337/assets?order=asc\u0026limit=1\u0026cursor=USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4\u0026asset_code=USD' }, prev: { - href: "https://horizon-live.stellar.org:1337/assets?order=desc\u0026limit=1\u0026cursor=USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4\u0026asset_code=USD", - }, + href: 'https://horizon-live.stellar.org:1337/assets?order=desc\u0026limit=1\u0026cursor=USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4\u0026asset_code=USD' + } }, _embedded: { records: [ { _links: { toml: { - href: "", - }, + href: '' + } }, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R", + 'GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R', paging_token: - "USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4", + 'USD_GCYK67DDGBOANS6UODJ62QWGLEB2A7JQ3XUV25HCMLT7CI23PMMK3W6R_credit_alphanum4', accounts: { authorized: 127, authorized_to_maintain_liabilities: 64, - unauthorized: 0, + unauthorized: 0 }, num_claimable_balances: 3, num_contracts: 2, balances: { - authorized: "111.0010000", - authorized_to_maintain_liabilities: "55.5005000", - unauthorized: "0.0000000", + authorized: '111.0010000', + authorized_to_maintain_liabilities: '55.5005000', + unauthorized: '0.0000000' }, - claimable_balances_amount: "0.0000000", - contracts_amount: "10000.0000000", - amount: "111.0010000", + claimable_balances_amount: '0.0000000', + contracts_amount: '10000.0000000', + amount: '111.0010000', num_accounts: 127, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, - }, - }, - ], - }, + auth_clawback_enabled: false + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_code=USD&limit=1", - ), + 'https://horizon-live.stellar.org:1337/assets?asset_code=USD&limit=1' + ) ) .returns(Promise.resolve({ data: assetsCodeResponse })); this.server .assets() - .forCode("USD") - .limit("1") + .forCode('USD') + .limit('1') .call() .then(function (response) { expect(response.records).to.be.equal( - assetsCodeResponse._embedded.records, + assetsCodeResponse._embedded.records ); done(); }) @@ -3591,76 +3593,76 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("requests the correct endpoint (asset_issuer)", function (done) { + it('requests the correct endpoint (asset_issuer)', function (done) { let assetIssuerResponse = { _links: { self: { - href: "http://horizon-testnet.stellar.org:1337/assets?order=asc\u0026limit=10\u0026cursor=\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN", + href: 'http://horizon-testnet.stellar.org:1337/assets?order=asc\u0026limit=10\u0026cursor=\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN' }, next: { - href: "http://horizon-testnet.stellar.org:1337/assets?order=asc\u0026limit=10\u0026cursor=00acc1_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN", + href: 'http://horizon-testnet.stellar.org:1337/assets?order=asc\u0026limit=10\u0026cursor=00acc1_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN' }, prev: { - href: "http://horizon-testnet.stellar.org:1337/assets?order=desc\u0026limit=10\u0026cursor=004d40_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN", - }, + href: 'http://horizon-testnet.stellar.org:1337/assets?order=desc\u0026limit=10\u0026cursor=004d40_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12\u0026asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN' + } }, _embedded: { records: [ { _links: { toml: { - href: "", - }, + href: '' + } }, - asset_type: "credit_alphanum12", - asset_code: "004d40", + asset_type: 'credit_alphanum12', + asset_code: '004d40', asset_issuer: - "GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN", + 'GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN', paging_token: - "004d40_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12", + '004d40_GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN_credit_alphanum12', accounts: { authorized: 18, authorized_to_maintain_liabilities: 9, - unauthorized: 0, + unauthorized: 0 }, num_claimable_balances: 3, num_contracts: 2, balances: { - authorized: "757.0000000", - authorized_to_maintain_liabilities: "378.5000000", - unauthorized: "0.0000000", + authorized: '757.0000000', + authorized_to_maintain_liabilities: '378.5000000', + unauthorized: '0.0000000' }, - claimable_balances_amount: "0.0000000", - contracts_amount: "10000.0000000", - amount: "757.0000000", + claimable_balances_amount: '0.0000000', + contracts_amount: '10000.0000000', + amount: '757.0000000', num_accounts: 18, flags: { auth_required: false, auth_revocable: false, auth_immutable: false, - auth_clawback_enabled: false, - }, - }, - ], - }, + auth_clawback_enabled: false + } + } + ] + } }; this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN&limit=1", - ), + 'https://horizon-live.stellar.org:1337/assets?asset_issuer=GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN&limit=1' + ) ) .returns(Promise.resolve({ data: assetIssuerResponse })); this.server .assets() - .forIssuer("GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN") - .limit("1") + .forIssuer('GCOGPF7IRVXUCJZAQWXVFQEE4HAOCTDGZI2QZSMKLM5BTTGRLY6GDOJN') + .limit('1') .call() .then(function (response) { expect(response.records).to.be.equal( - assetIssuerResponse._embedded.records, + assetIssuerResponse._embedded.records ); done(); }) @@ -3672,73 +3674,73 @@ describe("Horizon Server non-transaction tests", function () { let assetCodeIssuerResponse = { _links: { self: { - href: "http://horizon-testnet.stellar.org/assets?order=asc\u0026limit=10\u0026cursor=\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", + href: 'http://horizon-testnet.stellar.org/assets?order=asc\u0026limit=10\u0026cursor=\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR' }, next: { - href: "http://horizon-testnet.stellar.org/assets?order=asc\u0026limit=10\u0026cursor=USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", + href: 'http://horizon-testnet.stellar.org/assets?order=asc\u0026limit=10\u0026cursor=USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR' }, prev: { - href: "http://horizon-testnet.stellar.org/assets?order=desc\u0026limit=10\u0026cursor=USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", - }, + href: 'http://horizon-testnet.stellar.org/assets?order=desc\u0026limit=10\u0026cursor=USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4\u0026asset_code=USD\u0026asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR' + } }, _embedded: { records: [ { _links: { toml: { - href: "https://bakalr/.well-known/stellar.toml", - }, + href: 'https://bakalr/.well-known/stellar.toml' + } }, - asset_type: "credit_alphanum4", - asset_code: "USD", + asset_type: 'credit_alphanum4', + asset_code: 'USD', asset_issuer: - "GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", + 'GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR', paging_token: - "USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4", + 'USD_GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR_credit_alphanum4', accounts: { authorized: 1, authorized_to_maintain_liabilities: 0, - unauthorized: 0, + unauthorized: 0 }, num_claimable_balances: 0, num_contracts: 2, balances: { - authorized: "1387.0000000", - authorized_to_maintain_liabilities: "0.0000000", - unauthorized: "0.0000000", + authorized: '1387.0000000', + authorized_to_maintain_liabilities: '0.0000000', + unauthorized: '0.0000000' }, - claimable_balances_amount: "0.0000000", - contracts_amount: "10000.0000000", - amount: "1387.0000000", + claimable_balances_amount: '0.0000000', + contracts_amount: '10000.0000000', + amount: '1387.0000000', num_accounts: 1, flags: { auth_required: true, auth_revocable: true, auth_immutable: false, - auth_clawback_enabled: false, - }, - }, - ], - }, + auth_clawback_enabled: false + } + } + ] + } }; - it("requests the correct endpoint (asset_code then asset_issuer)", function (done) { + it('requests the correct endpoint (asset_code then asset_issuer)', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR&asset_code=USD", - ), + 'https://horizon-live.stellar.org:1337/assets?asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR&asset_code=USD' + ) ) .returns(Promise.resolve({ data: assetCodeIssuerResponse })); this.server .assets() - .forIssuer("GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR") - .forCode("USD") + .forIssuer('GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR') + .forCode('USD') .call() .then(function (response) { expect(response.records).to.be.equal( - assetCodeIssuerResponse._embedded.records, + assetCodeIssuerResponse._embedded.records ); done(); }) @@ -3747,24 +3749,24 @@ describe("Horizon Server non-transaction tests", function () { }); }); - it("requests the correct endpoint (asset_issuer then asset_code)", function (done) { + it('requests the correct endpoint (asset_issuer then asset_code)', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/assets?asset_code=USD&asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR", - ), + 'https://horizon-live.stellar.org:1337/assets?asset_code=USD&asset_issuer=GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR' + ) ) .returns(Promise.resolve({ data: assetCodeIssuerResponse })); this.server .assets() - .forCode("USD") - .forIssuer("GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR") + .forCode('USD') + .forIssuer('GBW3EZBZKRERB4JUDWGQPIBGHKJ4XPOFG2VQ2WTFR4F7TYC5WS7F3XGR') .call() .then(function (response) { expect(response.records).to.be.equal( - assetCodeIssuerResponse._embedded.records, + assetCodeIssuerResponse._embedded.records ); done(); }) @@ -3774,21 +3776,21 @@ describe("Horizon Server non-transaction tests", function () { }); }); - describe("Regressions", function () { - it("offers callBuilder does not pollute Server instance URI #379", function (done) { + describe('Regressions', function () { + it('offers callBuilder does not pollute Server instance URI #379', function (done) { this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects", - ), + 'https://horizon-live.stellar.org:1337/accounts/GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K/effects' + ) ) .returns(Promise.resolve({ data: {} })); const account = - "GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K"; + 'GBS43BF24ENNS3KPACUZVKK2VYPOZVBQO2CISGZ777RYGOPYC2FT6S3K'; - const offerCallBuilder = this.server.offers("accounts", account); + const offerCallBuilder = this.server.offers('accounts', account); const effectCallBuilder = this.server .effects() .forAccount(account) diff --git a/test/unit/horizon/server_transaction_test.js b/test/unit/horizon/server_transaction_test.js index be142b145..119986704 100644 --- a/test/unit/horizon/server_transaction_test.js +++ b/test/unit/horizon/server_transaction_test.js @@ -1,24 +1,24 @@ -describe("server.js transaction tests", function () { +describe('server.js transaction tests', function () { let keypair = StellarSdk.Keypair.random(); - let account = new StellarSdk.Account(keypair.publicKey(), "56199647068161"); + let account = new StellarSdk.Account(keypair.publicKey(), '56199647068161'); beforeEach(function () { this.server = new StellarSdk.Server( - "https://horizon-live.stellar.org:1337", + 'https://horizon-live.stellar.org:1337' ); this.axiosMock = sinon.mock(AxiosClient); let transaction = new StellarSdk.TransactionBuilder(account, { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET, - v1: true, + v1: true }) .addOperation( StellarSdk.Operation.payment({ destination: - "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + 'GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW', asset: StellarSdk.Asset.native(), - amount: "100.50", - }), + amount: '100.50' + }) ) .setTimeout(StellarSdk.TimeoutInfinite) .build(); @@ -26,7 +26,7 @@ describe("server.js transaction tests", function () { this.transaction = transaction; this.blob = encodeURIComponent( - transaction.toEnvelope().toXDR().toString("base64"), + transaction.toEnvelope().toXDR().toString('base64') ); }); @@ -35,12 +35,12 @@ describe("server.js transaction tests", function () { this.axiosMock.restore(); }); - it("sends a transaction", function (done) { + it('sends a transaction', function (done) { this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: {} })); @@ -53,27 +53,27 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("adds metadata - tx was too small and was immediately deleted", function (done) { + it('adds metadata - tx was too small and was immediately deleted', function (done) { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/db2c69a07be57eb5baefbfbb72b95c7c20d2c4d6f2a0e84e7c27dd0359055a2f", - }, + href: 'https://horizon.stellar.org/transactions/db2c69a07be57eb5baefbfbb72b95c7c20d2c4d6f2a0e84e7c27dd0359055a2f' + } }, - hash: "db2c69a07be57eb5baefbfbb72b95c7c20d2c4d6f2a0e84e7c27dd0359055a2f", + hash: 'db2c69a07be57eb5baefbfbb72b95c7c20d2c4d6f2a0e84e7c27dd0359055a2f', ledger: 22895637, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAjAAAAAQAAAAAAAAAAAAAAAFyIDdQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAAAAAAEAAAACAAAAAwAAAAAAAAAAAAAAAAAAAAFPQUH/AAAAQOJlnAnmSv1igsU/LjpXvuCqS/EcnM7oxgyk4ElnCwOz9YUEcvhXuc9GS2Sz1fMxsWvV9dHhmu3HvBrsphVl5A8=", - result_xdr: "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAAAAAACAAAAAA==", + 'AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAjAAAAAQAAAAAAAAAAAAAAAFyIDdQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAAAAAAEAAAACAAAAAwAAAAAAAAAAAAAAAAAAAAFPQUH/AAAAQOJlnAnmSv1igsU/LjpXvuCqS/EcnM7oxgyk4ElnCwOz9YUEcvhXuc9GS2Sz1fMxsWvV9dHhmu3HvBrsphVl5A8=', + result_xdr: 'AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAAAAAACAAAAAA==', result_meta_xdr: - "AAAAAQAAAAIAAAADAV1cFQAAAAAAAAAAhQARbeNC3f59tPqcIBIDX/xFZ2n18nbCjGo8dk9BQf8AAAACU4RoUgEH/OgAAAAiAAAABQAAAAEAAAAAhD8BLsZFQEF33rKS6YopQUT3b6iLBG4nspe68/DBNBYAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBXVwVAAAAAAAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAJThGhSAQf86AAAACMAAAAFAAAAAQAAAACEPwEuxkVAQXfespLpiilBRPdvqIsEbieyl7rz8ME0FgAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAA=", + 'AAAAAQAAAAIAAAADAV1cFQAAAAAAAAAAhQARbeNC3f59tPqcIBIDX/xFZ2n18nbCjGo8dk9BQf8AAAACU4RoUgEH/OgAAAAiAAAABQAAAAEAAAAAhD8BLsZFQEF33rKS6YopQUT3b6iLBG4nspe68/DBNBYAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBXVwVAAAAAAAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAJThGhSAQf86AAAACMAAAAFAAAAAQAAAACEPwEuxkVAQXfespLpiilBRPdvqIsEbieyl7rz8ME0FgAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAA=' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -82,14 +82,14 @@ describe("server.js transaction tests", function () { .then(function (res) { expect(res.offerResults).to.be.an.instanceOf(Array); expect(res.offerResults[0].offersClaimed).to.be.an.instanceOf(Array); - expect(typeof res.offerResults[0].effect).to.equal("string"); + expect(typeof res.offerResults[0].effect).to.equal('string'); expect(res.offerResults[0].wasImmediatelyFilled).to.equal(false); expect(res.offerResults[0].wasImmediatelyDeleted).to.equal(true); expect(res.offerResults[0].wasPartiallyFilled).to.equal(false); expect(res.offerResults[0].operationIndex).to.equal(0); - expect(res.offerResults[0].amountBought).to.equal("0"); - expect(res.offerResults[0].amountSold).to.equal("0"); + expect(res.offerResults[0].amountBought).to.equal('0'); + expect(res.offerResults[0].amountSold).to.equal('0'); expect(res.offerResults[0].currentOffer).to.equal(undefined); done(); @@ -98,28 +98,28 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("adds metadata, order immediately fills", function (done) { + it('adds metadata, order immediately fills', function (done) { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/d88ded94c558790f7e819b85fd35adb10a1e474312c34ebd611495c349a8eb69", - }, + href: 'https://horizon.stellar.org/transactions/d88ded94c558790f7e819b85fd35adb10a1e474312c34ebd611495c349a8eb69' + } }, - hash: "d88ded94c558790f7e819b85fd35adb10a1e474312c34ebd611495c349a8eb69", + hash: 'd88ded94c558790f7e819b85fd35adb10a1e474312c34ebd611495c349a8eb69', ledger: 22895558, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAgAAAAAQAAAAAAAAAAAAAAAFyIDD0AAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAAExLQAAAAABAAAAAgAAAAAAAAAAAAAAAAAAAAFPQUH/AAAAQHk3Igj+JXqggsJBFl4mrzgACqxWpx87psxu5UHnSskbwRjHZz89NycCZmJL4gN5WN7twm+wK371K9XcRNDiBwQ=", + 'AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAgAAAAAQAAAAAAAAAAAAAAAFyIDD0AAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWY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AAAEAAAAAPEGtxQtQD1UZU+mY3N5z5KtzKggiZYzimTMfGsnpHKQAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAALaNFPKAAAADouVkLYAAAAAAAAAAAAAAAMBXVmCAAAAAQAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAAAAAAB//////////wAAAAEAAAAAAAAAAAAAAAEBXVvGAAAAAQAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAACj1/l//////////wAAAAEAAAAAAAAAAAAAAAMBXVvGAAAAAAAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAJUtZZ9AQf86AAAACAAAAAFAAAAAQAAAACEPwEuxkVAQXfespLpiilBRPdvqIsEbieyl7rz8ME0FgAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQFdW8YAAAAAAAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAAlOEaX4BB/zoAAAAIAAAAAUAAAABAAAAAIQ/AS7GRUBBd96ykumKKUFE92+oiwRuJ7KXuvPwwTQWAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -128,13 +128,13 @@ describe("server.js transaction tests", function () { .then(function (res) { expect(res.offerResults).to.be.an.instanceOf(Array); expect(res.offerResults[0].offersClaimed).to.be.an.instanceOf(Array); - expect(typeof res.offerResults[0].effect).to.equal("string"); + expect(typeof res.offerResults[0].effect).to.equal('string'); expect(res.offerResults[0].wasImmediatelyFilled).to.equal(true); expect(res.offerResults[0].wasImmediatelyDeleted).to.equal(false); expect(res.offerResults[0].wasPartiallyFilled).to.equal(false); expect(res.offerResults[0].operationIndex).to.equal(0); - expect(res.offerResults[0].amountSold).to.equal("1.9999999"); + expect(res.offerResults[0].amountSold).to.equal('1.9999999'); done(); }) @@ -142,28 +142,28 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("adds metadata, order is open", function (done) { + it('adds metadata, order is open', function (done) { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/e1c2b91141d8c4185dc8c18118f345a269d88c476bdadec695c1b3ecdc999831", - }, + href: 'https://horizon.stellar.org/transactions/e1c2b91141d8c4185dc8c18118f345a269d88c476bdadec695c1b3ecdc999831' + } }, - hash: "e1c2b91141d8c4185dc8c18118f345a269d88c476bdadec695c1b3ecdc999831", + hash: 'e1c2b91141d8c4185dc8c18118f345a269d88c476bdadec695c1b3ecdc999831', ledger: 22896129, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAkAAAAAQAAAAAAAAAAAAAAAFyIF70AAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAACYloAAAAABAAAAAQAAAAAAAAAAAAAAAAAAAAFPQUH/AAAAQJYfX7d9Cp609ChIRR5ONhCkSM2a1YLmi21rNLjcw5XFZg5R6Y3ZQ6kwVyJBcgqMwpH9F+NgoybKpepIIaXJiQs=", + 'AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAkAAAAAQAAAAAAAAAAAAAAAFyIF70AAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo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wAAAAAEZqfGAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAAACYloAAAAABAAAAAQAAAAAAAAAAAAAAAA==' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -172,9 +172,9 @@ describe("server.js transaction tests", function () { .then(function (res) { expect(res.offerResults).to.be.an.instanceOf(Array); expect(res.offerResults[0].offersClaimed).to.be.an.instanceOf(Array); - expect(typeof res.offerResults[0].effect).to.equal("string"); + expect(typeof res.offerResults[0].effect).to.equal('string'); expect(res.offerResults[0].wasImmediatelyFilled).to.equal(false); - expect(res.offerResults[0].amountBought).to.equal("0"); + expect(res.offerResults[0].amountBought).to.equal('0'); expect(res.offerResults[0].wasImmediatelyDeleted).to.equal(false); expect(res.offerResults[0].wasPartiallyFilled).to.equal(false); expect(res.offerResults[0].isFullyOpen).to.equal(true); @@ -186,28 +186,28 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("adds metadata, partial fill", function (done) { + it('adds metadata, partial fill', function (done) { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/28552ba6a70ab74f6de05319950e2ddad94491159ebc97b14cfcde2d3c7e70a1", - }, + href: 'https://horizon.stellar.org/transactions/28552ba6a70ab74f6de05319950e2ddad94491159ebc97b14cfcde2d3c7e70a1' + } }, - hash: "28552ba6a70ab74f6de05319950e2ddad94491159ebc97b14cfcde2d3c7e70a1", + hash: '28552ba6a70ab74f6de05319950e2ddad94491159ebc97b14cfcde2d3c7e70a1', ledger: 22896525, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAlAAAAAQAAAAAAAAAAAAAAAFyIH7sAAAAAAAAAAQAAAAAAAAADAAAAAAAAAAFCQVQ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Iv23wBMS0AAAAAAAAAAAAAAAAAAAAACAAAAAgAAAAB1m3A/FStIp4ybPiuwbAqUFZdVE0htPHeAmDCu9diR/AAAAAAEZsDDAAAAAwFdX4IAAAABAAAAAHWbcD8VK0injJs+K7BsCpQVl1UTSG08d4CYMK712JH8AAAAAUJBVAAAAAAARkrT28ebM6YQyhVZi1ttlwq/dk6ijTpyTNuHIMgUp+EAAAABgQWCFn//////////AAAAAQAAAAEAAAAIIq08AgAAAAGBBYIVAAAAAAAAAAAAAAABAV1fjQAAAAEAAAAAdZtwPxUrSKeMmz4rsGwKlBWXVRNIbTx3gJgwrvXYkfwAAAABQkFUAAAAAABGStPbx5szphDKFVmLW22XCr92TqKNOnJM24cgyBSn4QAAAAFg77c/f/////////8AAAABAAAAAQAAAAgirTwCAAAAAWDvtz4AAAAAAAAAAAAAAAABXV+NAAAAAgAAAACFABFt40Ld/n20+pwgEgNf/EVnafXydsKMajx2T0FB/wAAAAAEZsEvAAAAAAAAAAFCQVQAAAAAAEZK09vHmzOmEMoVWYtbbZcKv3ZOoo06ckzbhyDIFKfhAAAAADJ8VSAATEtAAIv23wAAAAAAAAAAAAAAAA==' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -217,22 +217,22 @@ describe("server.js transaction tests", function () { expect(res.offerResults).to.be.an.instanceOf(Array); expect(res.offerResults[0].offersClaimed).to.be.an.instanceOf(Array); expect(res.offerResults[0].offersClaimed).to.have.lengthOf(1); - expect(res.offerResults[0].effect).to.equal("manageOfferCreated"); - expect(typeof res.offerResults[0].effect).to.equal("string"); + expect(res.offerResults[0].effect).to.equal('manageOfferCreated'); + expect(typeof res.offerResults[0].effect).to.equal('string'); expect(res.offerResults[0].wasImmediatelyFilled).to.equal(false); - expect(res.offerResults[0].amountBought).to.equal("53.8299095"); + expect(res.offerResults[0].amountBought).to.equal('53.8299095'); expect(res.offerResults[0].wasImmediatelyDeleted).to.equal(false); expect(res.offerResults[0].wasPartiallyFilled).to.equal(true); expect(res.offerResults[0].isFullyOpen).to.equal(false); expect(res.offerResults[0].operationIndex).to.equal(0); expect(res.offerResults[0].currentOffer.selling.type).to.equal( - "native", + 'native' ); expect(res.offerResults[0].currentOffer.buying.assetCode).to.equal( - "BAT", + 'BAT' ); expect(res.offerResults[0].currentOffer.buying.issuer).to.equal( - "GBDEVU63Y6NTHJQQZIKVTC23NWLQVP3WJ2RI2OTSJTNYOIGICST6DUXR", + 'GBDEVU63Y6NTHJQQZIKVTC23NWLQVP3WJ2RI2OTSJTNYOIGICST6DUXR' ); done(); @@ -245,23 +245,23 @@ describe("server.js transaction tests", function () { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/6c3191f252f2c586c74275c766ce761021513e520eab3bb63d3fd18d0d01492e", - }, + href: 'https://horizon.stellar.org/transactions/6c3191f252f2c586c74275c766ce761021513e520eab3bb63d3fd18d0d01492e' + } }, - hash: "6c3191f252f2c586c74275c766ce761021513e520eab3bb63d3fd18d0d01492e", + hash: '6c3191f252f2c586c74275c766ce761021513e520eab3bb63d3fd18d0d01492e', ledger: 22893969, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAZAEH/OgAAAAeAAAAAQAAAAAAAAAAAAAAAFyH7EoAAAAAAAAAAQAAAAAAAAAGAAAAAUJUQwAAAAAAKTpjGpnWX8jImMrLprg+1nHJhiAVINNe+zSvg3bvNiUAAAAAAAAAAAAAAAAAAAABT0FB/wAAAEBDRFjJITX4LIIY2tc8KxVU3Pe7dqZ+BkWft93SCVlEXxiCHnoNop5UEKRoRTvAUh34I6As4IN/QpGGqHmbKv8F", - result_xdr: "AAAAAAAAAGQAAAAAAAAAAQAAAAAAAAAGAAAAAAAAAAA=", + 'AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2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t3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAAAAlS1mHEBB/zoAAAAHgAAAAYAAAABAAAAAIQ/AS7GRUBBd96ykumKKUFE92+oiwRuJ7KXuvPwwTQWAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAV1VkQAAAAAAAAAAhQARbeNC3f59tPqcIBIDX/xFZ2n18nbCjGo8dk9BQf8AAAACVLWYcQEH/OgAAAAeAAAABQAAAAEAAAAAhD8BLsZFQEF33rKS6YopQUT3b6iLBG4nspe68/DBNBYAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -275,28 +275,28 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("adds metadata about offers, even if some ops are not", function (done) { + it('adds metadata about offers, even if some ops are not', function (done) { const response = { _links: { transaction: { - href: "https://horizon.stellar.org/transactions/6a22d6896140f6f330ef19086827df0780eb2ad3324f3271b38c70cb1cba1c3d", - }, + href: 'https://horizon.stellar.org/transactions/6a22d6896140f6f330ef19086827df0780eb2ad3324f3271b38c70cb1cba1c3d' + } }, - hash: "6a22d6896140f6f330ef19086827df0780eb2ad3324f3271b38c70cb1cba1c3d", + hash: '6a22d6896140f6f330ef19086827df0780eb2ad3324f3271b38c70cb1cba1c3d', ledger: 22894978, envelope_xdr: - "AAAAAIUAEW3jQt3+fbT6nCASA1/8RWdp9fJ2woxqPHZPQUH/AAABkAEH/OgAAAAfAAAAAQAAAAAAAAAAAAAAAFyIAGgAAAAAAAAABAAAAAAAAAAGAAAAAUJBVAAAAAAARkrT28ebM6YQyhVZi1ttlwq/dk6ijTpyTNuHIMgUp+F//////////wAAAAAAAAAFAAAAAQ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AAAHwAAAAUAAAABAAAAAIQ/AS7GRUBBd96ykumKKUFE92+oiwRuJ7KXuvPwwTQWAAAAAAAAAAABAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAV1ZggAAAAAAAAAAhQARbeNC3f59tPqcIBIDX/xFZ2n18nbCjGo8dk9BQf8AAAACVLWW4QEH/OgAAAAfAAAABQAAAAEAAAAAhD8BLsZFQEF33rKS6YopQUT3b6iLBG4nspe68/DBNBYAAAAAAAAAAAEAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' }; this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: response })); @@ -306,10 +306,10 @@ describe("server.js transaction tests", function () { expect(res.offerResults).to.be.an.instanceOf(Array); expect(res.offerResults).to.have.lengthOf(2); expect(res.offerResults[0].offersClaimed).to.be.an.instanceOf(Array); - expect(typeof res.offerResults[0].effect).to.equal("string"); + expect(typeof res.offerResults[0].effect).to.equal('string'); expect(res.offerResults[0].operationIndex).to.equal(2); expect(res.offerResults[1].offersClaimed).to.be.an.instanceOf(Array); - expect(typeof res.offerResults[1].effect).to.equal("string"); + expect(typeof res.offerResults[1].effect).to.equal('string'); expect(res.offerResults[1].operationIndex).to.equal(3); done(); }) @@ -317,25 +317,25 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("checks for memo required by default", function (done) { + it('checks for memo required by default', function (done) { this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: {} })); this.axiosMock - .expects("get") + .expects('get') .withArgs( sinon.match( - "https://horizon-live.stellar.org:1337/accounts/GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", - ), + 'https://horizon-live.stellar.org:1337/accounts/GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW' + ) ) .returns( Promise.reject({ - response: { status: 404, statusText: "NotFound", data: {} }, - }), + response: { status: 404, statusText: 'NotFound', data: {} } + }) ) .once(); @@ -348,23 +348,23 @@ describe("server.js transaction tests", function () { done(err); }); }); - it("submits fee bump transactions", function (done) { + it('submits fee bump transactions', function (done) { const feeBumpTx = StellarSdk.TransactionBuilder.buildFeeBumpTransaction( keypair, - "200", + '200', this.transaction, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); this.blob = encodeURIComponent( - feeBumpTx.toEnvelope().toXDR().toString("base64"), + feeBumpTx.toEnvelope().toXDR().toString('base64') ); this.axiosMock - .expects("post") + .expects('post') .withArgs( - "https://horizon-live.stellar.org:1337/transactions", - `tx=${this.blob}`, + 'https://horizon-live.stellar.org:1337/transactions', + `tx=${this.blob}` ) .returns(Promise.resolve({ data: {} })); diff --git a/test/unit/horizon/stellar_toml_resolver_test.js b/test/unit/horizon/stellar_toml_resolver_test.js index cd932490a..024aae33c 100644 --- a/test/unit/horizon/stellar_toml_resolver_test.js +++ b/test/unit/horizon/stellar_toml_resolver_test.js @@ -1,6 +1,6 @@ -const http = require("http"); +const http = require('http'); -describe("stellar_toml_resolver.js tests", function () { +describe('stellar_toml_resolver.js tests', function () { beforeEach(function () { this.axiosMock = sinon.mock(axios); StellarSdk.Config.setDefault(); @@ -11,139 +11,139 @@ describe("stellar_toml_resolver.js tests", function () { this.axiosMock.restore(); }); - describe("StellarTomlResolver.resolve", function () { + describe('StellarTomlResolver.resolve', function () { afterEach(function () { StellarSdk.Config.setDefault(); }); - it("returns stellar.toml object for valid request and stellar.toml file", function (done) { + it('returns stellar.toml object for valid request and stellar.toml file', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` # The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" -`, - }), +` + }) ); - StellarSdk.StellarTomlResolver.resolve("acme.com").then((stellarToml) => { + StellarSdk.StellarTomlResolver.resolve('acme.com').then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "https://api.stellar.org/federation", + 'https://api.stellar.org/federation' ); done(); }); }); - it("returns stellar.toml object for valid request and stellar.toml file when allowHttp is `true`", function (done) { + it('returns stellar.toml object for valid request and stellar.toml file when allowHttp is `true`', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("http://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('http://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` # The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="http://api.stellar.org/federation" -`, - }), +` + }) ); - StellarSdk.StellarTomlResolver.resolve("acme.com", { - allowHttp: true, + StellarSdk.StellarTomlResolver.resolve('acme.com', { + allowHttp: true }).then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "http://api.stellar.org/federation", + 'http://api.stellar.org/federation' ); done(); }); }); - it("returns stellar.toml object for valid request and stellar.toml file when global Config.allowHttp flag is set", function (done) { + it('returns stellar.toml object for valid request and stellar.toml file when global Config.allowHttp flag is set', function (done) { StellarSdk.Config.setAllowHttp(true); this.axiosMock - .expects("get") - .withArgs(sinon.match("http://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('http://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` # The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="http://api.stellar.org/federation" -`, - }), +` + }) ); - StellarSdk.StellarTomlResolver.resolve("acme.com").then((stellarToml) => { + StellarSdk.StellarTomlResolver.resolve('acme.com').then((stellarToml) => { expect(stellarToml.FEDERATION_SERVER).equals( - "http://api.stellar.org/federation", + 'http://api.stellar.org/federation' ); done(); }); }); - it("rejects when stellar.toml file is invalid", function (done) { + it('rejects when stellar.toml file is invalid', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://acme.com/.well-known/stellar.toml')) .returns( Promise.resolve({ data: ` /# The endpoint which clients should query to resolve stellar addresses # for users on your domain. FEDERATION_SERVER="https://api.stellar.org/federation" -`, - }), +` + }) ); - StellarSdk.StellarTomlResolver.resolve("acme.com") + StellarSdk.StellarTomlResolver.resolve('acme.com') .should.be.rejectedWith(/Parsing error on line/) .and.notify(done); }); - it("rejects when there was a connection error", function (done) { + it('rejects when there was a connection error', function (done) { this.axiosMock - .expects("get") - .withArgs(sinon.match("https://acme.com/.well-known/stellar.toml")) + .expects('get') + .withArgs(sinon.match('https://acme.com/.well-known/stellar.toml')) .returns(Promise.reject()); StellarSdk.StellarTomlResolver.resolve( - "acme.com", + 'acme.com' ).should.be.rejected.and.notify(done); }); - it("fails when response exceeds the limit", function (done) { + it('fails when response exceeds the limit', function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } - var response = Array(StellarSdk.STELLAR_TOML_MAX_SIZE + 10).join("a"); + var response = Array(StellarSdk.STELLAR_TOML_MAX_SIZE + 10).join('a'); let tempServer = http .createServer((req, res) => { - res.setHeader("Content-Type", "text/x-toml; charset=UTF-8"); + res.setHeader('Content-Type', 'text/x-toml; charset=UTF-8'); res.end(response); }) .listen(4444, () => { - StellarSdk.StellarTomlResolver.resolve("localhost:4444", { - allowHttp: true, + StellarSdk.StellarTomlResolver.resolve('localhost:4444', { + allowHttp: true }) .should.be.rejectedWith( - /stellar.toml file exceeds allowed size of [0-9]+/, + /stellar.toml file exceeds allowed size of [0-9]+/ ) .notify(done) .then(() => tempServer.close()); }); }); - it("rejects after given timeout when global Config.timeout flag is set", function (done) { + it('rejects after given timeout when global Config.timeout flag is set', function (done) { StellarSdk.Config.setTimeout(1000); // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } @@ -152,8 +152,8 @@ FEDERATION_SERVER="https://api.stellar.org/federation" setTimeout(() => {}, 10000); }) .listen(4444, () => { - StellarSdk.StellarTomlResolver.resolve("localhost:4444", { - allowHttp: true, + StellarSdk.StellarTomlResolver.resolve('localhost:4444', { + allowHttp: true }) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) @@ -164,9 +164,9 @@ FEDERATION_SERVER="https://api.stellar.org/federation" }); }); - it("rejects after given timeout when timeout specified in StellarTomlResolver opts param", function (done) { + it('rejects after given timeout when timeout specified in StellarTomlResolver opts param', function (done) { // Unable to create temp server in a browser - if (typeof window != "undefined") { + if (typeof window != 'undefined') { return done(); } @@ -175,9 +175,9 @@ FEDERATION_SERVER="https://api.stellar.org/federation" setTimeout(() => {}, 10000); }) .listen(4444, () => { - StellarSdk.StellarTomlResolver.resolve("localhost:4444", { + StellarSdk.StellarTomlResolver.resolve('localhost:4444', { allowHttp: true, - timeout: 1000, + timeout: 1000 }) .should.be.rejectedWith(/timeout of 1000ms exceeded/) .notify(done) diff --git a/test/unit/soroban/get_account_test.js b/test/unit/soroban/get_account_test.js index 346c588c6..45cd999d7 100644 --- a/test/unit/soroban/get_account_test.js +++ b/test/unit/soroban/get_account_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#getAccount", function () { +describe('Server#getAccount', function () { const { Account, StrKey, xdr } = SorobanClient; beforeEach(function () { @@ -13,27 +11,27 @@ describe("Server#getAccount", function () { this.axiosMock.restore(); }); - it("requests the correct method", function (done) { - const address = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + it('requests the correct method', function (done) { + const address = 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; const accountId = xdr.PublicKey.publicKeyTypeEd25519( StrKey.decodeEd25519PublicKey(address) ); this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLedgerEntries", + method: 'getLedgerEntries', params: [ [ xdr.LedgerKey.account( new xdr.LedgerKeyAccount({ - accountId, + accountId }) - ).toXDR("base64"), - ], - ], + ).toXDR('base64') + ] + ] }) .returns( Promise.resolve({ @@ -41,15 +39,15 @@ describe("Server#getAccount", function () { result: { entries: [ { - xdr: "AAAAAAAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1g3gtpoE608YAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAQAAAAAY9D8iA", - }, - ], - }, - }, + xdr: 'AAAAAAAAAABzdv3ojkzWHMD7KUoXhrPx0GH18vHKV0ZfqpMiEblG1g3gtpoE608YAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAQAAAAAY9D8iA' + } + ] + } + } }) ); - const expected = new Account(address, "1"); + const expected = new Account(address, '1'); this.server .getAccount(address) .then(function (response) { @@ -59,42 +57,42 @@ describe("Server#getAccount", function () { .catch(done); }); - it("throws a useful error when the account is not found", function (done) { - const address = "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + it('throws a useful error when the account is not found', function (done) { + const address = 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; const accountId = xdr.PublicKey.publicKeyTypeEd25519( StrKey.decodeEd25519PublicKey(address) ); this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLedgerEntries", + method: 'getLedgerEntries', params: [ [ xdr.LedgerKey.account( new xdr.LedgerKeyAccount({ - accountId, + accountId }) - ).toXDR("base64"), - ], - ], + ).toXDR('base64') + ] + ] }) .returns( Promise.resolve({ data: { result: { - entries: null, - }, - }, + entries: null + } + } }) ); this.server .getAccount(address) .then(function (_) { - done(new Error("Expected error to be thrown")); + done(new Error('Expected error to be thrown')); }) .catch(function (err) { done( diff --git a/test/unit/soroban/get_contract_data_test.js b/test/unit/soroban/get_contract_data_test.js index a3b014a18..09bdec6cc 100644 --- a/test/unit/soroban/get_contract_data_test.js +++ b/test/unit/soroban/get_contract_data_test.js @@ -1,8 +1,7 @@ -const MockAdapter = require("axios-mock-adapter"); const xdr = SorobanClient.xdr; const Address = SorobanClient.Address; -describe("Server#getContractData", function () { +describe('Server#getContractData', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -13,23 +12,23 @@ describe("Server#getContractData", function () { this.axiosMock.restore(); }); - let address = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"; + let address = 'CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5'; let key = SorobanClient.xdr.ScVal.scvVec([ - SorobanClient.xdr.ScVal.scvSymbol("Admin"), + SorobanClient.xdr.ScVal.scvSymbol('Admin') ]); - it("key found", function (done) { + it('key found', function (done) { let result = { id: address, - sequence: "1", + sequence: '1' }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLedgerEntries", + method: 'getLedgerEntries', params: [ [ xdr.LedgerKey.contractData( @@ -39,24 +38,24 @@ describe("Server#getContractData", function () { .toScAddress(), key, durability: xdr.ContractDataDurability.persistent(), - bodyType: xdr.ContractEntryBodyType.dataEntry(), + bodyType: xdr.ContractEntryBodyType.dataEntry() }) - ).toXDR("base64"), - ], - ], + ).toXDR('base64') + ] + ] }) .returns( Promise.resolve({ data: { result: { - entries: [result], - }, - }, + entries: [result] + } + } }) ); this.server - .getContractData(address, key, "persistent") + .getContractData(address, key, 'persistent') .then(function (response) { expect(response).to.be.deep.equal(result); done(); @@ -66,13 +65,13 @@ describe("Server#getContractData", function () { }); }); - it("key not found", function (done) { + it('key not found', function (done) { this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLedgerEntries", + method: 'getLedgerEntries', params: [ [ xdr.LedgerKey.contractData( @@ -82,32 +81,32 @@ describe("Server#getContractData", function () { .toScAddress(), key, durability: xdr.ContractDataDurability.temporary(), - bodyType: xdr.ContractEntryBodyType.dataEntry(), + bodyType: xdr.ContractEntryBodyType.dataEntry() }) - ).toXDR("base64"), - ], - ], + ).toXDR('base64') + ] + ] }) .returns(Promise.resolve({ data: { result: { entries: [] } } })); this.server - .getContractData(address, key, "temporary") + .getContractData(address, key, 'temporary') .then(function (_response) { - done(new Error("Expected error")); + done(new Error('Expected error')); }) .catch(function (err) { done( err.code == 404 ? null - : new Error("Expected error code 404, got: " + err.code) + : new Error('Expected error code 404, got: ' + err.code) ); }); }); - it("fails on hex address (was deprecated now unsupported)", function (done) { - let hexAddress = "0".repeat(63) + "1"; + it('fails on hex address (was deprecated now unsupported)', function (done) { + let hexAddress = '0'.repeat(63) + '1'; this.server - .getContractData(hexAddress, key, "persistent") + .getContractData(hexAddress, key, 'persistent') .then((reply) => done(new Error(`should fail, got: ${reply}`))) .catch((error) => { expect(error).to.contain(/unsupported contract id/i); diff --git a/test/unit/soroban/get_events_test.js b/test/unit/soroban/get_events_test.js index c53645e73..5232976f5 100644 --- a/test/unit/soroban/get_events_test.js +++ b/test/unit/soroban/get_events_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#getEvents", function () { +describe('Server#getEvents', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -11,14 +9,14 @@ describe("Server#getEvents", function () { this.axiosMock.restore(); }); - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { let result = { events: [] }; setupMock( this.axiosMock, { filters: [], pagination: {}, - startLedger: "1", + startLedger: '1' }, result ); @@ -34,19 +32,19 @@ describe("Server#getEvents", function () { }); }); - it("can build wildcard filters", function (done) { - let result = filterEvents(getEventsResponseFixture, "*/*"); + it('can build wildcard filters', function (done) { + let result = filterEvents(getEventsResponseFixture, '*/*'); setupMock( this.axiosMock, { - startLedger: "1", + startLedger: '1', filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], - pagination: {}, + pagination: {} }, result ); @@ -56,9 +54,9 @@ describe("Server#getEvents", function () { startLedger: 1, filters: [ { - topics: [["*", "*"]], - }, - ], + topics: [['*', '*']] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(result); @@ -67,22 +65,22 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can build matching filters", function (done) { + it('can build matching filters', function (done) { let result = filterEvents( getEventsResponseFixture, - "AAAABQAAAAh0cmFuc2Zlcg==/AAAAAQB6Mcc=" + 'AAAABQAAAAh0cmFuc2Zlcg==/AAAAAQB6Mcc=' ); setupMock( this.axiosMock, { - startLedger: "1", + startLedger: '1', filters: [ { - topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="]], - }, + topics: [['AAAABQAAAAh0cmFuc2Zlcg==', 'AAAAAQB6Mcc=']] + } ], - pagination: {}, + pagination: {} }, result ); @@ -92,9 +90,9 @@ describe("Server#getEvents", function () { startLedger: 1, filters: [ { - topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="]], - }, - ], + topics: [['AAAABQAAAAh0cmFuc2Zlcg==', 'AAAAAQB6Mcc=']] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(result); @@ -103,22 +101,22 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can build mixed filters", function (done) { + it('can build mixed filters', function (done) { let result = filterEventsByLedger( - filterEvents(getEventsResponseFixture, "AAAABQAAAAh0cmFuc2Zlcg==/*"), + filterEvents(getEventsResponseFixture, 'AAAABQAAAAh0cmFuc2Zlcg==/*'), 1 ); setupMock( this.axiosMock, { - startLedger: "1", + startLedger: '1', filters: [ { - topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "*"]], - }, + topics: [['AAAABQAAAAh0cmFuc2Zlcg==', '*']] + } ], - pagination: {}, + pagination: {} }, result ); @@ -128,9 +126,9 @@ describe("Server#getEvents", function () { startLedger: 1, filters: [ { - topics: [["AAAABQAAAAh0cmFuc2Zlcg==", "*"]], - }, - ], + topics: [['AAAABQAAAAh0cmFuc2Zlcg==', '*']] + } + ] }) .then(function (response) { expect(response).to.be.deep.equal(result); @@ -139,9 +137,9 @@ describe("Server#getEvents", function () { .catch(done); }); - it("can paginate", function (done) { + it('can paginate', function (done) { let result = filterEventsByLedger( - filterEvents(getEventsResponseFixture, "*/*"), + filterEvents(getEventsResponseFixture, '*/*'), 1 ); @@ -150,13 +148,13 @@ describe("Server#getEvents", function () { { filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], pagination: { limit: 10, - cursor: "0164090849041387521-0000000000", - }, + cursor: '0164090849041387521-0000000000' + } }, result ); @@ -165,11 +163,11 @@ describe("Server#getEvents", function () { .getEvents({ filters: [ { - topics: [["*", "*"]], - }, + topics: [['*', '*']] + } ], - cursor: "0164090849041387521-0000000000", - limit: 10, + cursor: '0164090849041387521-0000000000', + limit: 10 }) .then(function (response) { expect(response).to.be.deep.equal(result); @@ -183,7 +181,7 @@ function filterEvents(events, filter) { return events.filter( (e, i) => e.topic.length == filter.length && - e.topic.every((s, j) => s === filter[j] || s === "*") + e.topic.every((s, j) => s === filter[j] || s === '*') ); } @@ -195,71 +193,71 @@ function filterEventsByLedger(events, start) { function setupMock(axiosMock, params, result) { axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getEvents", - params: params, + method: 'getEvents', + params: params }) .returns(Promise.resolve({ data: { result } })); } let getEventsResponseFixture = [ { - type: "system", - ledger: "1", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'system', + ledger: '1', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId: - "e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", - topic: ["AAAABQAAAAh0cmFuc2Zlcg==", "AAAAAQB6Mcc="], + 'e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7', + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', + topic: ['AAAABQAAAAh0cmFuc2Zlcg==', 'AAAAAQB6Mcc='], inSuccessfulContractCall: true, value: { - xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", - }, + xdr: 'AAAABQAAAApHaWJNb255UGxzAAA=' + } }, { - type: "contract", - ledger: "2", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'contract', + ledger: '2', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId: - "e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", - topic: ["AAAAAQB6Mcc=", "AAAABQAAAAh0cmFuc2Zlcg=="], + 'e3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7', + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', + topic: ['AAAAAQB6Mcc=', 'AAAABQAAAAh0cmFuc2Zlcg=='], inSuccessfulContractCall: true, value: { - xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", - }, + xdr: 'AAAABQAAAApHaWJNb255UGxzAAA=' + } }, { - type: "diagnostic", - ledger: "2", - ledgerClosedAt: "2022-11-16T16:10:41Z", + type: 'diagnostic', + ledger: '2', + ledgerClosedAt: '2022-11-16T16:10:41Z', contractId: - "a3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7", - id: "0164090849041387521-0000000003", - pagingToken: "164090849041387521-3", + 'a3e82a76cc316f6289fd1ffbdf315da0f2c6be9582b84b9983a402f02ea0fff7', + id: '0164090849041387521-0000000003', + pagingToken: '164090849041387521-3', inSuccessfulContractCall: true, - topic: ["AAAAAQB6Mcc="], + topic: ['AAAAAQB6Mcc='], value: { - xdr: "AAAABQAAAApHaWJNb255UGxzAAA=", - }, + xdr: 'AAAABQAAAApHaWJNb255UGxzAAA=' + } }, { - type: "contract", - ledger: "3", - ledgerClosedAt: "2022-12-14T01:01:20Z", + type: 'contract', + ledger: '3', + ledgerClosedAt: '2022-12-14T01:01:20Z', contractId: - "6ebe0114ae15f72f187f05d06dcb66b22bd97218755c9b4646b034ab961fc1d5", - id: "0000000171798695936-0000000001", - pagingToken: "0000000171798695936-0000000001", + '6ebe0114ae15f72f187f05d06dcb66b22bd97218755c9b4646b034ab961fc1d5', + id: '0000000171798695936-0000000001', + pagingToken: '0000000171798695936-0000000001', inSuccessfulContractCall: true, - topic: ["AAAABQAAAAdDT1VOVEVSAA==", "AAAABQAAAAlpbmNyZW1lbnQAAAA="], + topic: ['AAAABQAAAAdDT1VOVEVSAA==', 'AAAABQAAAAlpbmNyZW1lbnQAAAA='], value: { - xdr: "AAAAAQAAAAE=", - }, - }, + xdr: 'AAAAAQAAAAE=' + } + } ]; diff --git a/test/unit/soroban/get_health_test.js b/test/unit/soroban/get_health_test.js index 4d18c2b25..8190581e6 100644 --- a/test/unit/soroban/get_health_test.js +++ b/test/unit/soroban/get_health_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#getHealth", function () { +describe('Server#getHealth', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -11,18 +9,18 @@ describe("Server#getHealth", function () { this.axiosMock.restore(); }); - it("requests the correct endpoint", function (done) { + it('requests the correct endpoint', function (done) { let result = { - status: "healthy", + status: 'healthy' }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getHealth", - params: null, + method: 'getHealth', + params: null }) .returns(Promise.resolve({ data: { result } })); diff --git a/test/unit/soroban/get_latest_ledger_test.js b/test/unit/soroban/get_latest_ledger_test.js index 6ad072ec9..6de4af8a3 100644 --- a/test/unit/soroban/get_latest_ledger_test.js +++ b/test/unit/soroban/get_latest_ledger_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#getLatestLedger", function () { +describe('Server#getLatestLedger', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -11,19 +9,19 @@ describe("Server#getLatestLedger", function () { this.axiosMock.restore(); }); - it("requests the correct method", function (done) { + it('requests the correct method', function (done) { const result = { - id: "hashed_id", + id: 'hashed_id', sequence: 123, - protocolVersion: 20, + protocolVersion: 20 }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLatestLedger", - params: null, + method: 'getLatestLedger', + params: null }) .returns(Promise.resolve({ data: { result } })); diff --git a/test/unit/soroban/get_network_test.js b/test/unit/soroban/get_network_test.js index 0c68333ff..426073bea 100644 --- a/test/unit/soroban/get_network_test.js +++ b/test/unit/soroban/get_network_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#getNetwork", function () { +describe('Server#getNetwork', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -11,19 +9,19 @@ describe("Server#getNetwork", function () { this.axiosMock.restore(); }); - it("requests the correct method", function (done) { + it('requests the correct method', function (done) { const result = { - friendbotUrl: "https://friendbot.stellar.org", - passphrase: "Soroban Testnet ; December 2018", - protocolVersion: 20, + friendbotUrl: 'https://friendbot.stellar.org', + passphrase: 'Soroban Testnet ; December 2018', + protocolVersion: 20 }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getNetwork", - params: null, + method: 'getNetwork', + params: null }) .returns(Promise.resolve({ data: { result } })); diff --git a/test/unit/soroban/get_transaction_test.js b/test/unit/soroban/get_transaction_test.js index c921e8303..d3630d903 100644 --- a/test/unit/soroban/get_transaction_test.js +++ b/test/unit/soroban/get_transaction_test.js @@ -1,8 +1,8 @@ -describe("Server#getTransaction", function () { +describe('Server#getTransaction', function () { let keypair = SorobanClient.Keypair.random(); let account = new SorobanClient.Account( keypair.publicKey(), - "56199647068161" + '56199647068161' ); beforeEach(function () { @@ -10,14 +10,14 @@ describe("Server#getTransaction", function () { this.axiosMock = sinon.mock(AxiosClient); let transaction = new SorobanClient.TransactionBuilder(account, { fee: 100, - networkPassphrase: SorobanClient.Networks.FUTURENET, + networkPassphrase: SorobanClient.Networks.FUTURENET }) .addOperation( SorobanClient.Operation.payment({ destination: - "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + 'GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW', asset: SorobanClient.Asset.native(), - amount: "100.50", + amount: '100.50' }) ) .setTimeout(SorobanClient.TimeoutInfinite) @@ -25,8 +25,8 @@ describe("Server#getTransaction", function () { transaction.sign(keypair); this.transaction = transaction; - this.hash = this.transaction.hash().toString("hex"); - this.blob = transaction.toEnvelope().toXDR().toString("base64"); + this.hash = this.transaction.hash().toString('hex'); + this.blob = transaction.toEnvelope().toXDR().toString('base64'); }); afterEach(function () { @@ -34,21 +34,21 @@ describe("Server#getTransaction", function () { this.axiosMock.restore(); }); - it("transaction not found", function (done) { + it('transaction not found', function (done) { const result = { - status: "NOT_FOUND", + status: 'NOT_FOUND', latestLedger: 100, latestLedgerCloseTime: 12345, oldestLedger: 50, - oldestLedgerCloseTime: 500, + oldestLedgerCloseTime: 500 }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getTransaction", - params: [this.hash], + method: 'getTransaction', + params: [this.hash] }) .returns(Promise.resolve({ data: { id: 1, result } })); @@ -58,9 +58,9 @@ describe("Server#getTransaction", function () { }); }); - xit("transaction pending", function (done) {}); + xit('transaction pending', function (done) {}); - xit("transaction success", function (done) {}); + xit('transaction success', function (done) {}); - xit("transaction error", function (done) {}); + xit('transaction error', function (done) {}); }); diff --git a/test/unit/soroban/request_airdrop_test.js b/test/unit/soroban/request_airdrop_test.js index 842812429..f6cf41409 100644 --- a/test/unit/soroban/request_airdrop_test.js +++ b/test/unit/soroban/request_airdrop_test.js @@ -1,6 +1,4 @@ -const MockAdapter = require("axios-mock-adapter"); - -describe("Server#requestAirdrop", function () { +describe('Server#requestAirdrop', function () { const { Account, StrKey, xdr } = SorobanClient; function accountLedgerEntryData(accountId, sequence) { @@ -9,16 +7,16 @@ describe("Server#requestAirdrop", function () { accountId: xdr.AccountId.publicKeyTypeEd25519( StrKey.decodeEd25519PublicKey(accountId) ), - balance: xdr.Int64.fromString("1"), + balance: xdr.Int64.fromString('1'), seqNum: xdr.SequenceNumber.fromString(sequence), numSubEntries: 0, inflationDest: null, flags: 0, - homeDomain: "", + homeDomain: '', // Taken from a real response. idk. - thresholds: Buffer.from("AQAAAA==", "base64"), + thresholds: Buffer.from('AQAAAA==', 'base64'), signers: [], - ext: new xdr.AccountEntryExt(0), + ext: new xdr.AccountEntryExt(0) }) ); } @@ -32,11 +30,11 @@ describe("Server#requestAirdrop", function () { new xdr.LedgerEntry({ lastModifiedLedgerSeq: 0, data: accountLedgerEntryData(accountId, sequence), - ext: new xdr.LedgerEntryExt(0), + ext: new xdr.LedgerEntryExt(0) }) - ), - ], - }), + ) + ] + }) ]); return meta; } @@ -54,38 +52,38 @@ describe("Server#requestAirdrop", function () { function mockGetNetwork(friendbotUrl) { const result = { friendbotUrl, - passphrase: "Soroban Testnet ; December 2018", - protocolVersion: 20, + passphrase: 'Soroban Testnet ; December 2018', + protocolVersion: 20 }; this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getNetwork", - params: null, + method: 'getNetwork', + params: null }) .returns(Promise.resolve({ data: { result } })); } - it("returns true when the account is created", function (done) { - const friendbotUrl = "https://friendbot.stellar.org"; + it('returns true when the account is created', function (done) { + const friendbotUrl = 'https://friendbot.stellar.org'; const accountId = - "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; mockGetNetwork.call(this, friendbotUrl); - const result_meta_xdr = transactionMetaFor(accountId, "1234").toXDR( - "base64" + const result_meta_xdr = transactionMetaFor(accountId, '1234').toXDR( + 'base64' ); this.axiosMock - .expects("post") + .expects('post') .withArgs(`${friendbotUrl}?addr=${accountId}`) .returns(Promise.resolve({ data: { result_meta_xdr } })); this.server .requestAirdrop(accountId) .then(function (response) { - expect(response).to.be.deep.equal(new Account(accountId, "1234")); + expect(response).to.be.deep.equal(new Account(accountId, '1234')); done(); }) .catch(function (err) { @@ -93,42 +91,42 @@ describe("Server#requestAirdrop", function () { }); }); - it("returns false if the account already exists", function (done) { - const friendbotUrl = "https://friendbot.stellar.org"; + it('returns false if the account already exists', function (done) { + const friendbotUrl = 'https://friendbot.stellar.org'; const accountId = - "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; mockGetNetwork.call(this, friendbotUrl); this.axiosMock - .expects("post") + .expects('post') .withArgs(`${friendbotUrl}?addr=${accountId}`) .returns( Promise.reject({ response: { status: 400, detail: - "createAccountAlreadyExist (AAAAAAAAAGT/////AAAAAQAAAAAAAAAA/////AAAAAA=)", - }, + 'createAccountAlreadyExist (AAAAAAAAAGT/////AAAAAQAAAAAAAAAA/////AAAAAA=)' + } }) ); this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "getLedgerEntries", + method: 'getLedgerEntries', params: [ [ xdr.LedgerKey.account( new xdr.LedgerKeyAccount({ accountId: xdr.PublicKey.publicKeyTypeEd25519( StrKey.decodeEd25519PublicKey(accountId) - ), + ) }) - ).toXDR("base64"), - ], - ], + ).toXDR('base64') + ] + ] }) .returns( Promise.resolve({ @@ -136,20 +134,18 @@ describe("Server#requestAirdrop", function () { result: { entries: [ { - xdr: accountLedgerEntryData(accountId, "1234").toXDR( - "base64" - ), - }, - ], - }, - }, + xdr: accountLedgerEntryData(accountId, '1234').toXDR('base64') + } + ] + } + } }) ); this.server .requestAirdrop(accountId) .then(function (response) { - expect(response).to.be.deep.equal(new Account(accountId, "1234")); + expect(response).to.be.deep.equal(new Account(accountId, '1234')); done(); }) .catch(function (err) { @@ -157,23 +153,23 @@ describe("Server#requestAirdrop", function () { }); }); - it("uses custom friendbotUrl if passed", function (done) { - const friendbotUrl = "https://custom-friendbot.stellar.org"; + it('uses custom friendbotUrl if passed', function (done) { + const friendbotUrl = 'https://custom-friendbot.stellar.org'; const accountId = - "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; - const result_meta_xdr = transactionMetaFor(accountId, "1234").toXDR( - "base64" + const result_meta_xdr = transactionMetaFor(accountId, '1234').toXDR( + 'base64' ); this.axiosMock - .expects("post") + .expects('post') .withArgs(`${friendbotUrl}?addr=${accountId}`) .returns(Promise.resolve({ data: { result_meta_xdr } })); this.server .requestAirdrop(accountId, friendbotUrl) .then(function (response) { - expect(response).to.be.deep.equal(new Account(accountId, "1234")); + expect(response).to.be.deep.equal(new Account(accountId, '1234')); done(); }) .catch(function (err) { @@ -181,76 +177,76 @@ describe("Server#requestAirdrop", function () { }); }); - it("rejects invalid addresses", function (done) { - const friendbotUrl = "https://friendbot.stellar.org"; - const accountId = "addr&injected=1"; + it('rejects invalid addresses', function (done) { + const friendbotUrl = 'https://friendbot.stellar.org'; + const accountId = 'addr&injected=1'; mockGetNetwork.call(this, friendbotUrl); this.axiosMock - .expects("post") + .expects('post') .withArgs(`${friendbotUrl}?addr=addr%26injected%3D1`) .returns( Promise.reject({ response: { status: 400, - type: "https://stellar.org/horizon-errors/bad_request", - title: "Bad Request", - detail: "The request you sent was invalid in some way.", + type: 'https://stellar.org/horizon-errors/bad_request', + title: 'Bad Request', + detail: 'The request you sent was invalid in some way.', extras: { - invalid_field: "addr", + invalid_field: 'addr', reason: - "base32 decode failed: illegal base32 data at input byte 7", - }, - }, + 'base32 decode failed: illegal base32 data at input byte 7' + } + } }) ); this.server .requestAirdrop(accountId) .then(function (_) { - done(new Error("Should have thrown")); + done(new Error('Should have thrown')); }) .catch(function (err) { - expect(err.response.extras.reason).to.include("base32 decode failed"); + expect(err.response.extras.reason).to.include('base32 decode failed'); done(); }); }); - it("throws if there is no friendbotUrl set", function (done) { - const accountId = "addr&injected=1"; + it('throws if there is no friendbotUrl set', function (done) { + const accountId = 'addr&injected=1'; mockGetNetwork.call(this, undefined); this.server .requestAirdrop(accountId) .then(function (_) { - done(new Error("Should have thrown")); + done(new Error('Should have thrown')); }) .catch(function (err) { expect(err.message).to.be.equal( - "No friendbot URL configured for current network" + 'No friendbot URL configured for current network' ); done(); }); }); - it("throws if the request fails", function (done) { - const friendbotUrl = "https://friendbot.stellar.org"; + it('throws if the request fails', function (done) { + const friendbotUrl = 'https://friendbot.stellar.org'; const accountId = - "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI"; + 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI'; mockGetNetwork.call(this, friendbotUrl); this.axiosMock - .expects("post") + .expects('post') .withArgs(`${friendbotUrl}?addr=${accountId}`) - .returns(Promise.reject(new Error("Request failed"))); + .returns(Promise.reject(new Error('Request failed'))); this.server .requestAirdrop(accountId) .then(function (_) { - done(new Error("Should have thrown")); + done(new Error('Should have thrown')); }) .catch(function (err) { - expect(err.message).to.be.equal("Request failed"); + expect(err.message).to.be.equal('Request failed'); done(); }); }); diff --git a/test/unit/soroban/send_transaction_test.js b/test/unit/soroban/send_transaction_test.js index 3e387be3b..139105c95 100644 --- a/test/unit/soroban/send_transaction_test.js +++ b/test/unit/soroban/send_transaction_test.js @@ -1,8 +1,8 @@ -describe("Server#sendTransaction", function () { +describe('Server#sendTransaction', function () { let keypair = SorobanClient.Keypair.random(); let account = new SorobanClient.Account( keypair.publicKey(), - "56199647068161" + '56199647068161' ); beforeEach(function () { @@ -11,14 +11,14 @@ describe("Server#sendTransaction", function () { let transaction = new SorobanClient.TransactionBuilder(account, { fee: 100, networkPassphrase: SorobanClient.Networks.TESTNET, - v1: true, + v1: true }) .addOperation( SorobanClient.Operation.payment({ destination: - "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW", + 'GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW', asset: SorobanClient.Asset.native(), - amount: "100.50", + amount: '100.50' }) ) .setTimeout(SorobanClient.TimeoutInfinite) @@ -26,8 +26,8 @@ describe("Server#sendTransaction", function () { transaction.sign(keypair); this.transaction = transaction; - this.hash = this.transaction.hash().toString("hex"); - this.blob = transaction.toEnvelope().toXDR().toString("base64"); + this.hash = this.transaction.hash().toString('hex'); + this.blob = transaction.toEnvelope().toXDR().toString('base64'); }); afterEach(function () { @@ -35,18 +35,18 @@ describe("Server#sendTransaction", function () { this.axiosMock.restore(); }); - it("sends a transaction", function (done) { + it('sends a transaction', function (done) { this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "sendTransaction", - params: [this.blob], + method: 'sendTransaction', + params: [this.blob] }) .returns( Promise.resolve({ - data: { id: 1, result: { id: this.hash, status: "PENDING" } }, + data: { id: 1, result: { id: this.hash, status: 'PENDING' } } }) ); @@ -59,11 +59,11 @@ describe("Server#sendTransaction", function () { done(err); }); }); - xit("adds metadata - tx was too small and was immediately deleted"); - xit("adds metadata, order immediately fills"); - xit("adds metadata, order is open"); - xit("adds metadata, partial fill"); - xit("doesnt add metadata to non-offers"); - xit("adds metadata about offers, even if some ops are not"); - xit("submits fee bump transactions"); + xit('adds metadata - tx was too small and was immediately deleted'); + xit('adds metadata, order immediately fills'); + xit('adds metadata, order is open'); + xit('adds metadata, partial fill'); + xit('doesnt add metadata to non-offers'); + xit('adds metadata about offers, even if some ops are not'); + xit('submits fee bump transactions'); }); diff --git a/test/unit/soroban/server_test.js b/test/unit/soroban/server_test.js index 4cabb0bbc..b87605960 100644 --- a/test/unit/soroban/server_test.js +++ b/test/unit/soroban/server_test.js @@ -1,4 +1,4 @@ -describe("Soroban Server.constructor", function () { +describe('Soroban Server.constructor', function () { beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); @@ -9,15 +9,15 @@ describe("Soroban Server.constructor", function () { this.axiosMock.restore(); }); - let insecureServerUrl = serverUrl.replace("https://", "http://"); + let insecureServerUrl = serverUrl.replace('https://', 'http://'); - it("throws error for insecure server", function () { + it('throws error for insecure server', function () { expect(() => new SorobanClient.Server(insecureServerUrl)).to.throw( /Cannot connect to insecure soroban-rpc server/ ); }); - it("allow insecure server when opts.allowHttp flag is set", function () { + it('allow insecure server when opts.allowHttp flag is set', function () { expect( () => new SorobanClient.Server(insecureServerUrl, { allowHttp: true }) ).to.not.throw(); diff --git a/test/unit/soroban/simulate_transaction_test.js b/test/unit/soroban/simulate_transaction_test.js index c41a33e80..e8ea664c8 100644 --- a/test/unit/soroban/simulate_transaction_test.js +++ b/test/unit/soroban/simulate_transaction_test.js @@ -1,11 +1,11 @@ -describe("Server#simulateTransaction", function () { +describe('Server#simulateTransaction', function () { let keypair = SorobanClient.Keypair.random(); let account = new SorobanClient.Account( keypair.publicKey(), - "56199647068161" + '56199647068161' ); - let contractId = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"; + let contractId = 'CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM'; let contract = new SorobanClient.Contract(contractId); let address = contract.address().toScAddress(); @@ -14,18 +14,18 @@ describe("Server#simulateTransaction", function () { resources: new SorobanClient.xdr.SorobanResources({ footprint: new SorobanClient.xdr.LedgerFootprint({ readOnly: [], - readWrite: [], + readWrite: [] }), instructions: 0, readBytes: 0, writeBytes: 0, - extendedMetaDataSizeBytes: 0, + extendedMetaDataSizeBytes: 0 }), - refundableFee: SorobanClient.xdr.Int64.fromString("0"), - ext: new SorobanClient.xdr.ExtensionPoint(0), - }).toXDR("base64"), + refundableFee: SorobanClient.xdr.Int64.fromString('0'), + ext: new SorobanClient.xdr.ExtensionPoint(0) + }).toXDR('base64'), events: [], - minResourceFee: "15", + minResourceFee: '15', result: { auth: [ new SorobanClient.xdr.SorobanAuthorizationEntry({ @@ -36,7 +36,7 @@ describe("Server#simulateTransaction", function () { address: address, nonce: new SorobanClient.xdr.Int64(1234), signatureExpirationLedger: 1, - signatureArgs: [], + signatureArgs: [] }) ), // Basic fake invocation @@ -45,42 +45,42 @@ describe("Server#simulateTransaction", function () { SorobanClient.xdr.SorobanAuthorizedFunction.sorobanAuthorizedFunctionTypeContractFn( new SorobanClient.xdr.SorobanAuthorizedContractFunction({ contractAddress: address, - functionName: "test", - args: [], + functionName: 'test', + args: [] }) ), - subInvocations: [], - }), - }).toXDR("base64"), + subInvocations: [] + }) + }).toXDR('base64') ], - xdr: SorobanClient.xdr.ScVal.scvU32(0).toXDR().toString("base64"), + xdr: SorobanClient.xdr.ScVal.scvU32(0).toXDR().toString('base64') }, latestLedger: 3, cost: { - cpuInsns: "0", - memBytes: "0", - }, + cpuInsns: '0', + memBytes: '0' + } }; beforeEach(function () { this.server = new SorobanClient.Server(serverUrl); this.axiosMock = sinon.mock(AxiosClient); const source = new SorobanClient.Account( - "GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI", - "1" + 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI', + '1' ); function emptyContractTransaction() { return new SorobanClient.TransactionBuilder(source, { fee: 100, - networkPassphrase: "Test", - v1: true, + networkPassphrase: 'Test', + v1: true }) .addOperation( SorobanClient.Operation.invokeHostFunction({ func: new SorobanClient.xdr.HostFunction.hostFunctionTypeInvokeContract( [] ), - auth: [], + auth: [] }) ) .setTimeout(SorobanClient.TimeoutInfinite) @@ -91,8 +91,8 @@ describe("Server#simulateTransaction", function () { transaction.sign(keypair); this.transaction = transaction; - this.hash = this.transaction.hash().toString("hex"); - this.blob = transaction.toEnvelope().toXDR().toString("base64"); + this.hash = this.transaction.hash().toString('hex'); + this.blob = transaction.toEnvelope().toXDR().toString('base64'); }); afterEach(function () { @@ -100,14 +100,14 @@ describe("Server#simulateTransaction", function () { this.axiosMock.restore(); }); - it("simulates a transaction", function (done) { + it('simulates a transaction', function (done) { this.axiosMock - .expects("post") + .expects('post') .withArgs(serverUrl, { - jsonrpc: "2.0", + jsonrpc: '2.0', id: 1, - method: "simulateTransaction", - params: [this.blob], + method: 'simulateTransaction', + params: [this.blob] }) .returns( Promise.resolve({ data: { id: 1, result: simulationResponse } }) @@ -123,11 +123,11 @@ describe("Server#simulateTransaction", function () { done(err); }); }); - xit("adds metadata - tx was too small and was immediately deleted"); - xit("adds metadata, order immediately fills"); - xit("adds metadata, order is open"); - xit("adds metadata, partial fill"); - xit("doesnt add metadata to non-offers"); - xit("adds metadata about offers, even if some ops are not"); - xit("simulates fee bump transactions"); + xit('adds metadata - tx was too small and was immediately deleted'); + xit('adds metadata, order immediately fills'); + xit('adds metadata, order is open'); + xit('adds metadata, partial fill'); + xit('doesnt add metadata to non-offers'); + xit('adds metadata about offers, even if some ops are not'); + xit('simulates fee bump transactions'); }); diff --git a/test/unit/utils_test.js b/test/unit/utils_test.js index f712c9d7c..724b630e1 100644 --- a/test/unit/utils_test.js +++ b/test/unit/utils_test.js @@ -1,17 +1,17 @@ -const randomBytes = require("randombytes"); +const randomBytes = require('randombytes'); function newClientSigner(key, weight) { return { key, weight }; } -describe("Utils", function () { +describe('Utils', function () { let clock, txBuilderOpts; beforeEach(function () { clock = sinon.useFakeTimers(); txBuilderOpts = { fee: 100, - networkPassphrase: StellarSdk.Networks.TESTNET, + networkPassphrase: StellarSdk.Networks.TESTNET }; }); @@ -19,32 +19,32 @@ describe("Utils", function () { clock.restore(); }); - describe("Utils.buildChallengeTx", function () { - it("allows non-muxed accounts", function () { + describe('Utils.buildChallengeTx', function () { + it('allows non-muxed accounts', function () { let keypair = StellarSdk.Keypair.random(); let muxedAddress = - "MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6"; + 'MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6'; let challenge; expect( () => (challenge = StellarSdk.Utils.buildChallengeTx( keypair, - "MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6", - "testanchor.stellar.org", + 'MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6', + 'testanchor.stellar.org', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - )), + 'testanchor.stellar.org' + )) ).not.to.throw(); const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true, + true ); expect(transaction.operations[0].source).to.equal(muxedAddress); }); - it("allows ID memos", function () { + it('allows ID memos', function () { let keypair = StellarSdk.Keypair.random(); let challenge; expect( @@ -52,77 +52,77 @@ describe("Utils", function () { (challenge = StellarSdk.Utils.buildChallengeTx( keypair, StellarSdk.Keypair.random().publicKey(), - "testanchor.stellar.org", + 'testanchor.stellar.org', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "8884404377665521220", - )), + 'testanchor.stellar.org', + '8884404377665521220' + )) ).not.to.throw(); const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true, + true ); - expect(transaction.memo.value).to.equal("8884404377665521220"); + expect(transaction.memo.value).to.equal('8884404377665521220'); }); - it("disallows non-ID memos", function () { + it('disallows non-ID memos', function () { let keypair = StellarSdk.Keypair.random(); expect( () => (challenge = StellarSdk.Utils.buildChallengeTx( keypair, StellarSdk.Keypair.random().publicKey(), - "testanchor.stellar.org", + 'testanchor.stellar.org', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "memo text", - )), + 'testanchor.stellar.org', + 'memo text' + )) ).to.throw(); }); - it("disallows memos with muxed accounts", function () { + it('disallows memos with muxed accounts', function () { let keypair = StellarSdk.Keypair.random(); const muxedAddress = - "MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6"; + 'MAAAAAAAAAAAAAB7BQ2L7E5NBWMXDUCMZSIPOBKRDSBYVLMXGSSKF6YNPIB7Y77ITLVL6'; expect( () => (challenge = StellarSdk.Utils.buildChallengeTx( keypair, muxedAddress, - "testanchor.stellar.org", + 'testanchor.stellar.org', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "8884404377665521220", - )), + 'testanchor.stellar.org', + '8884404377665521220' + )) ).to.throw(/memo cannot be used if clientAccountID is a muxed account/); }); - it("returns challenge which follows SEP0010 spec", function () { + it('returns challenge which follows SEP0010 spec', function () { let keypair = StellarSdk.Keypair.random(); let clientSigningKeypair = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( keypair, - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - "testanchor.stellar.org", + 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF', + 'testanchor.stellar.org', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org', null, - "testdomain", - clientSigningKeypair.publicKey(), + 'testdomain', + clientSigningKeypair.publicKey() ); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); - expect(transaction.sequence).to.eql("0"); + expect(transaction.sequence).to.eql('0'); expect(transaction.source).to.eql(keypair.publicKey()); expect(transaction.operations.length).to.eql(3); @@ -132,42 +132,42 @@ describe("Utils", function () { const [operation1, operation2, operation3] = transaction.operations; - expect(operation1.name).to.eql("testanchor.stellar.org auth"); + expect(operation1.name).to.eql('testanchor.stellar.org auth'); expect(operation1.source).to.eql( - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", + 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF' ); - expect(operation1.type).to.eql("manageData"); + expect(operation1.type).to.eql('manageData'); expect(operation1.value.length).to.eql(64); - expect(Buffer.from(operation1.value.toString(), "base64").length).to.eql( - 48, + expect(Buffer.from(operation1.value.toString(), 'base64').length).to.eql( + 48 ); - expect(operation2.name).to.equal("web_auth_domain"); + expect(operation2.name).to.equal('web_auth_domain'); expect(operation2.source).to.eql(keypair.publicKey()); - expect(operation2.type).to.eql("manageData"); - expect(operation2.value.toString()).to.eql("testanchor.stellar.org"); + expect(operation2.type).to.eql('manageData'); + expect(operation2.value.toString()).to.eql('testanchor.stellar.org'); - expect(operation3.name).to.eql("client_domain"); + expect(operation3.name).to.eql('client_domain'); expect(operation3.source).to.eql(clientSigningKeypair.publicKey()); - expect(operation3.type).to.eql("manageData"); - expect(operation3.value.toString()).to.eql("testdomain"); + expect(operation3.type).to.eql('manageData'); + expect(operation3.value.toString()).to.eql('testdomain'); }); - it("uses the passed-in timeout", function () { + it('uses the passed-in timeout', function () { let keypair = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( keypair, - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - "testanchor.stellar.org", + 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF', + 'testanchor.stellar.org', 600, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); let maxTime = parseInt(transaction.timeBounds.maxTime); @@ -178,79 +178,79 @@ describe("Utils", function () { expect(maxTime - minTime).to.eql(600); }); - it("throws an error if a muxed account and memo is passed", function () { + it('throws an error if a muxed account and memo is passed', function () { let keypair = StellarSdk.Keypair.random(); const muxedAddress = - "MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC"; + 'MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC'; expect(() => StellarSdk.Utils.buildChallengeTx( keypair, muxedAddress, - "testanchor.stellar.org", + 'testanchor.stellar.org', 600, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "10154623012567072189", - ), + 'testanchor.stellar.org', + '10154623012567072189' + ) ).to.throw(/memo cannot be used if clientAccountID is a muxed account/); }); - it("throws an error if clientSigningKey is not passed", function () { + it('throws an error if clientSigningKey is not passed', function () { expect(() => StellarSdk.Utils.buildChallengeTx( StellarSdk.Keypair.random(), StellarSdk.Keypair.random().publicKey(), - "testanchor.stellar.org", + 'testanchor.stellar.org', 600, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - null, - "testdomain", + 'testanchor.stellar.org', null, - ), + 'testdomain', + null + ) ).to.throw(/clientSigningKey is required if clientDomain is provided/); }); }); - describe("Utils.readChallengeTx", function () { - it("requires a envelopeTypeTxV0 or envelopeTypeTx", function () { + describe('Utils.readChallengeTx', function () { + it('requires a envelopeTypeTxV0 or envelopeTypeTx', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, clientKP.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); const innerTx = new StellarSdk.TransactionBuilder( - new StellarSdk.Account(clientKP.publicKey(), "0"), + new StellarSdk.Account(clientKP.publicKey(), '0'), { - fee: "100", + fee: '100', networkPassphrase: StellarSdk.Networks.TESTNET, timebounds: { minTime: 0, - maxTime: 0, - }, - }, + maxTime: 0 + } + } ) .addOperation( StellarSdk.Operation.payment({ destination: clientKP.publicKey(), asset: StellarSdk.Asset.native(), - amount: "10.000", - }), + amount: '10.000' + }) ) .build(); let feeBump = StellarSdk.TransactionBuilder.buildFeeBumpTransaction( serverKP, - "300", + '300', innerTx, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ).toXDR(); expect(() => @@ -258,12 +258,12 @@ describe("Utils", function () { feeBump, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid challenge: expected a Transaction but received a FeeBumpTransaction/, + /Invalid challenge: expected a Transaction but received a FeeBumpTransaction/ ); expect(() => @@ -271,18 +271,18 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.not.throw(StellarSdk.InvalidSep10ChallengeError); expect(() => StellarSdk.Utils.readChallengeTx( - feeBump.toXDR().toString("base64"), + feeBump.toXDR().toString('base64'), serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.not.throw(StellarSdk.InvalidSep10ChallengeError); }); it("returns the transaction and the clientAccountID (client's pubKey) if the challenge was created successfully", function () { @@ -292,17 +292,17 @@ describe("Utils", function () { const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, clientKP.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -310,37 +310,37 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transaction, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "SDF", - memo: null, + matchedHomeDomain: 'SDF', + memo: null }); }); - it("returns the clientAccountID and memo if the challenge includes a memo", function () { + it('returns the clientAccountID and memo if the challenge includes a memo', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - let clientMemo = "7659725268483412096"; + let clientMemo = '7659725268483412096'; const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, clientKP.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - clientMemo, + 'testanchor.stellar.org', + clientMemo ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -348,29 +348,29 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transaction, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "SDF", - memo: clientMemo, + matchedHomeDomain: 'SDF', + memo: clientMemo }); }); - it("returns the muxed clientAccountID if included in the challenge", function () { + it('returns the muxed clientAccountID if included in the challenge', function () { let serverKP = StellarSdk.Keypair.random(); let muxedAddress = - "MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC"; + 'MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC'; const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, muxedAddress, - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); @@ -378,7 +378,7 @@ describe("Utils", function () { const transaction = new StellarSdk.Transaction( challenge, StellarSdk.Networks.TESTNET, - true, + true ); expect( @@ -386,45 +386,45 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transaction, clientAccountID: muxedAddress, - matchedHomeDomain: "SDF", - memo: null, + matchedHomeDomain: 'SDF', + memo: null }); }); - it("throws an error if the transaction uses a muxed account and has a memo", function () { + it('throws an error if the transaction uses a muxed account and has a memo', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const clientMuxedAddress = - "MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC"; + 'MCQQMHTBRF2NPCEJWO2JMDT2HBQ2FGDCYREY2YIBSHLTXDG54Y3KTWX3R7NBER62VBELC'; const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientMuxedAddress, - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - withMuxing: true, - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64'), + withMuxing: true + }) ) - .addMemo(new StellarSdk.Memo.id("5842698851377328257")) + .addMemo(new StellarSdk.Memo.id('5842698851377328257')) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect(() => @@ -432,12 +432,12 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has a memo but the client account ID is a muxed account/, + /The transaction has a memo but the client account ID is a muxed account/ ); }); @@ -446,72 +446,72 @@ describe("Utils", function () { let clientKP = StellarSdk.Keypair.random(); const transaction = new StellarSdk.TransactionBuilder( - new StellarSdk.Account(serverKP.publicKey(), "-1"), - { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET }, + new StellarSdk.Account(serverKP.publicKey(), '-1'), + { fee: 100, networkPassphrase: StellarSdk.Networks.TESTNET } ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "SDF-test auth", - value: randomBytes(48).toString("base64"), - }), + name: 'SDF-test auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF-test", - "testanchor.stellar.org", - ), + 'SDF-test', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + serverKP.publicKey() + "'", + "Transaction not signed by server: '" + serverKP.publicKey() + "'" ); }); - it("throws an error if transaction sequenceNumber is different to zero", function () { + it('throws an error if transaction sequenceNumber is different to zero', function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "100"); + const account = new StellarSdk.Account(keypair.publicKey(), '100'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .setTimeout(30) .build(); - let challenge = transaction.toEnvelope().toXDR("base64").toString(); + let challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction sequence number should be zero/, + /The transaction sequence number should be zero/ ); }); - it("throws an error if transaction source account is different to server account id", function () { + it('throws an error if transaction source account is different to server account id', function () { let keypair = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( keypair, - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - "SDF", + 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF', + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); let serverAccountId = StellarSdk.Keypair.random().publicKey(); @@ -521,149 +521,149 @@ describe("Utils", function () { challenge, serverAccountId, StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction source account is not equal to the server's account/, + /The transaction source account is not equal to the server's account/ ); }); it("throws an error if transaction doesn't contain any operation", function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "-1"); + const account = new StellarSdk.Account(keypair.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .setTimeout(30) .build(); transaction.sign(keypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction should contain at least one operation/, + /The transaction should contain at least one operation/ ); }); - it("throws an error if operation does not contain the source account", function () { + it('throws an error if operation does not contain the source account', function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "-1"); + const account = new StellarSdk.Account(keypair.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ - name: "SDF auth", - value: randomBytes(48).toString("base64"), - }), + name: 'SDF auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(keypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation should contain a source account/, + /The transaction\'s operation should contain a source account/ ); }); - it("throws an error if operation is not manage data", function () { + it('throws an error if operation is not manage data', function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "-1"); + const account = new StellarSdk.Account(keypair.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.accountMerge({ destination: keypair.publicKey(), - source: keypair.publicKey(), - }), + source: keypair.publicKey() + }) ) .setTimeout(30) .build(); transaction.sign(keypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation type should be \'manageData\'/, + /The transaction\'s operation type should be \'manageData\'/ ); }); - it("throws an error if transaction.timeBounds.maxTime is infinite", function () { + it('throws an error if transaction.timeBounds.maxTime is infinite', function () { let serverKeypair = StellarSdk.Keypair.random(); let clientKeypair = StellarSdk.Keypair.random(); - const anchorName = "SDF"; + const anchorName = 'SDF'; const networkPassphrase = StellarSdk.Networks.TESTNET; - const account = new StellarSdk.Account(serverKeypair.publicKey(), "-1"); + const account = new StellarSdk.Account(serverKeypair.publicKey(), '-1'); const now = Math.floor(Date.now() / 1000); - const value = randomBytes(48).toString("base64"); + const value = randomBytes(48).toString('base64'); let transaction = new StellarSdk.TransactionBuilder(account, { fee: StellarSdk.BASE_FEE, networkPassphrase, timebounds: { minTime: now, - maxTime: "0", - }, + maxTime: '0' + } }) .addOperation( StellarSdk.Operation.manageData({ name: `${anchorName} auth`, value, - source: clientKeypair.publicKey(), - }), + source: clientKeypair.publicKey() + }) ) .build(); transaction.sign(serverKeypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(clientKeypair); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -672,91 +672,91 @@ describe("Utils", function () { serverKeypair.publicKey(), StellarSdk.Networks.TESTNET, anchorName, - "testanchor.stellar.org", - ), + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction requires non-infinite timebounds/, + /The transaction requires non-infinite timebounds/ ); }); - it("throws an error if operation value is not a 64 bytes base64 string", function () { + it('throws an error if operation value is not a 64 bytes base64 string', function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "-1"); + const account = new StellarSdk.Account(keypair.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ - name: "SDF auth", + name: 'SDF auth', value: randomBytes(64), - source: "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - }), + source: 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF' + }) ) .setTimeout(30) .build(); transaction.sign(keypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation value should be a 64 bytes base64 random string/, + /The transaction\'s operation value should be a 64 bytes base64 random string/ ); }); - it("throws an error if operation value is null", function () { + it('throws an error if operation value is null', function () { let keypair = StellarSdk.Keypair.random(); - const account = new StellarSdk.Account(keypair.publicKey(), "-1"); + const account = new StellarSdk.Account(keypair.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( account, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ - name: "SDF auth", + name: 'SDF auth', value: null, - source: "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF", - }), + source: 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF' + }) ) .setTimeout(30) .build(); transaction.sign(keypair); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, keypair.publicKey(), - StellarSdk.Networks.TESTNET, - ), + StellarSdk.Networks.TESTNET + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction\'s operation values should not be null/, + /The transaction\'s operation values should not be null/ ); }); - it("throws an error if transaction does not contain valid timeBounds", function () { + it('throws an error if transaction does not contain valid timeBounds', function () { let keypair = StellarSdk.Keypair.random(); let clientKeypair = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( keypair, clientKeypair.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); // Note that this is greater than the grace period of 5 minutes (600 seconds) @@ -764,13 +764,13 @@ describe("Utils", function () { const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(clientKeypair); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -778,61 +778,61 @@ describe("Utils", function () { signedChallenge, keypair.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has expired/, + /The transaction has expired/ ); }); - it("does NOT throw errors when the user is slightly out of minTime", function () { + it('does NOT throw errors when the user is slightly out of minTime', function () { clock.tick(1626888681 * 1000); // this challenge from Stablex's testnet env, collected 2021-07-21T17:31:21.530Z, // is erroring, and we want to know if it's a bug on our side or in the sdk const signedChallenge = - "AAAAAgAAAADZJunw2QO9LzjqagEjh/mpWG8Us5nOb+gc6wOex8G+IwAAAGQAAAAAAAAAAAAAAAEAAAAAYPhZ6gAAAXrKHz2UAAAAAAAAAAEAAAABAAAAAJyknd/qYHdzX6iV3TkHlh/usJUr5/U8cRsfVNqaruBAAAAACgAAAB50ZXN0bmV0LXNlcC5zdGFibGV4LmNsb3VkIGF1dGgAAAAAAAEAAABAaEs3QUZieUFCZzBEekx0WnpTVXJkcEhWOXdkdExXUkwxUHFFOW5QRVIrZVlaZzQvdDJlc3drclpBc0ZnTnp5UQAAAAAAAAABx8G+IwAAAEA8I5qQ+/HHXoHrULlg1ODTiCEQ92GQrVBFaB40OKxJhTf1c597AuKLHhJ3c4TNdSp1rjLGbk7qUuhjauxUuH0N"; + 'AAAAAgAAAADZJunw2QO9LzjqagEjh/mpWG8Us5nOb+gc6wOex8G+IwAAAGQAAAAAAAAAAAAAAAEAAAAAYPhZ6gAAAXrKHz2UAAAAAAAAAAEAAAABAAAAAJyknd/qYHdzX6iV3TkHlh/usJUr5/U8cRsfVNqaruBAAAAACgAAAB50ZXN0bmV0LXNlcC5zdGFibGV4LmNsb3VkIGF1dGgAAAAAAAEAAABAaEs3QUZieUFCZzBEekx0WnpTVXJkcEhWOXdkdExXUkwxUHFFOW5QRVIrZVlaZzQvdDJlc3drclpBc0ZnTnp5UQAAAAAAAAABx8G+IwAAAEA8I5qQ+/HHXoHrULlg1ODTiCEQ92GQrVBFaB40OKxJhTf1c597AuKLHhJ3c4TNdSp1rjLGbk7qUuhjauxUuH0N'; expect(() => StellarSdk.Utils.readChallengeTx( signedChallenge, - "GDMSN2PQ3EB32LZY5JVACI4H7GUVQ3YUWOM4437IDTVQHHWHYG7CGA5Z", + 'GDMSN2PQ3EB32LZY5JVACI4H7GUVQ3YUWOM4437IDTVQHHWHYG7CGA5Z', StellarSdk.Networks.TESTNET, - "testnet-sep.stablex.cloud", - "staging-transfer-server.zetl.network", - ), + 'testnet-sep.stablex.cloud', + 'staging-transfer-server.zetl.network' + ) ).not.to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has expired/, + /The transaction has expired/ ); }); it("home domain string matches transaction's operation key name", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -840,41 +840,41 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "testanchor.stellar.org", - memo: null, + matchedHomeDomain: 'testanchor.stellar.org', + memo: null }); }); it("home domain in array matches transaction's operation key name", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -882,71 +882,71 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - ["SDF", "Test", "testanchor.stellar.org", "SDF-test"], - "testanchor.stellar.org", - ), + ['SDF', 'Test', 'testanchor.stellar.org', 'SDF-test'], + 'testanchor.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "testanchor.stellar.org", - memo: null, + matchedHomeDomain: 'testanchor.stellar.org', + memo: null }); }); - it("throws an error if home domain is not provided", function () { + it('throws an error if home domain is not provided', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET // home domain not provided - ), + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: a home domain must be provided for verification/, + /Invalid homeDomains: a home domain must be provided for verification/ ); }); - it("throws an error if home domain type is not string or array", function () { + it('throws an error if home domain type is not string or array', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( @@ -954,115 +954,115 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, // home domain as number - 1, - ), + 1 + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: homeDomains type is number but should be a string or an array/, + /Invalid homeDomains: homeDomains type is number but should be a string or an array/ ); }); it("throws an error if home domain string does not match transaction's operation key name", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "does.not.match auth", - value: randomBytes(48).toString("base64"), - }), + name: 'does.not.match auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/, + /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/ ); }); it("throws an error if home domain array does not have a match to transaction's operation key name", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "does.not.match auth", - value: randomBytes(48).toString("base64"), - }), + name: 'does.not.match auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - ["SDF", "Test", "testanchor.stellar.org", "SDF-test"], - "testanchor.stellar.org", - ), + ['SDF', 'Test', 'testanchor.stellar.org', 'SDF-test'], + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/, + /Invalid homeDomains: the transaction\'s operation key name does not match the expected home domain/ ); }); - it("allows transaction to contain subsequent manage data ops with server account as source account", function () { + it('allows transaction to contain subsequent manage data ops with server account as source account', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "SDF auth", - value: randomBytes(48).toString("base64"), - }), + name: 'SDF auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), - name: "a key", - value: "a value", - }), + name: 'a key', + value: 'a value' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -1070,48 +1070,48 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "SDF", - memo: null, + matchedHomeDomain: 'SDF', + memo: null }); }); - it("throws an error if the transaction contain subsequent manage data ops without the server account as the source account", function () { + it('throws an error if the transaction contain subsequent manage data ops without the server account as the source account', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "SDF auth", - value: randomBytes(48).toString("base64"), - }), + name: 'SDF auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "a key", - value: "a value", - }), + name: 'a key', + value: 'a value' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect(() => @@ -1119,45 +1119,45 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are unrecognized/, + /The transaction has operations that are unrecognized/ ); }); - it("throws an error if the transaction contain subsequent ops that are not manage data ops", function () { + it('throws an error if the transaction contain subsequent ops that are not manage data ops', function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "SDF auth", - value: randomBytes(48).toString("base64"), - }), + name: 'SDF auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.bumpSequence({ source: clientKP.publicKey(), - bumpTo: "0", - }), + bumpTo: '0' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect(() => @@ -1165,46 +1165,46 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are not of type 'manageData'/, + /The transaction has operations that are not of type 'manageData'/ ); }); it("throws an error if the provided webAuthDomain does not match the 'web_auth_domain' operation's value", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), - name: "web_auth_domain", - value: "unexpected_web_auth_domain", - }), + name: 'web_auth_domain', + value: 'unexpected_web_auth_domain' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect(() => @@ -1212,46 +1212,46 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /'web_auth_domain' operation value does not match testanchor.stellar.org/, + /'web_auth_domain' operation value does not match testanchor.stellar.org/ ); }); it("throws an error if the 'web_auth_domain' operation's source account is not the server's public key", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "web_auth_domain", - value: "testanchor.stellar.org", - }), + name: 'web_auth_domain', + value: 'testanchor.stellar.org' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect(() => @@ -1259,39 +1259,39 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /The transaction has operations that are unrecognized/, + /The transaction has operations that are unrecognized/ ); }); it("allows transaction to omit the 'web_auth_domain' operation", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -1299,48 +1299,48 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "testanchor.stellar.org", - memo: null, + matchedHomeDomain: 'testanchor.stellar.org', + memo: null }); }); it("matches the 'web_auth_domain' operation value with webAuthDomain", function () { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), - name: "web_auth_domain", - value: "auth.stellar.org", - }), + name: 'web_auth_domain', + value: 'auth.stellar.org' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -1348,48 +1348,48 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "auth.stellar.org", - ), + 'testanchor.stellar.org', + 'auth.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "testanchor.stellar.org", - memo: null, + matchedHomeDomain: 'testanchor.stellar.org', + memo: null }); }); - it("allows subsequent manageData operations to have undefined values", () => { + it('allows subsequent manageData operations to have undefined values', () => { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: serverKP.publicKey(), - name: "nonWebAuthDomainKey", - value: null, - }), + name: 'nonWebAuthDomainKey', + value: null + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const transactionRoundTripped = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); expect( @@ -1397,76 +1397,76 @@ describe("Utils", function () { challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "auth.stellar.org", - ), + 'testanchor.stellar.org', + 'auth.stellar.org' + ) ).to.eql({ tx: transactionRoundTripped, clientAccountID: clientKP.publicKey(), - matchedHomeDomain: "testanchor.stellar.org", - memo: null, + matchedHomeDomain: 'testanchor.stellar.org', + memo: null }); }); it("validates a challenge containing a 'client_domain' manageData operation", () => { let serverKP = StellarSdk.Keypair.random(); let clientKP = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); let clientSigningKeypair = StellarSdk.Keypair.random(); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), - name: "client_domain", - value: "testdomain", - }), + name: 'client_domain', + value: 'testdomain' + }) ) .setTimeout(30) .build(); transaction.sign(serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); StellarSdk.Utils.readChallengeTx( challenge, serverKP.publicKey(), StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", - "testanchor.stellar.org", + 'testanchor.stellar.org', + 'testanchor.stellar.org' ); }); }); - describe("Utils.verifyChallengeTxThreshold", function () { + describe('Utils.verifyChallengeTxThreshold', function () { beforeEach(function () { this.serverKP = StellarSdk.Keypair.random(); this.clientKP1 = StellarSdk.Keypair.random(); this.clientKP2 = StellarSdk.Keypair.random(); this.clientKP3 = StellarSdk.Keypair.random(); - this.txAccount = new StellarSdk.Account(this.serverKP.publicKey(), "-1"); - this.opAccount = new StellarSdk.Account(this.clientKP1.publicKey(), "0"); + this.txAccount = new StellarSdk.Account(this.serverKP.publicKey(), '-1'); + this.opAccount = new StellarSdk.Account(this.clientKP1.publicKey(), '0'); this.operation = StellarSdk.Operation.manageData({ source: this.clientKP1.publicKey(), - name: "SDF-test auth", - value: randomBytes(48).toString("base64"), + name: 'SDF-test auth', + value: randomBytes(48).toString('base64') }); this.txBuilderOpts = { fee: 100, - networkPassphrase: StellarSdk.Networks.TESTNET, + networkPassphrase: StellarSdk.Networks.TESTNET }; }); @@ -1482,7 +1482,7 @@ describe("Utils", function () { it("throws an error if the server hasn't signed the transaction", function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts, + this.txBuilderOpts ) .addOperation(this.operation) .setTimeout(30) @@ -1493,7 +1493,7 @@ describe("Utils", function () { transaction.sign(this.clientKP1); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); expect(() => StellarSdk.Utils.verifyChallengeTxThreshold( @@ -1502,35 +1502,35 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF-test", - "testanchor.stellar.org", - ), + 'SDF-test', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + this.serverKP.publicKey() + "'", + "Transaction not signed by server: '" + this.serverKP.publicKey() + "'" ); }); - it("successfully validates server and client key meeting threshold", function () { + it('successfully validates server and client key meeting threshold', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 1; @@ -1543,38 +1543,38 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP1.publicKey()]); }); - it("successfully validates server and multiple client keys, meeting threshold", function () { + it('successfully validates server and multiple client keys, meeting threshold', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 3; const signerSummary = [ newClientSigner(this.clientKP1.publicKey(), 1), - newClientSigner(this.clientKP2.publicKey(), 2), + newClientSigner(this.clientKP2.publicKey(), 2) ]; expect( @@ -1584,39 +1584,39 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); - it("successfully validates server and multiple client keys, meeting threshold with more keys than needed", function () { + it('successfully validates server and multiple client keys, meeting threshold with more keys than needed', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 3; const signerSummary = [ newClientSigner(this.clientKP1.publicKey(), 1), newClientSigner(this.clientKP2.publicKey(), 2), - newClientSigner(this.clientKP3.publicKey(), 2), + newClientSigner(this.clientKP3.publicKey(), 2) ]; expect( @@ -1626,38 +1626,38 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); - it("successfully validates server and multiple client keys, meeting threshold with more keys than needed but ignoring PreauthTxHash and XHash", function () { + it('successfully validates server and multiple client keys, meeting threshold with more keys than needed but ignoring PreauthTxHash and XHash', function () { const preauthTxHash = - "TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4"; - const xHash = "XDRPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD"; + 'TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4'; + const xHash = 'XDRPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD'; const unknownSignerType = - "?ARPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD"; + '?ARPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD'; const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 3; @@ -1667,7 +1667,7 @@ describe("Utils", function () { newClientSigner(this.clientKP3.publicKey(), 2), newClientSigner(preauthTxHash, 10), newClientSigner(xHash, 10), - newClientSigner(unknownSignerType, 10), + newClientSigner(unknownSignerType, 10) ]; expect( @@ -1677,39 +1677,39 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP1.publicKey(), this.clientKP2.publicKey()]); }); - it("throws an error if multiple client keys were not enough to meet the threshold", function () { + it('throws an error if multiple client keys were not enough to meet the threshold', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 10; const signerSummary = [ newClientSigner(this.clientKP1.publicKey(), 1), newClientSigner(this.clientKP2.publicKey(), 2), - newClientSigner(this.clientKP3.publicKey(), 2), + newClientSigner(this.clientKP3.publicKey(), 2) ]; expect(() => @@ -1719,41 +1719,41 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - `signers with weight 3 do not meet threshold ${threshold}"`, + `signers with weight 3 do not meet threshold ${threshold}"` ); }); - it("throws an error if an unrecognized (not from the signerSummary) key has signed the transaction", function () { + it('throws an error if an unrecognized (not from the signerSummary) key has signed the transaction', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2, this.clientKP3); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 10; const signerSummary = [ newClientSigner(this.clientKP1.publicKey(), 1), - newClientSigner(this.clientKP2.publicKey(), 2), + newClientSigner(this.clientKP2.publicKey(), 2) ]; expect(() => @@ -1763,35 +1763,35 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, signerSummary, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction has unrecognized signatures/, + /Transaction has unrecognized signatures/ ); }); - it("throws an error if the signerSummary is empty", function () { + it('throws an error if the signerSummary is empty', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1, this.clientKP2, this.clientKP3); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const threshold = 10; @@ -1803,34 +1803,34 @@ describe("Utils", function () { StellarSdk.Networks.TESTNET, threshold, [], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/, + /No verifiable client signers provided, at least one G... address must be provided/ ); }); }); - describe("Utils.verifyChallengeTxSigners", function () { + describe('Utils.verifyChallengeTxSigners', function () { beforeEach(function () { this.serverKP = StellarSdk.Keypair.random(); this.clientKP1 = StellarSdk.Keypair.random(); this.clientKP2 = StellarSdk.Keypair.random(); - this.txAccount = new StellarSdk.Account(this.serverKP.publicKey(), "-1"); - this.opAccount = new StellarSdk.Account(this.clientKP1.publicKey(), "0"); + this.txAccount = new StellarSdk.Account(this.serverKP.publicKey(), '-1'); + this.opAccount = new StellarSdk.Account(this.clientKP1.publicKey(), '0'); this.operation = StellarSdk.Operation.manageData({ source: this.clientKP1.publicKey(), - name: "SDF-test auth", - value: randomBytes(48).toString("base64"), + name: 'SDF-test auth', + value: randomBytes(48).toString('base64') }); this.txBuilderOpts = { fee: 100, - networkPassphrase: StellarSdk.Networks.TESTNET, + networkPassphrase: StellarSdk.Networks.TESTNET }; }); @@ -1843,27 +1843,27 @@ describe("Utils", function () { (this.operation = null); }); - it("successfully validates server and client master key signatures in the transaction", function () { + it('successfully validates server and client master key signatures in the transaction', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -1872,16 +1872,16 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP1.publicKey()]); }); it("throws an error if the server hasn't signed the transaction", function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts, + this.txBuilderOpts ) .addOperation(this.operation) .setTimeout(30) @@ -1891,7 +1891,7 @@ describe("Utils", function () { const invalidsServerSignedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -1900,23 +1900,23 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], - "SDF-test", - "testanchor.stellar.org", - ), + 'SDF-test', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - "Transaction not signed by server: '" + this.serverKP.publicKey() + "'", + "Transaction not signed by server: '" + this.serverKP.publicKey() + "'" ); }); - it("throws an error if the list of signers is empty", function () { + it('throws an error if the list of signers is empty', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); @@ -1927,38 +1927,38 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/, + /No verifiable client signers provided, at least one G... address must be provided/ ); }); - it("throws an error if none of the given signers have signed the transaction", function () { + it('throws an error if none of the given signers have signed the transaction', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign( StellarSdk.Keypair.random(), - StellarSdk.Keypair.random(), + StellarSdk.Keypair.random() ); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -1967,30 +1967,30 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP1.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/, + /None of the given signers match the transaction signatures/ ); }); - it("successfully validates server and multiple client signers in the transaction", function () { + it('successfully validates server and multiple client signers in the transaction', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); const clientSigners = [this.clientKP1, this.clientKP2]; transaction.sign(...clientSigners); @@ -1998,7 +1998,7 @@ describe("Utils", function () { const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2007,27 +2007,27 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, clientSignersPubKey, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql(clientSignersPubKey); }); - it("successfully validates server and multiple client signers, in reverse order", function () { + it('successfully validates server and multiple client signers, in reverse order', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); const clientSigners = [this.clientKP1, this.clientKP2]; transaction.sign(...clientSigners.reverse()); @@ -2035,7 +2035,7 @@ describe("Utils", function () { const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2044,33 +2044,33 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, clientSignersPubKey, - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.have.same.members(clientSignersPubKey); }); - it("successfully validates server and non-masterkey client signer", function () { + it('successfully validates server and non-masterkey client signer', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2079,33 +2079,33 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP2.publicKey()]); }); - it("successfully validates server and non-master key client signer, ignoring extra signer", function () { + it('successfully validates server and non-master key client signer, ignoring extra signer', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2114,33 +2114,33 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), StellarSdk.Keypair.random().publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP2.publicKey()]); }); - it("throws an error if no client but instead the server has signed the transaction", function () { + it('throws an error if no client but instead the server has signed the transaction', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.serverKP); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2149,36 +2149,36 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.serverKP.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/, + /None of the given signers match the transaction signatures/ ); }); - it("successfully validates server and non-masterkey client signer, ignoring duplicated client signers", function () { + it('successfully validates server and non-masterkey client signer, ignoring duplicated client signers', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2187,39 +2187,39 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.clientKP2.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP2.publicKey()]); }); - it("successfully validates server and non-masterkey client signer, ignoring preauthTxHash and xHash", function () { + it('successfully validates server and non-masterkey client signer, ignoring preauthTxHash and xHash', function () { const preauthTxHash = - "TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4"; - const xHash = "XDRPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD"; + 'TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4'; + const xHash = 'XDRPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD'; const unknownSignerType = - "?ARPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD"; + '?ARPF6NZRR7EEVO7ESIWUDXHAOMM2QSKIQQBJK6I2FB7YKDZES5UCLWD'; const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect( @@ -2228,9 +2228,9 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), preauthTxHash, xHash, unknownSignerType], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.eql([this.clientKP2.publicKey()]); }); @@ -2238,22 +2238,22 @@ describe("Utils", function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2262,36 +2262,36 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey(), this.clientKP2.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/, + /None of the given signers match the transaction signatures/ ); }); - it("throws an error if the same KP has signed the transaction more than once", function () { + it('throws an error if the same KP has signed the transaction more than once', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2300,36 +2300,36 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction has unrecognized signatures/, + /Transaction has unrecognized signatures/ ); }); - it("throws an error if the client attempts to verify the transaction with a Seed instead of the Public Key", function () { + it('throws an error if the client attempts to verify the transaction with a Seed instead of the Public Key', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP2, this.clientKP2); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2338,30 +2338,30 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [this.clientKP2.secret()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/, + /No verifiable client signers provided, at least one G... address must be provided/ ); }); - it("throws an error if no client has signed the transaction", function () { + it('throws an error if no client has signed the transaction', function () { const transaction = new StellarSdk.TransactionBuilder( this.txAccount, - this.txBuilderOpts, + this.txBuilderOpts ) .addOperation(this.operation) .setTimeout(30) .build(); transaction.sign(this.serverKP); - const challenge = transaction.toEnvelope().toXDR("base64").toString(); + const challenge = transaction.toEnvelope().toXDR('base64').toString(); const clientSigners = [ this.clientKP1.publicKey(), - this.clientKP2.publicKey(), + this.clientKP2.publicKey() ]; expect(() => @@ -2370,36 +2370,36 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, clientSigners, - "SDF-test", - "testanchor.stellar.org", - ), + 'SDF-test', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /None of the given signers match the transaction signatures/, + /None of the given signers match the transaction signatures/ ); }); - it("throws an error if no public keys were provided to verify signatires", function () { + it('throws an error if no public keys were provided to verify signatires', function () { const challenge = StellarSdk.Utils.buildChallengeTx( this.serverKP, this.clientKP1.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org' ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(this.clientKP1); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2408,36 +2408,36 @@ describe("Utils", function () { this.serverKP.publicKey(), StellarSdk.Networks.TESTNET, [], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /No verifiable client signers provided, at least one G... address must be provided/, + /No verifiable client signers provided, at least one G... address must be provided/ ); }); - it("validates challenges containing client domain signers", () => { + it('validates challenges containing client domain signers', () => { const serverKP = StellarSdk.Keypair.random(); const clientKP = StellarSdk.Keypair.random(); const clientSigningKey = StellarSdk.Keypair.random(); const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, clientKP.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org', null, - "testdomain", - clientSigningKey.publicKey(), + 'testdomain', + clientSigningKey.publicKey() ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(clientKP); @@ -2445,7 +2445,7 @@ describe("Utils", function () { const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); const signersFound = StellarSdk.Utils.verifyChallengeTxSigners( @@ -2453,8 +2453,8 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, [clientKP.publicKey()], - "SDF", - "testanchor.stellar.org", + 'SDF', + 'testanchor.stellar.org' ); expect(signersFound.indexOf(clientSigningKey.publicKey())).to.eql(-1); @@ -2467,27 +2467,27 @@ describe("Utils", function () { const challenge = StellarSdk.Utils.buildChallengeTx( serverKP, clientKP.publicKey(), - "SDF", + 'SDF', 300, StellarSdk.Networks.TESTNET, - "testanchor.stellar.org", + 'testanchor.stellar.org', null, - "testdomain", - clientSigningKeypair.publicKey(), + 'testdomain', + clientSigningKeypair.publicKey() ); clock.tick(200); const transaction = new StellarSdk.Transaction( challenge, - StellarSdk.Networks.TESTNET, + StellarSdk.Networks.TESTNET ); transaction.sign(clientKP); const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2496,46 +2496,46 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, [clientKP.publicKey()], - "SDF", - "testanchor.stellar.org", - ), + 'SDF', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Transaction not signed by the source account of the 'client_domain' ManageData operation/, + /Transaction not signed by the source account of the 'client_domain' ManageData operation/ ); }); - it("throws an error if a challenge has multiple client_domain operations", () => { + it('throws an error if a challenge has multiple client_domain operations', () => { const serverKP = StellarSdk.Keypair.random(); const clientKP = StellarSdk.Keypair.random(); const clientSigningKeypair = StellarSdk.Keypair.random(); - const serverAccount = new StellarSdk.Account(serverKP.publicKey(), "-1"); + const serverAccount = new StellarSdk.Account(serverKP.publicKey(), '-1'); const transaction = new StellarSdk.TransactionBuilder( serverAccount, - txBuilderOpts, + txBuilderOpts ) .addOperation( StellarSdk.Operation.manageData({ source: clientKP.publicKey(), - name: "testanchor.stellar.org auth", - value: randomBytes(48).toString("base64"), - }), + name: 'testanchor.stellar.org auth', + value: randomBytes(48).toString('base64') + }) ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), - name: "client_domain", - value: "testdomain", - }), + name: 'client_domain', + value: 'testdomain' + }) ) .addOperation( StellarSdk.Operation.manageData({ source: clientSigningKeypair.publicKey(), - name: "client_domain", - value: "testdomain2", - }), + name: 'client_domain', + value: 'testdomain2' + }) ) .setTimeout(30) .build(); @@ -2548,7 +2548,7 @@ describe("Utils", function () { const signedChallenge = transaction .toEnvelope() - .toXDR("base64") + .toXDR('base64') .toString(); expect(() => @@ -2557,23 +2557,23 @@ describe("Utils", function () { serverKP.publicKey(), StellarSdk.Networks.TESTNET, [clientKP.publicKey()], - "testanchor.stellar.org", - "testanchor.stellar.org", - ), + 'testanchor.stellar.org', + 'testanchor.stellar.org' + ) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Found more than one client_domain operation/, + /Found more than one client_domain operation/ ); }); }); - describe("Utils.verifyTxSignedBy", function () { + describe('Utils.verifyTxSignedBy', function () { beforeEach(function () { this.keypair = StellarSdk.Keypair.random(); - this.account = new StellarSdk.Account(this.keypair.publicKey(), "-1"); + this.account = new StellarSdk.Account(this.keypair.publicKey(), '-1'); this.transaction = new StellarSdk.TransactionBuilder( this.account, - txBuilderOpts, + txBuilderOpts ) .setTimeout(30) .build(); @@ -2583,18 +2583,18 @@ describe("Utils", function () { this.keypair, this.account, (this.transaction = null); }); - it("returns true if the transaction was signed by the given account", function () { + it('returns true if the transaction was signed by the given account', function () { this.transaction.sign(this.keypair); expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - this.keypair.publicKey(), - ), + this.keypair.publicKey() + ) ).to.eql(true); }); - it("returns false if the transaction was not signed by the given account", function () { + it('returns false if the transaction was not signed by the given account', function () { this.transaction.sign(this.keypair); let differentKeypair = StellarSdk.Keypair.random(); @@ -2602,29 +2602,29 @@ describe("Utils", function () { expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - differentKeypair.publicKey(), - ), + differentKeypair.publicKey() + ) ).to.eql(false); }); - it("works with an unsigned transaction", function () { + it('works with an unsigned transaction', function () { expect( StellarSdk.Utils.verifyTxSignedBy( this.transaction, - this.keypair.publicKey(), - ), + this.keypair.publicKey() + ) ).to.eql(false); }); }); - describe("Utils.gatherTxSigners", function () { + describe('Utils.gatherTxSigners', function () { beforeEach(function () { this.keypair1 = StellarSdk.Keypair.random(); this.keypair2 = StellarSdk.Keypair.random(); - this.account = new StellarSdk.Account(this.keypair1.publicKey(), "-1"); + this.account = new StellarSdk.Account(this.keypair1.publicKey(), '-1'); this.transaction = new StellarSdk.TransactionBuilder( this.account, - txBuilderOpts, + txBuilderOpts ) .setTimeout(30) .build(); @@ -2634,90 +2634,90 @@ describe("Utils", function () { this.keypair1, this.keypair2, this.account, (this.transaction = null); }); - it("returns a list with the signatures used in the transaction", function () { + it('returns a list with the signatures used in the transaction', function () { this.transaction.sign(this.keypair1, this.keypair2); const expectedSignatures = [ this.keypair1.publicKey(), - this.keypair2.publicKey(), + this.keypair2.publicKey() ]; expect( - StellarSdk.Utils.gatherTxSigners(this.transaction, expectedSignatures), + StellarSdk.Utils.gatherTxSigners(this.transaction, expectedSignatures) ).to.eql(expectedSignatures); }); - it("returns a list with the signatures used in the transaction, removing duplicates", function () { + it('returns a list with the signatures used in the transaction, removing duplicates', function () { this.transaction.sign( this.keypair1, this.keypair1, this.keypair1, this.keypair2, this.keypair2, - this.keypair2, + this.keypair2 ); const expectedSignatures = [ this.keypair1.publicKey(), - this.keypair2.publicKey(), + this.keypair2.publicKey() ]; expect( StellarSdk.Utils.gatherTxSigners(this.transaction, [ this.keypair1.publicKey(), - this.keypair2.publicKey(), - ]), + this.keypair2.publicKey() + ]) ).to.eql(expectedSignatures); }); - it("returns an empty list if the transaction was not signed by the given accounts", function () { + it('returns an empty list if the transaction was not signed by the given accounts', function () { this.transaction.sign(this.keypair1, this.keypair2); let wrongSignatures = [ StellarSdk.Keypair.random().publicKey(), StellarSdk.Keypair.random().publicKey(), - StellarSdk.Keypair.random().publicKey(), + StellarSdk.Keypair.random().publicKey() ]; expect( - StellarSdk.Utils.gatherTxSigners(this.transaction, wrongSignatures), + StellarSdk.Utils.gatherTxSigners(this.transaction, wrongSignatures) ).to.eql([]); }); - it("calling gatherTxSigners with an unsigned transaction will return an empty list", function () { + it('calling gatherTxSigners with an unsigned transaction will return an empty list', function () { expect( StellarSdk.Utils.gatherTxSigners(this.transaction, [ this.keypair1.publicKey(), - this.keypair2.publicKey(), - ]), + this.keypair2.publicKey() + ]) ).to.eql([]); }); - it("Raises an error in case one of the given signers is not a valid G signer", function () { + it('Raises an error in case one of the given signers is not a valid G signer', function () { this.transaction.sign(this.keypair1, this.keypair2); const preauthTxHash = - "TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4"; + 'TAQCSRX2RIDJNHFIFHWD63X7D7D6TRT5Y2S6E3TEMXTG5W3OECHZ2OG4'; expect(() => StellarSdk.Utils.gatherTxSigners(this.transaction, [ preauthTxHash, - this.keypair1.publicKey(), - ]), + this.keypair1.publicKey() + ]) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Signer is not a valid address/, + /Signer is not a valid address/ ); }); - it("Raises an error in case one of the given signers is an invalid G signer", function () { + it('Raises an error in case one of the given signers is an invalid G signer', function () { this.transaction.sign(this.keypair1, this.keypair2); const invalidGHash = - "GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CAAA"; + 'GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CAAA'; expect(() => StellarSdk.Utils.gatherTxSigners(this.transaction, [ invalidGHash, - this.keypair1.publicKey(), - ]), + this.keypair1.publicKey() + ]) ).to.throw( StellarSdk.InvalidSep10ChallengeError, - /Signer is not a valid address/, + /Signer is not a valid address/ ); }); }); From 0a25bf4e004ce8d4c5a3647d9dcd79ec617be87f Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 15:28:36 -0700 Subject: [PATCH 09/14] Update integration test for both clients --- test/integration/client_headers_test.js | 74 ++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 8 deletions(-) diff --git a/test/integration/client_headers_test.js b/test/integration/client_headers_test.js index bf76ac208..21ac25534 100644 --- a/test/integration/client_headers_test.js +++ b/test/integration/client_headers_test.js @@ -1,9 +1,11 @@ -const http = require('http'); -const url = require('url'); +const http = require("http"); +const url = require("url"); const port = 3100; -describe('integration tests: client headers', function (done) { - if (typeof window !== 'undefined') { +const versionPattern = /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/; + +describe("integration tests: client headers", function (done) { + if (typeof window !== "undefined") { done(); return; } @@ -12,10 +14,8 @@ describe('integration tests: client headers', function (done) { let server; const requestHandler = (request, response) => { - expect(request.headers['x-client-name']).to.be.equal('js-soroban-client'); - expect(request.headers['x-client-version']).to.match( - /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/ - ); + expect(request.headers['x-client-name']).to.be.equal('js-stellar-sdk'); + expect(request.headers['x-client-version']).to.match(versionPattern); response.end(); server.close(() => done()); }; @@ -32,4 +32,62 @@ describe('integration tests: client headers', function (done) { }).getHealth(); }); }); + + it("sends client via headers", function (done) { + let server; + + const requestHandler = (request, response) => { + expect(request.headers["x-client-name"]).to.be.equal("js-stellar-sdk"); + expect(request.headers["x-client-version"]).to.match(versionPattern); + response.end(); + server.close(() => done()); + }; + + server = http.createServer(requestHandler); + server.listen(port, (err) => { + if (err) { + done(err); + return; + } + + new StellarSdk.Server(`http://localhost:${port}`, { allowHttp: true }) + .operations() + .call(); + }); + }); + + it("sends client data via get params when streaming", function (done) { + let server; + let closeStream; + + const requestHandler = (request, response) => { + // eslint-disable-next-line node/no-deprecated-api + let query = url.parse(request.url, true).query; + expect(query["X-Client-Name"]).to.be.equal("js-stellar-sdk"); + expect(query["X-Client-Version"]).to.match(versionPattern); + response.end(); + server.close(() => { + closeStream(); + done(); + }); + }; + + server = http.createServer(requestHandler); + server.listen(port, (err) => { + if (err) { + done(err); + return; + } + + closeStream = new StellarSdk.Server(`http://localhost:${port}`, { + allowHttp: true, + }) + .operations() + .stream({ + onerror: (err) => { + done(err); + }, + }); + }); + }); }); From 1ebc4daa0893d6a520188eacfcac702bfc9b482e Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 15:42:46 -0700 Subject: [PATCH 10/14] Fixup browser tests --- src/browser.ts | 1 + test/integration/client_headers_test.js | 24 ++++++++++++------------ test/test-browser.js | 3 +++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/browser.ts b/src/browser.ts index bbd6932ff..c81e4c90c 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -2,6 +2,7 @@ export * from './index'; export * as StellarBase from 'stellar-base'; +export * as SorobanClient from './soroban'; import axios from 'axios'; // idk why axios is weird export { axios }; diff --git a/test/integration/client_headers_test.js b/test/integration/client_headers_test.js index 21ac25534..78cffc1d1 100644 --- a/test/integration/client_headers_test.js +++ b/test/integration/client_headers_test.js @@ -1,11 +1,11 @@ -const http = require("http"); -const url = require("url"); +const http = require('http'); +const url = require('url'); const port = 3100; const versionPattern = /^[0-9]+\.[0-9]+\.[0-9]+(-[a-z]+(\.[0-9])?)?$/; -describe("integration tests: client headers", function (done) { - if (typeof window !== "undefined") { +describe('integration tests: client headers', function (done) { + if (typeof window !== 'undefined') { done(); return; } @@ -33,12 +33,12 @@ describe("integration tests: client headers", function (done) { }); }); - it("sends client via headers", function (done) { + it('sends client via headers', function (done) { let server; const requestHandler = (request, response) => { - expect(request.headers["x-client-name"]).to.be.equal("js-stellar-sdk"); - expect(request.headers["x-client-version"]).to.match(versionPattern); + expect(request.headers['x-client-name']).to.be.equal('js-stellar-sdk'); + expect(request.headers['x-client-version']).to.match(versionPattern); response.end(); server.close(() => done()); }; @@ -56,15 +56,15 @@ describe("integration tests: client headers", function (done) { }); }); - it("sends client data via get params when streaming", function (done) { + it('sends client data via get params when streaming', function (done) { let server; let closeStream; const requestHandler = (request, response) => { // eslint-disable-next-line node/no-deprecated-api let query = url.parse(request.url, true).query; - expect(query["X-Client-Name"]).to.be.equal("js-stellar-sdk"); - expect(query["X-Client-Version"]).to.match(versionPattern); + expect(query['X-Client-Name']).to.be.equal('js-stellar-sdk'); + expect(query['X-Client-Version']).to.match(versionPattern); response.end(); server.close(() => { closeStream(); @@ -80,13 +80,13 @@ describe("integration tests: client headers", function (done) { } closeStream = new StellarSdk.Server(`http://localhost:${port}`, { - allowHttp: true, + allowHttp: true }) .operations() .stream({ onerror: (err) => { done(err); - }, + } }); }); }); diff --git a/test/test-browser.js b/test/test-browser.js index 32b4ea88c..c0d37da13 100644 --- a/test/test-browser.js +++ b/test/test-browser.js @@ -1,4 +1,7 @@ /* eslint-disable no-undef */ chai.use(require('chai-as-promised')); +window.SorobanClient = StellarSdk.SorobanClient; window.axios = StellarSdk.axios; window.AxiosClient = StellarSdk.AxiosClient; + +global.serverUrl = 'https://horizon-live.stellar.org:1337/api/v1/jsonrpc'; \ No newline at end of file From 067fb651ae1190927f452ac13dd8789033fbb410 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 16:07:42 -0700 Subject: [PATCH 11/14] Resolve XDR type workarounds --- CHANGELOG.md | 4 ++-- src/errors.ts | 2 +- src/server.ts | 30 +++++++++++++++--------------- src/soroban/jsonrpc.ts | 2 +- src/stellar_toml_resolver.ts | 2 +- src/utils.ts | 10 +++++----- test/test-browser.js | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b4136679..de87eeeb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -166,7 +166,7 @@ This release introduces breaking changes from `stellar-base`. It adds **uncondit ### Updates -- Updates the following SEP-10 utility functions to include [client domain verification](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md#verifying-the-client-domain) functionality ([#720](https://github.com/stellar/js-stellar-sdk/pull/720)): +- Updates the following SEP-10 utility functions to include [client domain verification](https://stellar.org/protocol/sep-10.md#verifying-the-client-domain) functionality ([#720](https://github.com/stellar/js-stellar-sdk/pull/720)): - `Utils.buildChallengeTx()` accepts the `clientDomain` and `clientSigningKey` optional parameters - `Utils.readChallengeTx()` parses challenge transactions containing a `client_domain` ManageData operation - `Utils.verifyChallengeTxSigners()` verifies an additional signature from the `clientSigningKey` keypair if a `client_domain` Manage Data operation is included in the challenge @@ -634,7 +634,7 @@ The following enum values were rename in `OperationType`: If the transaction includes a memo, then memo required checking is skipped. - See [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md) for more information about memo required check. + See [SEP0029](https://stellar.org/protocol/sep-29.md) for more information about memo required check. ## [v4.0.2](https://github.com/stellar/js-stellar-sdk/compare/v4.0.1...v4.0.2) diff --git a/src/errors.ts b/src/errors.ts index 7cc3cf4eb..677e5c01d 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -70,7 +70,7 @@ export class InvalidSep10ChallengeError extends Error { /** * AccountRequiresMemoError is raised when a transaction is trying to submit an * operation to an account which requires a memo. See - * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md) + * [SEP0029](https://stellar.org/protocol/sep-29.md) * for more information. * * This error contains two attributes to help you identify the account requiring diff --git a/src/server.ts b/src/server.ts index bed6c1001..a8b3cca37 100644 --- a/src/server.ts +++ b/src/server.ts @@ -290,7 +290,7 @@ export class Server { * @param {object} [opts] Options object * @param {boolean} [opts.skipMemoRequiredCheck] - Allow skipping memo * required check, default: `false`. See - * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md). + * [SEP0029](https://stellar.org/protocol/sep-29.md). * @returns {Promise} Promise that resolves or rejects with response from * horizon. */ @@ -323,11 +323,11 @@ export class Server { } // TODO: fix stellar-base types. - const responseXDR: xdr.TransactionResult = (xdr.TransactionResult - .fromXDR as any)(response.data.result_xdr, "base64"); + const responseXDR: xdr.TransactionResult = xdr.TransactionResult.fromXDR( + response.data.result_xdr, "base64"); // TODO: fix stellar-base types. - const results = (responseXDR as any).result().value(); + const results = responseXDR.result().results(); let offerResults; let hasManageOffer; @@ -335,10 +335,10 @@ export class Server { if (results.length) { offerResults = results // TODO: fix stellar-base types. - .map((result: any, i: number) => { + .map((result, i: number) => { if ( - result.value().switch().name !== "manageBuyOffer" && - result.value().switch().name !== "manageSellOffer" + result.tr().switch().name !== "manageBuyOffer" && + result.tr().switch().name !== "manageSellOffer" ) { return null; } @@ -348,9 +348,10 @@ export class Server { let amountBought = new BigNumber(0); let amountSold = new BigNumber(0); - const offerSuccess = result - .value() - .value() + const offerSuccess = ( + result + .tr() + .value() as xdr.ManageBuyOfferResult | xdr.ManageSellOfferResult) .success(); const offersClaimed = offerSuccess @@ -436,13 +437,13 @@ export class Server { typeof offerSuccess.offer().value === "function" && offerSuccess.offer().value() ) { - const offerXDR = offerSuccess.offer().value(); + const offerXDR = offerSuccess.offer().offer(); currentOffer = { offerId: offerXDR.offerId().toString(), selling: {}, buying: {}, - amount: _getAmountInLumens(offerXDR.amount().toString()), + amount: _getAmountInLumens(new BigNumber(offerXDR.amount().toString())), price: { n: offerXDR.price().n(), d: offerXDR.price().d(), @@ -742,15 +743,14 @@ export class Server { * Check if any of the destination accounts requires a memo. * * This function implements a memo required check as defined in - * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md). + * [SEP-29](https://stellar.org/protocol/sep-29.md). * It will load each account which is the destination and check if it has the * data field `config.memo_required` set to `"MQ=="`. * * Each account is checked sequentially instead of loading multiple accounts * at the same time from Horizon. * - * @see - * [SEP0029](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0029.md) + * @see https://stellar.org/protocol/sep-29.md * @param {Transaction} transaction - The transaction to check. * @returns {Promise} - If any of the destination account * requires a memo, the promise will throw {@link AccountRequiresMemoError}. diff --git a/src/soroban/jsonrpc.ts b/src/soroban/jsonrpc.ts index d9c8bcef0..7a3c9e88b 100644 --- a/src/soroban/jsonrpc.ts +++ b/src/soroban/jsonrpc.ts @@ -1,4 +1,4 @@ -import {default as axios} from "../axios"; +import { default as axios } from "../axios"; import { hasOwnProperty } from "./utils"; export type Id = string | number; diff --git a/src/stellar_toml_resolver.ts b/src/stellar_toml_resolver.ts index 181734daf..646c68cd5 100644 --- a/src/stellar_toml_resolver.ts +++ b/src/stellar_toml_resolver.ts @@ -170,7 +170,7 @@ export namespace StellarTomlResolver { } // All fields are optional because there are no runtime checks // on external data body - // Sourced from https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0001.md + // Sourced from https://stellar.org/protocol/sep-1.md export interface StellarToml { VERSION?: string; ACCOUNTS?: PublicKey[]; diff --git a/src/utils.ts b/src/utils.ts index 2a99b4a97..48e94d4d9 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -20,10 +20,10 @@ import { ServerApi } from "./server_api"; */ export namespace Utils { /** - * Returns a valid [SEP0010](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md) + * Returns a valid [SEP0010](https://stellar.org/protocol/sep-10.md) * challenge transaction which you can use for Stellar Web Authentication. * - * @see [SEP0010: Stellar Web Authentication](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md). + * @see [SEP0010: Stellar Web Authentication](https://stellar.org/protocol/sep-10.md). * @function * @memberof Utils * @param {Keypair} serverKeypair Keypair for server's signing account. @@ -128,7 +128,7 @@ export namespace Utils { * - verifyChallengeTxThreshold * - verifyChallengeTxSigners * - * @see [SEP0010: Stellar Web Authentication](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md). + * @see [SEP0010: Stellar Web Authentication](https://stellar.org/protocol/sep-10.md). * @function * @memberof Utils * @param {string} challengeTx SEP0010 challenge transaction in base64. @@ -341,7 +341,7 @@ export namespace Utils { * server account or one of the signers provided in the arguments. * - The signatures are all valid but do not meet the threshold. * - * @see [SEP0010: Stellar Web Authentication](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md). + * @see [SEP0010: Stellar Web Authentication](https://stellar.org/protocol/sep-10.md). * @function * @memberof Utils * @param {string} challengeTx SEP0010 challenge transaction in base64. @@ -448,7 +448,7 @@ export namespace Utils { * - One or more signatures in the transaction are not identifiable as the * server account or one of the signers provided in the arguments. * - * @see [SEP0010: Stellar Web Authentication](https://github.com/stellar/stellar-protocol/blob/master/ecosystem/sep-0010.md). + * @see [SEP0010: Stellar Web Authentication](https://stellar.org/protocol/sep-10.md). * @function * @memberof Utils * @param {string} challengeTx SEP0010 challenge transaction in base64. diff --git a/test/test-browser.js b/test/test-browser.js index c0d37da13..0bdd67bfd 100644 --- a/test/test-browser.js +++ b/test/test-browser.js @@ -4,4 +4,4 @@ window.SorobanClient = StellarSdk.SorobanClient; window.axios = StellarSdk.axios; window.AxiosClient = StellarSdk.AxiosClient; -global.serverUrl = 'https://horizon-live.stellar.org:1337/api/v1/jsonrpc'; \ No newline at end of file +global.serverUrl = 'https://horizon-live.stellar.org:1337/api/v1/jsonrpc'; From 94ac80c1e7ef5ac83682b1643abae0e0145a792b Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 16:16:25 -0700 Subject: [PATCH 12/14] Move Horizon server into subfolder --- package.json | 7 +++---- src/browser.ts | 1 + src/errors.ts | 2 +- src/{ => horizon}/account_call_builder.ts | 1 + src/{ => horizon}/account_response.ts | 0 src/{ => horizon}/assets_call_builder.ts | 0 src/{ => horizon}/call_builder.ts | 7 ++----- src/{ => horizon}/claimable_balances_call_builder.ts | 0 src/{ => horizon}/effect_call_builder.ts | 0 src/{ => horizon}/friendbot_builder.ts | 0 src/{ => horizon}/horizon_api.ts | 0 src/horizon/index.ts | 12 ++++++++++++ src/{ => horizon}/ledger_call_builder.ts | 0 src/{ => horizon}/liquidity_pool_call_builder.ts | 0 src/{ => horizon}/offer_call_builder.ts | 0 src/{ => horizon}/operation_call_builder.ts | 0 src/{ => horizon}/orderbook_call_builder.ts | 0 src/{ => horizon}/path_call_builder.ts | 0 src/{ => horizon}/payment_call_builder.ts | 0 src/{ => horizon}/server.ts | 8 +++----- src/{ => horizon}/server_api.ts | 0 .../strict_receive_path_call_builder.ts | 0 src/{ => horizon}/strict_send_path_call_builder.ts | 0 src/{ => horizon}/trade_aggregation_call_builder.ts | 3 ++- src/{ => horizon}/trades_call_builder.ts | 0 src/{ => horizon}/transaction_call_builder.ts | 0 src/{ => horizon}/types/account.ts | 0 src/{ => horizon}/types/assets.ts | 2 +- src/{ => horizon}/types/effects.ts | 2 +- src/{ => horizon}/types/offer.ts | 2 +- src/{ => horizon}/types/trade.ts | 0 src/index.ts | 8 ++++---- src/soroban/browser.ts | 9 --------- src/utils.ts | 3 ++- 34 files changed, 34 insertions(+), 33 deletions(-) rename src/{ => horizon}/account_call_builder.ts (99%) rename src/{ => horizon}/account_response.ts (100%) rename src/{ => horizon}/assets_call_builder.ts (100%) rename src/{ => horizon}/call_builder.ts (98%) rename src/{ => horizon}/claimable_balances_call_builder.ts (100%) rename src/{ => horizon}/effect_call_builder.ts (100%) rename src/{ => horizon}/friendbot_builder.ts (100%) rename src/{ => horizon}/horizon_api.ts (100%) create mode 100644 src/horizon/index.ts rename src/{ => horizon}/ledger_call_builder.ts (100%) rename src/{ => horizon}/liquidity_pool_call_builder.ts (100%) rename src/{ => horizon}/offer_call_builder.ts (100%) rename src/{ => horizon}/operation_call_builder.ts (100%) rename src/{ => horizon}/orderbook_call_builder.ts (100%) rename src/{ => horizon}/path_call_builder.ts (100%) rename src/{ => horizon}/payment_call_builder.ts (100%) rename src/{ => horizon}/server.ts (99%) rename src/{ => horizon}/server_api.ts (100%) rename src/{ => horizon}/strict_receive_path_call_builder.ts (100%) rename src/{ => horizon}/strict_send_path_call_builder.ts (100%) rename src/{ => horizon}/trade_aggregation_call_builder.ts (98%) rename src/{ => horizon}/trades_call_builder.ts (100%) rename src/{ => horizon}/transaction_call_builder.ts (100%) rename src/{ => horizon}/types/account.ts (100%) rename src/{ => horizon}/types/assets.ts (92%) rename src/{ => horizon}/types/effects.ts (99%) rename src/{ => horizon}/types/offer.ts (91%) rename src/{ => horizon}/types/trade.ts (100%) delete mode 100644 src/soroban/browser.ts diff --git a/package.json b/package.json index 19857e764..4f08bbed1 100644 --- a/package.json +++ b/package.json @@ -31,16 +31,15 @@ "clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/", "docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json --verbose", "test": "yarn build && yarn test:node && yarn test:integration && yarn test:browser", - "test:node": "yarn _nyc mocha --recursive 'test/unit/**/*.js'", - "test:node:soroban": "yarn _nyc mocha --recursive 'test/unit/soroban/**/*.js'", - "test:integration": "yarn _nyc mocha --recursive 'test/integration/**/*.js'", + "test:node": "yarn _nyc 'test/unit/**/*.js'", + "test:integration": "yarn _nyc 'test/integration/**/*.js'", "test:browser": "karma start config/karma.conf.js", "fmt": "yarn eslint -c .eslintrc.js src/ --fix && yarn _prettier", "preversion": "yarn clean && yarn fmt && yarn build:prod && yarn test", "prepare": "yarn build:prod", "_build": "yarn build:node && yarn build:browser", "_babel": "babel --extensions '.ts' --out-dir lib/ src/", - "_nyc": "nyc --nycrc-path config/.nycrc", + "_nyc": "nyc --nycrc-path config/.nycrc mocha --recursive", "_prettier": "prettier --config config/prettier.config.js --ignore-path config/.prettierignore --write './**/*.js'" }, "husky": { diff --git a/src/browser.ts b/src/browser.ts index c81e4c90c..a15338486 100644 --- a/src/browser.ts +++ b/src/browser.ts @@ -3,6 +3,7 @@ export * from './index'; export * as StellarBase from 'stellar-base'; export * as SorobanClient from './soroban'; +export * from './horizon'; import axios from 'axios'; // idk why axios is weird export { axios }; diff --git a/src/errors.ts b/src/errors.ts index 677e5c01d..387eedb57 100644 --- a/src/errors.ts +++ b/src/errors.ts @@ -1,4 +1,4 @@ -import { Horizon } from "./horizon_api"; +import { Horizon } from "./horizon/horizon_api"; // For ES5 compatibility (https://stackoverflow.com/a/55066280). /* tslint:disable:variable-name max-classes-per-file */ diff --git a/src/account_call_builder.ts b/src/horizon/account_call_builder.ts similarity index 99% rename from src/account_call_builder.ts rename to src/horizon/account_call_builder.ts index ba840cf18..46db71e44 100644 --- a/src/account_call_builder.ts +++ b/src/horizon/account_call_builder.ts @@ -1,4 +1,5 @@ import { Asset } from "stellar-base"; + import { CallBuilder } from "./call_builder"; import { ServerApi } from "./server_api"; diff --git a/src/account_response.ts b/src/horizon/account_response.ts similarity index 100% rename from src/account_response.ts rename to src/horizon/account_response.ts diff --git a/src/assets_call_builder.ts b/src/horizon/assets_call_builder.ts similarity index 100% rename from src/assets_call_builder.ts rename to src/horizon/assets_call_builder.ts diff --git a/src/call_builder.ts b/src/horizon/call_builder.ts similarity index 98% rename from src/call_builder.ts rename to src/horizon/call_builder.ts index db3a26de6..695d84ed9 100644 --- a/src/call_builder.ts +++ b/src/horizon/call_builder.ts @@ -1,14 +1,11 @@ import URI from "urijs"; import URITemplate from "urijs/src/URITemplate"; -import { BadRequestError, NetworkError, NotFoundError } from "./errors"; +import { BadRequestError, NetworkError, NotFoundError } from "../errors"; import { Horizon } from "./horizon_api"; -import AxiosClient from "./axios"; +import AxiosClient, { version } from "../axios"; import { ServerApi } from "./server_api"; -/* tslint:disable-next-line:no-var-requires */ -const version = require("../package.json").version; - // Resources which can be included in the Horizon response via the `join` // query-param. const JOINABLE = ["transaction"]; diff --git a/src/claimable_balances_call_builder.ts b/src/horizon/claimable_balances_call_builder.ts similarity index 100% rename from src/claimable_balances_call_builder.ts rename to src/horizon/claimable_balances_call_builder.ts diff --git a/src/effect_call_builder.ts b/src/horizon/effect_call_builder.ts similarity index 100% rename from src/effect_call_builder.ts rename to src/horizon/effect_call_builder.ts diff --git a/src/friendbot_builder.ts b/src/horizon/friendbot_builder.ts similarity index 100% rename from src/friendbot_builder.ts rename to src/horizon/friendbot_builder.ts diff --git a/src/horizon_api.ts b/src/horizon/horizon_api.ts similarity index 100% rename from src/horizon_api.ts rename to src/horizon/horizon_api.ts diff --git a/src/horizon/index.ts b/src/horizon/index.ts new file mode 100644 index 000000000..3667fb4fd --- /dev/null +++ b/src/horizon/index.ts @@ -0,0 +1,12 @@ +// tslint:disable-next-line: no-reference +/// + +// Expose all types +export * from './horizon_api'; +export * from './server_api'; + +// stellar-sdk classes to expose +export * from './account_response'; +export { Server } from './server'; + +export default module.exports; diff --git a/src/ledger_call_builder.ts b/src/horizon/ledger_call_builder.ts similarity index 100% rename from src/ledger_call_builder.ts rename to src/horizon/ledger_call_builder.ts diff --git a/src/liquidity_pool_call_builder.ts b/src/horizon/liquidity_pool_call_builder.ts similarity index 100% rename from src/liquidity_pool_call_builder.ts rename to src/horizon/liquidity_pool_call_builder.ts diff --git a/src/offer_call_builder.ts b/src/horizon/offer_call_builder.ts similarity index 100% rename from src/offer_call_builder.ts rename to src/horizon/offer_call_builder.ts diff --git a/src/operation_call_builder.ts b/src/horizon/operation_call_builder.ts similarity index 100% rename from src/operation_call_builder.ts rename to src/horizon/operation_call_builder.ts diff --git a/src/orderbook_call_builder.ts b/src/horizon/orderbook_call_builder.ts similarity index 100% rename from src/orderbook_call_builder.ts rename to src/horizon/orderbook_call_builder.ts diff --git a/src/path_call_builder.ts b/src/horizon/path_call_builder.ts similarity index 100% rename from src/path_call_builder.ts rename to src/horizon/path_call_builder.ts diff --git a/src/payment_call_builder.ts b/src/horizon/payment_call_builder.ts similarity index 100% rename from src/payment_call_builder.ts rename to src/horizon/payment_call_builder.ts diff --git a/src/server.ts b/src/horizon/server.ts similarity index 99% rename from src/server.ts rename to src/horizon/server.ts index a8b3cca37..316510bcf 100644 --- a/src/server.ts +++ b/src/horizon/server.ts @@ -11,12 +11,12 @@ import { import URI from "urijs"; import { CallBuilder } from "./call_builder"; -import { Config } from "./config"; +import { Config } from "../config"; import { AccountRequiresMemoError, BadResponseError, NotFoundError, -} from "./errors"; +} from "../errors"; import { AccountCallBuilder } from "./account_call_builder"; import { AccountResponse } from "./account_response"; @@ -38,9 +38,7 @@ import { TradeAggregationCallBuilder } from "./trade_aggregation_call_builder"; import { TradesCallBuilder } from "./trades_call_builder"; import { TransactionCallBuilder } from "./transaction_call_builder"; -import AxiosClient, { - getCurrentServerTime, -} from "./axios"; +import AxiosClient, { getCurrentServerTime } from "../axios"; export const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; diff --git a/src/server_api.ts b/src/horizon/server_api.ts similarity index 100% rename from src/server_api.ts rename to src/horizon/server_api.ts diff --git a/src/strict_receive_path_call_builder.ts b/src/horizon/strict_receive_path_call_builder.ts similarity index 100% rename from src/strict_receive_path_call_builder.ts rename to src/horizon/strict_receive_path_call_builder.ts diff --git a/src/strict_send_path_call_builder.ts b/src/horizon/strict_send_path_call_builder.ts similarity index 100% rename from src/strict_send_path_call_builder.ts rename to src/horizon/strict_send_path_call_builder.ts diff --git a/src/trade_aggregation_call_builder.ts b/src/horizon/trade_aggregation_call_builder.ts similarity index 98% rename from src/trade_aggregation_call_builder.ts rename to src/horizon/trade_aggregation_call_builder.ts index f5f9f139e..9c93c876a 100644 --- a/src/trade_aggregation_call_builder.ts +++ b/src/horizon/trade_aggregation_call_builder.ts @@ -1,7 +1,8 @@ /* tslint:disable: variable-name */ import { Asset } from "stellar-base"; +import { BadRequestError } from "../errors"; + import { CallBuilder } from "./call_builder"; -import { BadRequestError } from "./errors"; import { Horizon } from "./horizon_api"; import { ServerApi } from "./server_api"; diff --git a/src/trades_call_builder.ts b/src/horizon/trades_call_builder.ts similarity index 100% rename from src/trades_call_builder.ts rename to src/horizon/trades_call_builder.ts diff --git a/src/transaction_call_builder.ts b/src/horizon/transaction_call_builder.ts similarity index 100% rename from src/transaction_call_builder.ts rename to src/horizon/transaction_call_builder.ts diff --git a/src/types/account.ts b/src/horizon/types/account.ts similarity index 100% rename from src/types/account.ts rename to src/horizon/types/account.ts diff --git a/src/types/assets.ts b/src/horizon/types/assets.ts similarity index 92% rename from src/types/assets.ts rename to src/horizon/types/assets.ts index 5c831408e..181bc35be 100644 --- a/src/types/assets.ts +++ b/src/horizon/types/assets.ts @@ -1,5 +1,5 @@ import { AssetType } from "stellar-base"; -import { Horizon } from "./../horizon_api"; +import { Horizon } from "../horizon_api"; export interface AssetRecord extends Horizon.BaseResponse { asset_type: AssetType.credit4 | AssetType.credit12; diff --git a/src/types/effects.ts b/src/horizon/types/effects.ts similarity index 99% rename from src/types/effects.ts rename to src/horizon/types/effects.ts index a2888907d..4a71c136a 100644 --- a/src/types/effects.ts +++ b/src/horizon/types/effects.ts @@ -1,4 +1,4 @@ -import { Horizon } from "./../horizon_api"; +import { Horizon } from "../horizon_api"; import { OfferAsset } from "./offer"; // Reference: GO SDK https://github.com/stellar/go/blob/ec5600bd6b2b6900d26988ff670b9ca7992313b8/services/horizon/internal/resourceadapter/effects.go diff --git a/src/types/offer.ts b/src/horizon/types/offer.ts similarity index 91% rename from src/types/offer.ts rename to src/horizon/types/offer.ts index 9319a33f5..2098eced9 100644 --- a/src/types/offer.ts +++ b/src/horizon/types/offer.ts @@ -1,5 +1,5 @@ import { AssetType } from "stellar-base"; -import { Horizon } from "./../horizon_api"; +import { Horizon } from "../horizon_api"; export interface OfferAsset { asset_type: AssetType; diff --git a/src/types/trade.ts b/src/horizon/types/trade.ts similarity index 100% rename from src/types/trade.ts rename to src/horizon/types/trade.ts diff --git a/src/index.ts b/src/index.ts index 2fed0bc7f..a49507b16 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,14 +2,11 @@ /// // Expose all types -export * from './horizon_api'; -export * from './server_api'; // stellar-sdk classes to expose -export * from './account_response'; export * from './errors'; export { Config } from './config'; -export { Server } from './server'; +export { Server } from './horizon/server'; export { FederationServer, FEDERATION_RESPONSE_MAX_SIZE, @@ -29,6 +26,9 @@ export * from './utils'; // expose classes and functions from stellar-base export * from 'stellar-base'; +// expose all Horizon stuff +export * from './horizon'; + // expose all Soroban stuff export * as SorobanClient from './soroban'; diff --git a/src/soroban/browser.ts b/src/soroban/browser.ts deleted file mode 100644 index bbd6932ff..000000000 --- a/src/soroban/browser.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* tslint:disable:no-var-requires */ - -export * from './index'; -export * as StellarBase from 'stellar-base'; - -import axios from 'axios'; // idk why axios is weird -export { axios }; - -export default module.exports; diff --git a/src/utils.ts b/src/utils.ts index 48e94d4d9..c339e4570 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -12,8 +12,9 @@ import { Transaction, TransactionBuilder, } from "stellar-base"; + import { InvalidSep10ChallengeError } from "./errors"; -import { ServerApi } from "./server_api"; +import { ServerApi } from "./horizon/server_api"; /** * @namespace Utils From 127043bec1222a463a46f3bc9c0496f9a6579a74 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 17:01:16 -0700 Subject: [PATCH 13/14] Fix outdated type workarounds --- src/horizon/server.ts | 44 +++++++++++++++++++------------------------ 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/src/horizon/server.ts b/src/horizon/server.ts index 316510bcf..07e5b09fc 100644 --- a/src/horizon/server.ts +++ b/src/horizon/server.ts @@ -64,11 +64,7 @@ function _getAmountInLumens(amt: BigNumber) { * @param {string} [opts.authToken] - Allow set custom header `X-Auth-Token`, default: `undefined`. */ export class Server { - /** - * serverURL Horizon Server URL (ex. `https://horizon-testnet.stellar.org`). - * - * TODO: Solve `URI(this.serverURL as any)`. - */ + /** Horizon Server URL (ex. `https://horizon-testnet.stellar.org`). */ public readonly serverURL: URI; constructor(serverURL: string, opts: Server.Options = {}) { @@ -159,7 +155,7 @@ export class Server { // otherwise, retry (by calling the root endpoint) // toString automatically adds the trailing slash - await AxiosClient.get(URI(this.serverURL as any).toString()); + await AxiosClient.get(this.serverURL.toString()); return await this.fetchTimebounds(seconds, true); } @@ -181,9 +177,7 @@ export class Server { * @returns {Promise} Promise that resolves to the fee stats returned by Horizon. */ public async feeStats(): Promise { - const cb = new CallBuilder( - URI(this.serverURL as any), - ); + const cb = new CallBuilder(URI(this.serverURL)); cb.filter.push(["fee_stats"]); return cb.call(); } @@ -309,7 +303,7 @@ export class Server { ); return AxiosClient.post( - URI(this.serverURL as any) + URI(this.serverURL) .segment("transactions") .toString(), `tx=${tx}`, @@ -510,28 +504,28 @@ export class Server { * @returns {AccountCallBuilder} New {@link AccountCallBuilder} object configured by a current Horizon server configuration. */ public accounts(): AccountCallBuilder { - return new AccountCallBuilder(URI(this.serverURL as any)); + return new AccountCallBuilder(URI(this.serverURL)); } /** * @returns {ClaimableBalanceCallBuilder} New {@link ClaimableBalanceCallBuilder} object configured by a current Horizon server configuration. */ public claimableBalances(): ClaimableBalanceCallBuilder { - return new ClaimableBalanceCallBuilder(URI(this.serverURL as any)); + return new ClaimableBalanceCallBuilder(URI(this.serverURL)); } /** * @returns {LedgerCallBuilder} New {@link LedgerCallBuilder} object configured by a current Horizon server configuration. */ public ledgers(): LedgerCallBuilder { - return new LedgerCallBuilder(URI(this.serverURL as any)); + return new LedgerCallBuilder(URI(this.serverURL)); } /** * @returns {TransactionCallBuilder} New {@link TransactionCallBuilder} object configured by a current Horizon server configuration. */ public transactions(): TransactionCallBuilder { - return new TransactionCallBuilder(URI(this.serverURL as any)); + return new TransactionCallBuilder(URI(this.serverURL)); } /** @@ -549,7 +543,7 @@ export class Server { * @returns {OfferCallBuilder} New {@link OfferCallBuilder} object */ public offers(): OfferCallBuilder { - return new OfferCallBuilder(URI(this.serverURL as any)); + return new OfferCallBuilder(URI(this.serverURL)); } /** @@ -559,7 +553,7 @@ export class Server { */ public orderbook(selling: Asset, buying: Asset): OrderbookCallBuilder { return new OrderbookCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), selling, buying, ); @@ -570,14 +564,14 @@ export class Server { * @returns {TradesCallBuilder} New {@link TradesCallBuilder} object configured by a current Horizon server configuration. */ public trades(): TradesCallBuilder { - return new TradesCallBuilder(URI(this.serverURL as any)); + return new TradesCallBuilder(URI(this.serverURL)); } /** * @returns {OperationCallBuilder} New {@link OperationCallBuilder} object configured by a current Horizon server configuration. */ public operations(): OperationCallBuilder { - return new OperationCallBuilder(URI(this.serverURL as any)); + return new OperationCallBuilder(URI(this.serverURL)); } /** @@ -620,7 +614,7 @@ export class Server { destinationAmount: string, ): PathCallBuilder { return new StrictReceivePathCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), source, destinationAsset, destinationAmount, @@ -648,7 +642,7 @@ export class Server { destination: string | Asset[], ): PathCallBuilder { return new StrictSendPathCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), sourceAsset, sourceAmount, destination, @@ -660,7 +654,7 @@ export class Server { * Horizon server configuration. */ public payments(): PaymentCallBuilder { - return new PaymentCallBuilder(URI(this.serverURL as any) as any); + return new PaymentCallBuilder(URI(this.serverURL)); } /** @@ -668,7 +662,7 @@ export class Server { * Horizon server configuration */ public effects(): EffectCallBuilder { - return new EffectCallBuilder(URI(this.serverURL as any) as any); + return new EffectCallBuilder(URI(this.serverURL)); } /** @@ -678,7 +672,7 @@ export class Server { * @private */ public friendbot(address: string): FriendbotBuilder { - return new FriendbotBuilder(URI(this.serverURL as any), address); + return new FriendbotBuilder(URI(this.serverURL), address); } /** @@ -687,7 +681,7 @@ export class Server { * @returns {AssetsCallBuilder} New AssetsCallBuilder instance */ public assets(): AssetsCallBuilder { - return new AssetsCallBuilder(URI(this.serverURL as any)); + return new AssetsCallBuilder(URI(this.serverURL)); } /** @@ -727,7 +721,7 @@ export class Server { offset: number, ): TradeAggregationCallBuilder { return new TradeAggregationCallBuilder( - URI(this.serverURL as any), + URI(this.serverURL), base, counter, start_time, From b4ac14638f7f3b616e6f489ebb9611031bd45d4d Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 15 Aug 2023 17:03:52 -0700 Subject: [PATCH 14/14] Fixup path after files moved --- test/unit/horizon/call_builders_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/unit/horizon/call_builders_test.js b/test/unit/horizon/call_builders_test.js index 984b7dd8f..6c1226eea 100644 --- a/test/unit/horizon/call_builders_test.js +++ b/test/unit/horizon/call_builders_test.js @@ -1,5 +1,5 @@ const URI = require('urijs'); -const { CallBuilder } = require('../../../lib/call_builder'); // bc not exported +const { CallBuilder } = require('../../../lib/horizon/call_builder'); // bc not exported describe('CallBuilder functions', function () { it("doesn't mutate the constructor passed url argument (it clones it instead)", function () {