Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/bitgo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
"bignumber.js": "^9.1.1",
"lodash": "^4.18.0",
"openpgp": "5.11.3",
"stellar-sdk": "^10.0.1",
"@stellar/stellar-sdk": "^16.0.0",
"superagent": "^9.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion modules/bitgo/src/v2/internal/seedValidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import * as _ from 'lodash';
import { CoinFamily } from '@bitgo/statics';
import { Hbar, Algo } from '@bitgo/account-lib';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-algo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"joi": "^17.4.0",
"js-sha512": "0.8.0",
"lodash": "^4.18.0",
"stellar-sdk": "^10.0.1",
"@stellar/stellar-sdk": "^16.0.0",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-algo/src/algo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {
AuditDecryptedKeyParams,
TxIntentMismatchError,
} from '@bitgo/sdk-core';
import stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import BigNumber from 'bignumber.js';
import Utils from './lib/utils';
import { TxData } from './lib/ifaces';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-algo/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import algosdk from 'algosdk';
import stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import * as hex from '@stablelib/hex';
import * as nacl from 'tweetnacl';
import base32 from 'hi-base32';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-algo/src/seedValidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import * as _ from 'lodash';
import { CoinFamily } from '@bitgo/statics';
import { algoUtils } from './lib';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-hbar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"lodash": "^4.18.0",
"long": "^5.2.3",
"protobufjs": "^7.5.8",
"stellar-sdk": "^10.0.1",
"@stellar/stellar-sdk": "^16.0.0",
"tweetnacl": "^1.0.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-hbar/src/hbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
AuditDecryptedKeyParams,
} from '@bitgo/sdk-core';
import { BigNumber } from 'bignumber.js';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { SeedValidator } from './seedValidator';
import { KeyPair as HbarKeyPair, TransactionBuilderFactory, Transaction, Recipient as HederaRecipient } from './lib';
import * as Utils from './lib/utils';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-hbar/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as _ from 'lodash';
import { AccountId, PrivateKey, PublicKey, TokenId, TransactionId } from '@hashgraph/sdk';
import { proto } from '@hashgraph/proto';
import BigNumber from 'bignumber.js';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { AddressDetails } from './iface';
import url from 'url';
import { toHex, toUint8Array, UtilsError } from '@bitgo/sdk-core';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-hbar/src/seedValidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import * as _ from 'lodash';
import { CoinFamily } from '@bitgo/statics';
import { createRawKey } from './lib/utils';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-hbar/test/unit/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import assert from 'assert';
import should from 'should';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import * as Utils from '../../src/lib/utils';
import * as testData from '../resources/hbar';
import { isValidEd25519PublicKey } from '@bitgo/sdk-core';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@bitgo/statics": "^58.54.0",
"bignumber.js": "^9.1.1",
"lodash": "^4.18.0",
"stellar-sdk": "^10.0.1",
"@stellar/stellar-sdk": "^16.0.0",
"superagent": "^9.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/src/getStellarKeys.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BitGoBase, InitiateRecoveryOptions } from '@bitgo/sdk-core';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { Utils } from './lib';

export async function getStellarKeys(bitgo: BitGoBase, params: InitiateRecoveryOptions): Promise<stellar.Keypair[]> {
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/src/lib/keyPair.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { DefaultKeys, Ed25519KeyPair, InvalidKey, KeyPairOptions } from '@bitgo/sdk-core';
import { decodePrivateKey, decodePublicKey, encodePrivateKey, encodePublicKey } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isValidEd25519PublicKey, isValidEd25519SecretKey } from '@bitgo/sdk-core';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';

/**
* Creates a Stellar keypair from a public key.
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/src/stellarToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as _ from 'lodash';
import { Xlm } from './xlm';
import { BitGoBase, BitGoJsError, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { StellarTokenConfig, tokens } from '@bitgo/statics';

export { StellarTokenConfig };
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/src/txlm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseCoin, BitGoBase } from '@bitgo/sdk-core';
import { Xlm } from './xlm';
const stellar = require('stellar-sdk');
const stellar = require('@stellar/stellar-sdk');

export class Txlm extends Xlm {
constructor(bitgo: BitGoBase) {
Expand Down
57 changes: 28 additions & 29 deletions modules/sdk-coin-xlm/src/xlm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import assert from 'assert';
import { BigNumber } from 'bignumber.js';
import * as _ from 'lodash';
import * as querystring from 'querystring';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { Federation: FederationAxios } = require('@stellar/stellar-sdk/axios') as typeof stellar;
import * as request from 'superagent';
import * as url from 'url';
import { KeyPair as StellarKeyPair } from './lib/keyPair';
Expand Down Expand Up @@ -364,7 +366,7 @@ export class Xlm extends BaseCoin {
* @returns minimum balance in stroops
*/
async getMinimumReserve(): Promise<number> {
const server = new stellar.Server(this.getHorizonUrl());
const server = new stellar.Horizon.Server(this.getHorizonUrl());

const horizonLedgerInfo = await server.ledgers().order('desc').limit(1).call();

Expand All @@ -383,7 +385,7 @@ export class Xlm extends BaseCoin {
* @returns transaction fee in stroops
*/
async getBaseTransactionFee(): Promise<number> {
const server = new stellar.Server(this.getHorizonUrl());
const server = new stellar.Horizon.Server(this.getHorizonUrl());

const horizonLedgerInfo = await server.ledgers().order('desc').limit(1).call();

Expand Down Expand Up @@ -531,11 +533,11 @@ export class Xlm extends BaseCoin {
*
* @returns instance of BitGo Federation Server
*/
getBitGoFederationServer(): stellar.FederationServer {
getBitGoFederationServer(): stellar.Federation.Server {
// Identify the URI scheme in case we need to allow connecting to HTTP server.
const isNonSecureEnv = !_.startsWith(common.Environments[this.bitgo.env].uri, 'https');
const federationServerOptions = { allowHttp: isNonSecureEnv };
return new stellar.FederationServer(this.getFederationServerUrl(), 'bitgo.com', federationServerOptions);
return new FederationAxios.Server(this.getFederationServerUrl(), 'bitgo.com', federationServerOptions);
}

/**
Expand All @@ -551,7 +553,7 @@ export class Xlm extends BaseCoin {
}: {
address?: string;
accountId?: string;
}): Promise<stellar.FederationServer.Record> {
}): Promise<stellar.Federation.Api.Record> {
try {
const federationServer = this.getBitGoFederationServer();
if (address) {
Expand All @@ -576,7 +578,7 @@ export class Xlm extends BaseCoin {
*
* @param {String} address - stellar address to look for
*/
async federationLookupByName(address: string): Promise<stellar.FederationServer.Record> {
async federationLookupByName(address: string): Promise<stellar.Federation.Api.Record> {
if (!address) {
throw new Error('invalid Stellar address');
}
Expand All @@ -590,7 +592,7 @@ export class Xlm extends BaseCoin {
*
* @param {String} accountId - stellar account id
*/
async federationLookupByAccountId(accountId: string): Promise<stellar.FederationServer.Record> {
async federationLookupByAccountId(accountId: string): Promise<stellar.Federation.Api.Record> {
if (!accountId) {
throw new Error('invalid Stellar account');
}
Expand Down Expand Up @@ -917,7 +919,7 @@ export class Xlm extends BaseCoin {
const outputs: TransactionOutput[] = [];
const operations: TransactionOperation[] = []; // non-payment operations

_.forEach(tx.operations, (op: stellar.Operation) => {
_.forEach(tx.operations, (op) => {
if (op.type === 'createAccount' || op.type === 'payment') {
// TODO Remove memoId from address
// Get memo to attach to address, if type is 'id'
Expand Down Expand Up @@ -997,28 +999,30 @@ export class Xlm extends BaseCoin {
}

getTrustlineOperationsOrThrow(
operations: stellar.Operation[],
operations: stellar.OperationRecord[],
txParams: TransactionParams,
operationTypePropName: 'trustlines' | 'recipients'
): stellar.Operation.ChangeTrust[] {
const trustlineOperations = operations.filter((op) => op?.type === 'changeTrust');
const trustlineOperations = operations.filter(
(op): op is stellar.Operation.ChangeTrust => op?.type === 'changeTrust'
);
if (trustlineOperations.length !== _.get(txParams, operationTypePropName, []).length) {
throw new Error('transaction prebuild does not match expected trustline operations');
}

return trustlineOperations;
}

isChangeTrustOperation(operation: stellar.Operation): operation is stellar.Operation.ChangeTrust {
return operation.type && operation.type === 'changeTrust';
isChangeTrustOperation(operation: stellar.OperationRecord): operation is stellar.Operation.ChangeTrust {
return operation.type === 'changeTrust';
}

getTrustlineOperationLineOrThrow(operation: stellar.Operation): stellar.Asset | stellar.LiquidityPoolAsset {
getTrustlineOperationLineOrThrow(operation: stellar.OperationRecord): stellar.Asset | stellar.LiquidityPoolAsset {
if (this.isChangeTrustOperation(operation) && operation.line) return operation.line;
throw new Error('Invalid operation - expected changeTrust operation with line property');
}

getTrustlineOperationLimitOrThrow(operation: stellar.Operation): string {
getTrustlineOperationLimitOrThrow(operation: stellar.OperationRecord): string {
if (this.isChangeTrustOperation(operation) && operation.limit) return operation.limit;
throw new Error('Invalid operation - expected changeTrust operation with limit property');
}
Expand All @@ -1034,9 +1038,9 @@ export class Xlm extends BaseCoin {
* @param {stellar.Operation} operations - tx operations
* @param {TransactionParams} txParams - params used to build the tx
*/
verifyTrustlineTxOperations(operations: stellar.Operation[], txParams: TransactionParams): void {
verifyTrustlineTxOperations(operations: stellar.OperationRecord[], txParams: TransactionParams): void {
const trustlineOperations = this.getTrustlineOperationsOrThrow(operations, txParams, 'trustlines');
_.forEach(trustlineOperations, (op: stellar.Operation) => {
_.forEach(trustlineOperations, (op) => {
if (op.type !== 'changeTrust') {
throw new Error('Invalid asset type');
}
Expand Down Expand Up @@ -1092,7 +1096,7 @@ export class Xlm extends BaseCoin {
return issuer;
}

verifyTxType(operations: stellar.Operation[]): void {
verifyTxType(operations: stellar.OperationRecord[]): void {
operations.forEach((operation) => {
if (!this.isChangeTrustOperation(operation))
throw new Error(
Expand All @@ -1103,7 +1107,7 @@ export class Xlm extends BaseCoin {
});
}

verifyAssetType(txParams: TransactionParams, operations: stellar.Operation[]): void {
verifyAssetType(txParams: TransactionParams, operations: stellar.OperationRecord[]): void {
operations.forEach((operation) => {
const line = this.getTrustlineOperationLineOrThrow(operation);
if (!this.isOperationLineOfAssetType(line)) {
Expand All @@ -1113,7 +1117,7 @@ export class Xlm extends BaseCoin {
});
}

verifyTokenIssuer(txParams: TransactionParams, operations: stellar.Operation[]): void {
verifyTokenIssuer(txParams: TransactionParams, operations: stellar.OperationRecord[]): void {
const fullTokenData = this.getTokenDataOrThrow(txParams);
const expectedIssuer = this.getIssuerFromTokenName(fullTokenData);

Expand All @@ -1125,7 +1129,7 @@ export class Xlm extends BaseCoin {
});
}

verifyTokenName(txParams: TransactionParams, operations: stellar.Operation[]): void {
verifyTokenName(txParams: TransactionParams, operations: stellar.OperationRecord[]): void {
const fullTokenData = this.getTokenDataOrThrow(txParams);
const expectedTokenCode = this.getTokenCodeFromTokenName(fullTokenData);

Expand All @@ -1140,7 +1144,7 @@ export class Xlm extends BaseCoin {
});
}

verifyTokenLimits(txParams: TransactionParams, operations: stellar.Operation[]): void {
verifyTokenLimits(txParams: TransactionParams, operations: stellar.OperationRecord[]): void {
const recipient = this.getRecipientOrThrow(txParams);

operations.forEach((operation) => {
Expand Down Expand Up @@ -1260,13 +1264,8 @@ export class Xlm extends BaseCoin {
throw new NotSupported('method deriveKeyWithSeed not supported for eddsa curve');
}

/**
* stellar-sdk has two overloads for toXDR, and typescript can't seem to figure out the
* correct one to use, so we have to be very explicit as to which one we want.
* @param tx transaction to convert
*/
protected static txToString = (tx: stellar.Transaction): string =>
(tx.toEnvelope().toXDR as (_: string) => string)('base64');
// v16 exposes toXDR() directly on TransactionBase, returning base64
protected static txToString = (tx: stellar.Transaction): string => tx.toXDR();

async parseTransaction(params: ParseTransactionOptions): Promise<ParsedTransaction> {
return {};
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/test/unit/keyPair.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as should from 'should';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';
import { KeyPair } from '../../src';
import { randomBytes } from 'crypto';
import assert from 'assert';
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-xlm/test/unit/xlm.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { randomBytes } from 'crypto';
import * as should from 'should';
import * as stellar from 'stellar-sdk';
import * as stellar from '@stellar/stellar-sdk';

import { BitGoAPI, encrypt } from '@bitgo/sdk-api';
import { Environments, PrebuildAndSignTransactionOptions, Wallet } from '@bitgo/sdk-core';
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@
"cookie": "^0.7.1",
"axios": "1.16.1",
"canvg": "4.0.3",
"**/stellar-sdk/**/bignumber.js": "4.1.0",
"**/stellar-base/**/bignumber.js": "4.1.0",
"**/@stellar/stellar-sdk/**/bignumber.js": "^11.1.1",
"bignumber.js": "9.1.2",
"form-data": "^4.0.4",
"**/avalanche/**/ws": "8.18.3",
Expand Down
Loading
Loading