Comparing version 2.1.0-beta.1 to 2.1.0
export { default as BroadcastClient } from './client/BroadcastClient'; | ||
export { Client } from './client'; | ||
export { Client, ClientOptions } from './client'; | ||
export * from './models'; | ||
@@ -4,0 +4,0 @@ export * from './utils'; |
@@ -42,3 +42,11 @@ export declare type LedgerIndex = number | ('validated' | 'closed' | 'current'); | ||
} | ||
export interface NFTOffer { | ||
amount: Amount; | ||
flags: number; | ||
index: string; | ||
owner: string; | ||
destination?: string; | ||
expiration?: number; | ||
} | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import AccountRoot, { AccountRootFlags } from './AccountRoot'; | ||
import AccountRoot, { AccountRootFlags, AccountRootFlagsInterface } from './AccountRoot'; | ||
import Amendments from './Amendments'; | ||
@@ -17,3 +17,3 @@ import Check from './Check'; | ||
import Ticket from './Ticket'; | ||
export { AccountRoot, AccountRootFlags, Amendments, Check, DepositPreauth, DirectoryNode, Escrow, FeeSettings, Ledger, LedgerEntry, LedgerHashes, NegativeUNL, Offer, OfferFlags, PayChannel, RippleState, RippleStateFlags, SignerList, SignerListFlags, Ticket, }; | ||
export { AccountRoot, AccountRootFlags, AccountRootFlagsInterface, Amendments, Check, DepositPreauth, DirectoryNode, Escrow, FeeSettings, Ledger, LedgerEntry, LedgerHashes, NegativeUNL, Offer, OfferFlags, PayChannel, RippleState, RippleStateFlags, SignerList, SignerListFlags, Ticket, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,3 +12,3 @@ import { BaseRequest, BaseResponse } from './baseMethod'; | ||
TokenID: string; | ||
TokenTaxons: number; | ||
TokenTaxon: number; | ||
nft_serial: number; | ||
@@ -18,2 +18,3 @@ } | ||
result: { | ||
account: string; | ||
account_nfts: AccountNFToken[]; | ||
@@ -20,0 +21,0 @@ ledger_current_index: number; |
@@ -10,3 +10,3 @@ import { AccountChannelsRequest, AccountChannelsResponse } from './accountChannels'; | ||
import { ErrorResponse } from './baseMethod'; | ||
import { BookOffersRequest, BookOffersResponse } from './bookOffers'; | ||
import { BookOffersRequest, BookOffer, BookOffersResponse } from './bookOffers'; | ||
import { ChannelVerifyRequest, ChannelVerifyResponse } from './channelVerify'; | ||
@@ -25,3 +25,3 @@ import { DepositAuthorizedRequest, DepositAuthorizedResponse } from './depositAuthorized'; | ||
import { NoRippleCheckRequest, NoRippleCheckResponse } from './norippleCheck'; | ||
import { PathFindRequest, PathFindResponse } from './pathFind'; | ||
import { PathFindRequest, PathFindCloseRequest, PathFindCreateRequest, PathFindStatusRequest, PathFindResponse } from './pathFind'; | ||
import { PingRequest, PingResponse } from './ping'; | ||
@@ -40,3 +40,3 @@ import { RandomRequest, RandomResponse } from './random'; | ||
declare type Response = AccountChannelsResponse | AccountCurrenciesResponse | AccountInfoResponse | AccountLinesResponse | AccountNFTsResponse | AccountObjectsResponse | AccountOffersResponse | AccountTxResponse | GatewayBalancesResponse | NoRippleCheckResponse | LedgerResponse | LedgerClosedResponse | LedgerCurrentResponse | LedgerDataResponse | LedgerEntryResponse | SubmitResponse | SubmitMultisignedResponse | TransactionEntryResponse | TxResponse | BookOffersResponse | DepositAuthorizedResponse | PathFindResponse | RipplePathFindResponse | ChannelVerifyResponse | SubscribeResponse | UnsubscribeResponse | FeeResponse | ManifestResponse | ServerInfoResponse | ServerStateResponse | PingResponse | RandomResponse | NFTBuyOffersResponse | NFTSellOffersResponse; | ||
export { Request, Response, AccountChannelsRequest, AccountChannelsResponse, AccountCurrenciesRequest, AccountCurrenciesResponse, AccountInfoRequest, AccountInfoResponse, AccountLinesRequest, AccountLinesResponse, AccountNFTsRequest, AccountNFTsResponse, AccountObjectsRequest, AccountObjectsResponse, AccountOffersRequest, AccountOffersResponse, AccountTxRequest, AccountTxResponse, GatewayBalancesRequest, GatewayBalancesResponse, NoRippleCheckRequest, NoRippleCheckResponse, LedgerRequest, LedgerResponse, LedgerClosedRequest, LedgerClosedResponse, LedgerCurrentRequest, LedgerCurrentResponse, LedgerDataRequest, LedgerDataResponse, LedgerEntryRequest, LedgerEntryResponse, SubmitRequest, SubmitResponse, SubmitMultisignedRequest, SubmitMultisignedResponse, TransactionEntryRequest, TransactionEntryResponse, TxRequest, TxResponse, BookOffersRequest, BookOffersResponse, DepositAuthorizedRequest, DepositAuthorizedResponse, PathFindRequest, PathFindResponse, RipplePathFindRequest, RipplePathFindResponse, ChannelVerifyRequest, ChannelVerifyResponse, SubscribeRequest, SubscribeResponse, Stream, LedgerStream, ValidationStream, TransactionStream, PathFindStream, PeerStatusStream, OrderBookStream, ConsensusStream, UnsubscribeRequest, UnsubscribeResponse, FeeRequest, FeeResponse, ManifestRequest, ManifestResponse, ServerInfoRequest, ServerInfoResponse, ServerStateRequest, ServerStateResponse, PingRequest, PingResponse, RandomRequest, RandomResponse, ErrorResponse, NFTBuyOffersRequest, NFTBuyOffersResponse, NFTSellOffersRequest, NFTSellOffersResponse, }; | ||
export { Request, Response, AccountChannelsRequest, AccountChannelsResponse, AccountCurrenciesRequest, AccountCurrenciesResponse, AccountInfoRequest, AccountInfoResponse, AccountLinesRequest, AccountLinesResponse, AccountNFTsRequest, AccountNFTsResponse, AccountObjectsRequest, AccountObjectsResponse, AccountOffersRequest, AccountOffersResponse, AccountTxRequest, AccountTxResponse, GatewayBalancesRequest, GatewayBalancesResponse, NoRippleCheckRequest, NoRippleCheckResponse, LedgerRequest, LedgerResponse, LedgerClosedRequest, LedgerClosedResponse, LedgerCurrentRequest, LedgerCurrentResponse, LedgerDataRequest, LedgerDataResponse, LedgerEntryRequest, LedgerEntryResponse, SubmitRequest, SubmitResponse, SubmitMultisignedRequest, SubmitMultisignedResponse, TransactionEntryRequest, TransactionEntryResponse, TxRequest, TxResponse, BookOffersRequest, BookOffer, BookOffersResponse, DepositAuthorizedRequest, DepositAuthorizedResponse, PathFindRequest, PathFindCreateRequest, PathFindCloseRequest, PathFindStatusRequest, PathFindResponse, RipplePathFindRequest, RipplePathFindResponse, ChannelVerifyRequest, ChannelVerifyResponse, SubscribeRequest, SubscribeResponse, Stream, LedgerStream, ValidationStream, TransactionStream, PathFindStream, PeerStatusStream, OrderBookStream, ConsensusStream, UnsubscribeRequest, UnsubscribeResponse, FeeRequest, FeeResponse, ManifestRequest, ManifestResponse, ServerInfoRequest, ServerInfoResponse, ServerStateRequest, ServerStateResponse, PingRequest, PingResponse, RandomRequest, RandomResponse, ErrorResponse, NFTBuyOffersRequest, NFTBuyOffersResponse, NFTSellOffersRequest, NFTSellOffersResponse, }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { Amount } from '../common'; | ||
import { NFTOffer } from '../common'; | ||
import { BaseRequest, BaseResponse } from './baseMethod'; | ||
@@ -7,17 +7,8 @@ export interface NFTBuyOffersRequest extends BaseRequest { | ||
} | ||
interface NFTBuyOffer { | ||
amount: Amount; | ||
destination: string; | ||
expiration: number; | ||
flags: number; | ||
index: string; | ||
owner: string; | ||
} | ||
export interface NFTBuyOffersResponse extends BaseResponse { | ||
result: { | ||
offers: NFTBuyOffer[]; | ||
offers: NFTOffer[]; | ||
tokenid: string; | ||
}; | ||
} | ||
export {}; | ||
//# sourceMappingURL=nftBuyOffers.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { Amount } from '../common'; | ||
import { NFTOffer } from '../common'; | ||
import { BaseRequest, BaseResponse } from './baseMethod'; | ||
@@ -7,17 +7,8 @@ export interface NFTSellOffersRequest extends BaseRequest { | ||
} | ||
interface NFTSellOffer { | ||
amount: Amount; | ||
destination: string; | ||
expiration: number; | ||
flags: number; | ||
index: string; | ||
owner: string; | ||
} | ||
export interface NFTSellOffersResponse extends BaseResponse { | ||
result: { | ||
offers: NFTSellOffer[]; | ||
offers: NFTOffer[]; | ||
tokenid: string; | ||
}; | ||
} | ||
export {}; | ||
//# sourceMappingURL=nftSellOffers.d.ts.map |
@@ -7,3 +7,3 @@ import { Amount, Path } from '../common'; | ||
} | ||
interface PathFindCreateRequest extends BasePathFindRequest { | ||
export interface PathFindCreateRequest extends BasePathFindRequest { | ||
subcommand: 'create'; | ||
@@ -16,6 +16,6 @@ source_account: string; | ||
} | ||
interface PathFindCloseRequest extends BasePathFindRequest { | ||
export interface PathFindCloseRequest extends BasePathFindRequest { | ||
subcommand: 'close'; | ||
} | ||
interface PathFindStatusRequest extends BasePathFindRequest { | ||
export interface PathFindStatusRequest extends BasePathFindRequest { | ||
subcommand: 'status'; | ||
@@ -22,0 +22,0 @@ } |
@@ -11,3 +11,4 @@ import { BaseTransaction } from './common'; | ||
asfDefaultRipple = 8, | ||
asfDepositAuth = 9 | ||
asfDepositAuth = 9, | ||
asfAuthorizedMinter = 10 | ||
} | ||
@@ -14,0 +15,0 @@ export declare enum AccountSetTfFlags { |
@@ -17,2 +17,3 @@ "use strict"; | ||
AccountSetAsfFlags[AccountSetAsfFlags["asfDepositAuth"] = 9] = "asfDepositAuth"; | ||
AccountSetAsfFlags[AccountSetAsfFlags["asfAuthorizedMinter"] = 10] = "asfAuthorizedMinter"; | ||
})(AccountSetAsfFlags = exports.AccountSetAsfFlags || (exports.AccountSetAsfFlags = {})); | ||
@@ -19,0 +20,0 @@ var AccountSetTfFlags; |
@@ -1,4 +0,4 @@ | ||
import { Memo, Signer } from '../common'; | ||
export declare function isIssuedCurrency(obj: Record<string, unknown>): boolean; | ||
export declare function isAmount(amount: unknown): boolean; | ||
import { Amount, IssuedCurrencyAmount, Memo, Signer } from '../common'; | ||
export declare function isIssuedCurrency(input: unknown): input is IssuedCurrencyAmount; | ||
export declare function isAmount(amount: unknown): amount is Amount; | ||
export interface GlobalFlags { | ||
@@ -22,2 +22,3 @@ } | ||
export declare function validateBaseTransaction(common: Record<string, unknown>): void; | ||
export declare function parseAmountValue(amount: unknown): number; | ||
//# sourceMappingURL=common.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateBaseTransaction = exports.isAmount = exports.isIssuedCurrency = void 0; | ||
exports.parseAmountValue = exports.validateBaseTransaction = exports.isAmount = exports.isIssuedCurrency = void 0; | ||
const ripple_binary_codec_1 = require("ripple-binary-codec"); | ||
const errors_1 = require("../../errors"); | ||
const utils_1 = require("../utils"); | ||
const transactionTypes = [ | ||
'AccountSet', | ||
'AccountDelete', | ||
'CheckCancel', | ||
'CheckCash', | ||
'CheckCreate', | ||
'DepositPreauth', | ||
'EscrowCancel', | ||
'EscrowCreate', | ||
'EscrowFinish', | ||
'OfferCancel', | ||
'OfferCreate', | ||
'Payment', | ||
'PaymentChannelClaim', | ||
'PaymentChannelCreate', | ||
'PaymentChannelFund', | ||
'SetRegularKey', | ||
'SignerListSet', | ||
'TicketCreate', | ||
'TrustSet', | ||
]; | ||
const MEMO_SIZE = 3; | ||
@@ -57,12 +37,15 @@ function isMemo(obj) { | ||
const ISSUED_CURRENCY_SIZE = 3; | ||
function isIssuedCurrency(obj) { | ||
return (Object.keys(obj).length === ISSUED_CURRENCY_SIZE && | ||
typeof obj.value === 'string' && | ||
typeof obj.issuer === 'string' && | ||
typeof obj.currency === 'string'); | ||
function isRecord(value) { | ||
return value !== null && typeof value === 'object'; | ||
} | ||
function isIssuedCurrency(input) { | ||
return (isRecord(input) && | ||
Object.keys(input).length === ISSUED_CURRENCY_SIZE && | ||
typeof input.value === 'string' && | ||
typeof input.issuer === 'string' && | ||
typeof input.currency === 'string'); | ||
} | ||
exports.isIssuedCurrency = isIssuedCurrency; | ||
function isAmount(amount) { | ||
return (typeof amount === 'string' || | ||
isIssuedCurrency(amount)); | ||
return typeof amount === 'string' || isIssuedCurrency(amount); | ||
} | ||
@@ -83,3 +66,3 @@ exports.isAmount = isAmount; | ||
} | ||
if (!transactionTypes.includes(common.TransactionType)) { | ||
if (!ripple_binary_codec_1.TRANSACTION_TYPES.includes(common.TransactionType)) { | ||
throw new errors_1.ValidationError('BaseTransaction: Unknown TransactionType'); | ||
@@ -127,2 +110,12 @@ } | ||
exports.validateBaseTransaction = validateBaseTransaction; | ||
function parseAmountValue(amount) { | ||
if (!isAmount(amount)) { | ||
return NaN; | ||
} | ||
if (typeof amount === 'string') { | ||
return parseFloat(amount); | ||
} | ||
return parseFloat(amount.value); | ||
} | ||
exports.parseAmountValue = parseAmountValue; | ||
//# sourceMappingURL=common.js.map |
@@ -6,11 +6,24 @@ "use strict"; | ||
const common_1 = require("./common"); | ||
function validateBrokerFee(tx) { | ||
const value = (0, common_1.parseAmountValue)(tx.BrokerFee); | ||
if (Number.isNaN(value)) { | ||
throw new errors_1.ValidationError('NFTokenAcceptOffer: invalid BrokerFee'); | ||
} | ||
if (value <= 0) { | ||
throw new errors_1.ValidationError('NFTokenAcceptOffer: BrokerFee must be greater than 0; omit if there is no fee'); | ||
} | ||
if (tx.SellOffer == null || tx.BuyOffer == null) { | ||
throw new errors_1.ValidationError('NFTokenAcceptOffer: both SellOffer and BuyOffer must be set if using brokered mode'); | ||
} | ||
} | ||
function validateNFTokenAcceptOffer(tx) { | ||
(0, common_1.validateBaseTransaction)(tx); | ||
if (tx.BrokerFee != null && | ||
typeof tx.BrokerFee !== 'string' && | ||
!(0, common_1.isAmount)(tx.BrokerFee)) { | ||
throw new errors_1.ValidationError('NFTokenAcceptOffer: invalid BrokerFee'); | ||
if (tx.BrokerFee != null) { | ||
validateBrokerFee(tx); | ||
} | ||
if (tx.SellOffer == null && tx.BuyOffer == null) { | ||
throw new errors_1.ValidationError('NFTokenAcceptOffer: must set either SellOffer or BuyOffer'); | ||
} | ||
} | ||
exports.validateNFTokenAcceptOffer = validateNFTokenAcceptOffer; | ||
//# sourceMappingURL=NFTokenAcceptOffer.js.map |
@@ -8,5 +8,2 @@ "use strict"; | ||
(0, common_1.validateBaseTransaction)(tx); | ||
if (tx.Account == null) { | ||
throw new errors_1.ValidationError('NFTokenBurn: missing field Account'); | ||
} | ||
if (tx.TokenID == null) { | ||
@@ -13,0 +10,0 @@ throw new errors_1.ValidationError('NFTokenBurn: missing field TokenID'); |
import { BaseTransaction } from './common'; | ||
export interface NFTokenCancelOffer extends BaseTransaction { | ||
TransactionType: 'NFTokenCancelOffer'; | ||
TokenIDs: string[]; | ||
TokenOffers: string[]; | ||
} | ||
export declare function validateNFTokenCancelOffer(tx: Record<string, unknown>): void; | ||
//# sourceMappingURL=NFTokenCancelOffer.d.ts.map |
@@ -8,7 +8,10 @@ "use strict"; | ||
(0, common_1.validateBaseTransaction)(tx); | ||
if (!Array.isArray(tx.TokenIDs) || tx.TokenIDs.length < 1) { | ||
throw new errors_1.ValidationError('NFTokenCancelOffer: missing field TokenIDs'); | ||
if (!Array.isArray(tx.TokenOffers)) { | ||
throw new errors_1.ValidationError('NFTokenCancelOffer: missing field TokenOffers'); | ||
} | ||
if (tx.TokenOffers.length < 1) { | ||
throw new errors_1.ValidationError('NFTokenCancelOffer: empty field TokenOffers'); | ||
} | ||
} | ||
exports.validateNFTokenCancelOffer = validateNFTokenCancelOffer; | ||
//# sourceMappingURL=NFTokenCancelOffer.js.map |
@@ -11,3 +11,2 @@ import { Amount } from '../common'; | ||
TransactionType: 'NFTokenCreateOffer'; | ||
Account: string; | ||
TokenID: string; | ||
@@ -14,0 +13,0 @@ Amount: Amount; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const errors_1 = require("../../errors"); | ||
const utils_1 = require("../utils"); | ||
const common_1 = require("./common"); | ||
@@ -11,18 +12,38 @@ var NFTokenCreateOfferFlags; | ||
})(NFTokenCreateOfferFlags = exports.NFTokenCreateOfferFlags || (exports.NFTokenCreateOfferFlags = {})); | ||
function validateSellOfferCases(tx) { | ||
if (tx.Owner != null) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: Owner must not be present for sell offers'); | ||
} | ||
} | ||
function validateBuyOfferCases(tx) { | ||
if (tx.Owner == null) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: Owner must be present for buy offers'); | ||
} | ||
if ((0, common_1.parseAmountValue)(tx.Amount) <= 0) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: Amount must be greater than 0 for buy offers'); | ||
} | ||
} | ||
function validateNFTokenCreateOffer(tx) { | ||
(0, common_1.validateBaseTransaction)(tx); | ||
if (tx.Account == null) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: missing field Account'); | ||
if (tx.Account === tx.Owner) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: Owner and Account must not be equal'); | ||
} | ||
if (tx.Account === tx.Destination) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: Destination and Account must not be equal'); | ||
} | ||
if (tx.TokenID == null) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: missing field TokenID'); | ||
} | ||
if (tx.Amount == null) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: missing field Amount'); | ||
} | ||
if (typeof tx.Amount !== 'string' && !(0, common_1.isAmount)(tx.Amount)) { | ||
if (!(0, common_1.isAmount)(tx.Amount)) { | ||
throw new errors_1.ValidationError('NFTokenCreateOffer: invalid Amount'); | ||
} | ||
if (typeof tx.Flags === 'number' && | ||
(0, utils_1.isFlagEnabled)(tx.Flags, NFTokenCreateOfferFlags.tfSellToken)) { | ||
validateSellOfferCases(tx); | ||
} | ||
else { | ||
validateBuyOfferCases(tx); | ||
} | ||
} | ||
exports.validateNFTokenCreateOffer = validateNFTokenCreateOffer; | ||
//# sourceMappingURL=NFTokenCreateOffer.js.map |
@@ -15,4 +15,4 @@ "use strict"; | ||
(0, common_1.validateBaseTransaction)(tx); | ||
if (tx.Account == null) { | ||
throw new errors_1.ValidationError('NFTokenMint: missing field Account'); | ||
if (tx.Account === tx.Issuer) { | ||
throw new errors_1.ValidationError('NFTokenMint: Issuer must not be equal to Account'); | ||
} | ||
@@ -19,0 +19,0 @@ if (tx.TokenTaxon == null) { |
import type { Client } from '..'; | ||
import { LedgerIndex } from '../models/common'; | ||
interface Balance { | ||
value: string; | ||
currency: string; | ||
issuer?: string; | ||
} | ||
interface GetXrpBalanceOptions { | ||
declare function getXrpBalance(this: Client, address: string, options?: { | ||
ledger_hash?: string; | ||
ledger_index?: LedgerIndex; | ||
} | ||
interface GetBalancesOptions { | ||
}): Promise<string>; | ||
declare function getBalances(this: Client, address: string, options?: { | ||
ledger_hash?: string; | ||
@@ -17,6 +12,8 @@ ledger_index?: LedgerIndex; | ||
limit?: number; | ||
} | ||
declare function getXrpBalance(this: Client, address: string, options?: GetXrpBalanceOptions): Promise<string>; | ||
declare function getBalances(this: Client, address: string, options?: GetBalancesOptions): Promise<Balance[]>; | ||
}): Promise<Array<{ | ||
value: string; | ||
currency: string; | ||
issuer?: string | undefined; | ||
}>>; | ||
export { getXrpBalance, getBalances }; | ||
//# sourceMappingURL=balances.d.ts.map |
import type { Client } from '../client'; | ||
import { LedgerIndex } from '../models/common'; | ||
import { BookOffer, TakerAmount } from '../models/methods/bookOffers'; | ||
interface Orderbook { | ||
buy: BookOffer[]; | ||
sell: BookOffer[]; | ||
} | ||
interface OrderbookOptions { | ||
declare function getOrderbook(this: Client, takerPays: TakerAmount, takerGets: TakerAmount, options?: { | ||
limit?: number; | ||
@@ -13,5 +9,7 @@ ledger_index?: LedgerIndex; | ||
taker?: string; | ||
} | ||
declare function getOrderbook(this: Client, takerPays: TakerAmount, takerGets: TakerAmount, options?: OrderbookOptions): Promise<Orderbook>; | ||
}): Promise<{ | ||
buy: BookOffer[]; | ||
sell: BookOffer[]; | ||
}>; | ||
export default getOrderbook; | ||
//# sourceMappingURL=getOrderbook.d.ts.map |
import type { Client, SubmitResponse, Wallet } from '..'; | ||
import { TxResponse } from '../models/methods'; | ||
import { Transaction } from '../models/transactions'; | ||
interface SubmitOptions { | ||
declare function submit(this: Client, transaction: Transaction | string, opts?: { | ||
autofill?: boolean; | ||
failHard?: boolean; | ||
wallet?: Wallet; | ||
} | ||
declare function submit(this: Client, transaction: Transaction | string, opts?: SubmitOptions): Promise<SubmitResponse>; | ||
declare function submitAndWait(this: Client, transaction: Transaction | string, opts?: SubmitOptions): Promise<TxResponse>; | ||
}): Promise<SubmitResponse>; | ||
declare function submitAndWait(this: Client, transaction: Transaction | string, opts?: { | ||
autofill?: boolean; | ||
failHard?: boolean; | ||
wallet?: Wallet; | ||
}): Promise<TxResponse>; | ||
export { submit, submitAndWait }; | ||
//# sourceMappingURL=submit.d.ts.map |
@@ -85,3 +85,3 @@ "use strict"; | ||
} | ||
function getSignedTx(client, transaction, { autofill = true, wallet } = {}) { | ||
function getSignedTx(client, transaction, { autofill = true, wallet, } = {}) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -88,0 +88,0 @@ if (isSigned(transaction)) { |
import { deriveKeypair } from 'ripple-keypairs'; | ||
interface DeriveOptions { | ||
declare function deriveXAddress(options: { | ||
publicKey: string; | ||
tag: number | false; | ||
test: boolean; | ||
} | ||
declare function deriveXAddress(options: DeriveOptions): string; | ||
}): string; | ||
export { deriveKeypair, deriveXAddress }; | ||
//# sourceMappingURL=derive.d.ts.map |
import { TransactionMetadata } from '../models/transactions/metadata'; | ||
interface Balance { | ||
currency: string; | ||
issuer?: string; | ||
value: string; | ||
} | ||
interface BalanceChanges { | ||
export default function getBalanceChanges(metadata: TransactionMetadata): Array<{ | ||
account: string; | ||
balances: Balance[]; | ||
} | ||
export default function getBalanceChanges(metadata: TransactionMetadata): BalanceChanges[]; | ||
export {}; | ||
balances: Array<{ | ||
currency: string; | ||
issuer?: string; | ||
value: string; | ||
}>; | ||
}>; | ||
//# sourceMappingURL=getBalanceChanges.d.ts.map |
import type { Ledger } from '../../models/ledger'; | ||
import { LedgerEntry } from '../../models/ledger'; | ||
import { Transaction, TransactionMetadata } from '../../models/transactions'; | ||
interface HashLedgerHeaderOptions { | ||
computeTreeHashes?: boolean; | ||
} | ||
export declare function hashSignedTx(tx: Transaction | string): string; | ||
@@ -13,4 +10,6 @@ export declare function hashLedgerHeader(ledgerHeader: Ledger): string; | ||
export declare function hashStateTree(entries: LedgerEntry[]): string; | ||
declare function hashLedger(ledger: Ledger, options?: HashLedgerHeaderOptions): string; | ||
declare function hashLedger(ledger: Ledger, options?: { | ||
computeTreeHashes?: boolean; | ||
}): string; | ||
export default hashLedger; | ||
//# sourceMappingURL=hashLedger.d.ts.map |
import type { Client } from '..'; | ||
import Wallet from '.'; | ||
interface WalletWithStartingBalance { | ||
wallet: Wallet; | ||
balance: number; | ||
} | ||
declare enum FaucetNetwork { | ||
@@ -11,3 +7,6 @@ Testnet = "faucet.altnet.rippletest.net", | ||
} | ||
declare function fundWallet(this: Client, wallet?: Wallet): Promise<WalletWithStartingBalance>; | ||
declare function fundWallet(this: Client, wallet?: Wallet): Promise<{ | ||
wallet: Wallet; | ||
balance: number; | ||
}>; | ||
declare function getFaucetUrl(client: Client): FaucetNetwork | undefined; | ||
@@ -14,0 +13,0 @@ export default fundWallet; |
import ECDSA from '../ECDSA'; | ||
import { Transaction } from '../models/transactions'; | ||
interface SignedTxBlobHash { | ||
tx_blob: string; | ||
hash: string; | ||
} | ||
interface WalletBaseOptions { | ||
masterAddress?: string; | ||
} | ||
interface WalletOptions extends WalletBaseOptions { | ||
seed?: string; | ||
} | ||
interface DeriveWalletOptions extends WalletBaseOptions { | ||
algorithm?: ECDSA; | ||
} | ||
interface FromMnemonicOptions extends WalletBaseOptions { | ||
derivationPath?: string; | ||
} | ||
declare class Wallet { | ||
@@ -25,10 +9,25 @@ readonly publicKey: string; | ||
get address(): string; | ||
constructor(publicKey: string, privateKey: string, opts?: WalletOptions); | ||
constructor(publicKey: string, privateKey: string, opts?: { | ||
masterAddress?: string; | ||
seed?: string; | ||
}); | ||
static generate(algorithm?: ECDSA): Wallet; | ||
static fromSeed(seed: string, opts?: DeriveWalletOptions): Wallet; | ||
static fromSeed(seed: string, opts?: { | ||
masterAddress?: string; | ||
algorithm?: ECDSA; | ||
}): Wallet; | ||
static fromSecret: typeof Wallet.fromSeed; | ||
static fromMnemonic(mnemonic: string, opts?: FromMnemonicOptions): Wallet; | ||
static fromEntropy(entropy: Uint8Array | number[], opts?: DeriveWalletOptions): Wallet; | ||
static fromMnemonic(mnemonic: string, opts?: { | ||
masterAddress?: string; | ||
derivationPath?: string; | ||
}): Wallet; | ||
static fromEntropy(entropy: Uint8Array | number[], opts?: { | ||
masterAddress?: string; | ||
algorithm?: ECDSA; | ||
}): Wallet; | ||
private static deriveWallet; | ||
sign(this: Wallet, transaction: Transaction, multisign?: boolean | string): SignedTxBlobHash; | ||
sign(this: Wallet, transaction: Transaction, multisign?: boolean | string): { | ||
tx_blob: string; | ||
hash: string; | ||
}; | ||
verifyTransaction(signedTransaction: string): boolean; | ||
@@ -35,0 +34,0 @@ getXAddress(tag?: number | false, isTestnet?: boolean): string; |
{ | ||
"name": "xrpl", | ||
"version": "2.1.0-beta.1", | ||
"version": "2.1.0", | ||
"license": "ISC", | ||
@@ -27,56 +27,13 @@ "description": "A TypeScript/JavaScript API for interacting with the XRP Ledger in Node.js and the browser", | ||
"lodash": "^4.17.4", | ||
"ripple-address-codec": "^4.1.1", | ||
"ripple-binary-codec": "^1.2.0-beta.1", | ||
"ripple-keypairs": "^1.0.3", | ||
"ripple-address-codec": "^4.2.3", | ||
"ripple-binary-codec": "^1.3.0", | ||
"ripple-keypairs": "^1.1.3", | ||
"ws": "^8.2.2" | ||
}, | ||
"devDependencies": { | ||
"xrpl-local": "file:./src" | ||
}, | ||
"resolutions": { | ||
"elliptic": "^6.5.4" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.21", | ||
"@types/lodash": "^4.14.136", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.4.3", | ||
"@types/puppeteer": "5.4.4", | ||
"@types/ws": "^8.2.0", | ||
"@typescript-eslint/eslint-plugin": "^4.30.0", | ||
"@typescript-eslint/parser": "^4.0.0", | ||
"@xrplf/eslint-config": "^1.5.0", | ||
"@xrplf/prettier-config": "^1.5.0", | ||
"assert": "^2.0.0", | ||
"buffer": "^6.0.2", | ||
"chai": "^4.3.4", | ||
"crypto-browserify": "^3.12.0", | ||
"ejs": "^3.0.1", | ||
"eslint": "^7.5.0", | ||
"eslint-plugin-array-func": "^3.1.7", | ||
"eslint-plugin-consistent-default-export-name": "^0.0.13", | ||
"eslint-plugin-eslint-comments": "^3.2.0", | ||
"eslint-plugin-import": "^2.24.1", | ||
"eslint-plugin-jsdoc": "^36.0.0", | ||
"eslint-plugin-mocha": "^9.0.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-tsdoc": "^0.2.14", | ||
"eventemitter2": "^6.0.0", | ||
"https-browserify": "^1.0.0", | ||
"mocha": "^9", | ||
"npm-run-all": "^4.1.5", | ||
"nyc": "^15", | ||
"path-browserify": "1.0.1", | ||
"prettier": "^2.3.2", | ||
"process": "^0.11.10", | ||
"puppeteer": "10.4.0", | ||
"stream-browserify": "^3.0.0", | ||
"stream-http": "3.2.0", | ||
"ts-loader": "^9.2.5", | ||
"ts-node": "^10.2.1", | ||
"typedoc": "^0.22.5", | ||
"typescript": "^4.4.2", | ||
"url": "^0.11.0", | ||
"webpack": "^5.6.0", | ||
"webpack-bundle-analyzer": "^4.1.0", | ||
"webpack-cli": "^4.2.0" | ||
}, | ||
"scripts": { | ||
@@ -91,3 +48,3 @@ "build": "run-s build:lib build:snippets build:web", | ||
"clean": "rm -rf dist", | ||
"docgen": "typedoc && echo js.xrpl.org >> ./docs/CNAME", | ||
"docgen": "typedoc && echo js.xrpl.org >> ../../docs/CNAME", | ||
"prepublish": "run-s clean build", | ||
@@ -112,5 +69,5 @@ "test": "nyc mocha --config=test/.mocharc.json --exit", | ||
"engines": { | ||
"node": ">=10.13.0", | ||
"npm": ">=7.14.0 <8.0.0" | ||
} | ||
"node": ">=10.13.0" | ||
}, | ||
"gitHead": "388c4a6124af2f5de12c3ce4e0dc0882d6f7cb65" | ||
} |
143
README.md
# xrpl.js | ||
A JavaScript/TypeScript library for interacting with the XRP Ledger | ||
This package includes the `xrpl` library. This repository uses a monorepo | ||
layout. Please find the README for `xrpl` [here](https://github.com/XRPLF/xrpl.js/tree/main/README.md). | ||
[![NPM](https://nodei.co/npm/xrpl.png)](https://www.npmjs.org/package/xrpl) | ||
![npm bundle size](https://img.shields.io/bundlephobia/min/xrpl) | ||
This is the recommended library for integrating a JavaScript/TypeScript app with the XRP Ledger, especially if you intend to use advanced functionality such as IOUs, payment paths, the decentralized exchange, account settings, payment channels, escrows, multi-signing, and more. | ||
## [➡️ Reference Documentation](http://js.xrpl.org) | ||
See the full reference documentation for all classes, methods, and utilities. | ||
## [➡️ Applications and Projects](https://github.com/XRPLF/xrpl.js/blob/master/APPLICATIONS.md) | ||
What is `xrpl.js` used for? The applications on the list linked above use `xrpl.js`. Open a PR to add your app or project to the list! | ||
### Features | ||
+ Works in Node.js and in web browsers | ||
+ Helpers for creating requests and parsing responses for the [XRP Ledger APIs](https://xrpl.org/rippled-api.html) | ||
+ Listen to events on the XRP Ledger (transactions, ledger, validations, etc.) | ||
+ Sign and submit transactions to the XRP Ledger | ||
+ Type definitions for TypeScript | ||
### Requirements | ||
+ **[Node.js v14](https://nodejs.org/)** is recommended. We also support v12 and v16. Other versions may work but are not frequently tested. | ||
+ **[npm](https://www.npmjs.com/)** is recommended. `yarn` may work but we use `package-lock.json`. | ||
## Getting Started | ||
In an existing project (with `package.json`), install `xrpl.js`: | ||
``` | ||
$ npm install xrpl | ||
``` | ||
Example usage: | ||
```js | ||
const xrpl = require("xrpl") | ||
async function main() { | ||
const client = new xrpl.Client("https://s.altnet.rippletest.net:51234/") | ||
await client.connect() | ||
const response = await client.request({ | ||
"command": "account_info", | ||
"account": "rPT1Sjq2YGrBMTttX4GZHjKu9dyfzbpAYe", | ||
"ledger_index": "validated" | ||
}) | ||
console.log(response) | ||
client.disconnect() | ||
} | ||
main() | ||
``` | ||
For more examples, see the [documentation](#documentation). | ||
### Using xrpl.js with React Native | ||
If you want to use `xrpl.js` with React Native you will need to install shims for core NodeJS modules. To help with this you can use a module like [rn-nodeify](https://github.com/tradle/rn-nodeify). | ||
1. Install dependencies (you can use `yarn` as well): | ||
```shell | ||
npm install react-native-crypto | ||
npm install xrpl | ||
# install peer deps | ||
npm install react-native-randombytes | ||
# install latest rn-nodeify | ||
npm install rn-nodeify@latest --dev | ||
``` | ||
2. After that, run the following command: | ||
```shell | ||
# install node core shims and recursively hack package.json files | ||
# in ./node_modules to add/update the "browser"/"react-native" field with relevant mappings | ||
./node_modules/.bin/rn-nodeify --hack --install | ||
``` | ||
3. Enable `crypto`: | ||
`rn-nodeify` will create a `shim.js` file in the project root directory. | ||
Open it and uncomment the line that requires the crypto module: | ||
```javascript | ||
// If using the crypto shim, uncomment the following line to ensure | ||
// crypto is loaded first, so it can populate global.crypto | ||
require('crypto') | ||
``` | ||
4. Import `shim` in your project (it must be the first line): | ||
```javascript | ||
import './shim' | ||
... | ||
``` | ||
### Using xrpl.js with Deno | ||
Until official support for [Deno](https://deno.land) is added, you can use the following work-around to use `xrpl.js` with Deno: | ||
```javascript | ||
import xrpl from 'https://dev.jspm.io/npm:xrpl'; | ||
(async () => { | ||
const api = new (xrpl as any).Client('wss://s.altnet.rippletest.net:51233'); | ||
const address = 'rH8NxV12EuV...khfJ5uw9kT'; | ||
api.connect().then(() => { | ||
api.getBalances(address).then((balances: any) => { | ||
console.log(JSON.stringify(balances, null, 2)); | ||
}); | ||
}); | ||
})(); | ||
``` | ||
## Documentation | ||
+ [Get Started in Node.js](https://xrpl.org/get-started-using-node-js.html) | ||
+ [Full Reference Documentation](https://js.xrpl.org) | ||
+ [Code Samples](https://github.com/XRPLF/xrpl.js/tree/develop/snippets/src) | ||
### Mailing Lists | ||
We have a low-traffic mailing list for announcements of new `xrpl.js` releases. (About 1 email per week) | ||
+ [Subscribe to xrpl-announce](https://groups.google.com/g/xrpl-announce) | ||
If you're using the XRP Ledger in production, you should run a [rippled server](https://github.com/ripple/rippled) and subscribe to the ripple-server mailing list as well. | ||
+ [Subscribe to ripple-server](https://groups.google.com/g/ripple-server) | ||
## More Information | ||
+ [xrpl-announce mailing list](https://groups.google.com/g/xrpl-announce) - subscribe for release announcements | ||
+ [xrpl.js API Reference](https://js.xrpl.org) | ||
+ [XRP Ledger Dev Portal](https://xrpl.org) | ||
READMEs for other packages in this monorepo are located at the root of their | ||
package, but since newcomers to XRPL are likely to want to use the `xrpl` | ||
package this README is at the root of the project. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
3822886
1
533
16722
1
2
9
Updatedripple-address-codec@^4.2.3
Updatedripple-binary-codec@^1.3.0
Updatedripple-keypairs@^1.1.3