init
This commit is contained in:
+6
@@ -0,0 +1,6 @@
|
||||
declare enum ECDSA {
|
||||
ed25519 = "ed25519",
|
||||
secp256k1 = "ecdsa-secp256k1"
|
||||
}
|
||||
export default ECDSA;
|
||||
//# sourceMappingURL=ECDSA.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ECDSA.d.ts","sourceRoot":"","sources":["../../src/ECDSA.ts"],"names":[],"mappings":"AAAA,aAAK,KAAK;IACR,OAAO,YAAY;IACnB,SAAS,oBAAoB;CAC9B;AAED,eAAe,KAAK,CAAA"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var ECDSA;
|
||||
(function (ECDSA) {
|
||||
ECDSA["ed25519"] = "ed25519";
|
||||
ECDSA["secp256k1"] = "ecdsa-secp256k1";
|
||||
})(ECDSA || (ECDSA = {}));
|
||||
exports.default = ECDSA;
|
||||
//# sourceMappingURL=ECDSA.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ECDSA.js","sourceRoot":"","sources":["../../src/ECDSA.ts"],"names":[],"mappings":";;AAAA,IAAK,KAGJ;AAHD,WAAK,KAAK;IACR,4BAAmB,CAAA;IACnB,sCAA6B,CAAA;AAC/B,CAAC,EAHI,KAAK,KAAL,KAAK,QAGT;AAED,kBAAe,KAAK,CAAA"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
import type { Client } from '../client';
|
||||
export interface FaucetWallet {
|
||||
account: {
|
||||
xAddress: string;
|
||||
classicAddress?: string;
|
||||
secret: string;
|
||||
};
|
||||
amount: number;
|
||||
balance: number;
|
||||
}
|
||||
export declare enum FaucetNetwork {
|
||||
Testnet = "faucet.altnet.rippletest.net",
|
||||
Devnet = "faucet.devnet.rippletest.net",
|
||||
AMMDevnet = "ammfaucet.devnet.rippletest.net",
|
||||
HooksV2Testnet = "hooks-testnet-v2.xrpl-labs.com"
|
||||
}
|
||||
export declare const FaucetNetworkPaths: Record<string, string>;
|
||||
export declare function getFaucetHost(client: Client): FaucetNetwork | undefined;
|
||||
export declare function getDefaultFaucetPath(hostname: string | undefined): string;
|
||||
//# sourceMappingURL=defaultFaucets.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultFaucets.d.ts","sourceRoot":"","sources":["../../../src/Wallet/defaultFaucets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAGvC,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE;QACP,QAAQ,EAAE,MAAM,CAAA;QAChB,cAAc,CAAC,EAAE,MAAM,CAAA;QACvB,MAAM,EAAE,MAAM,CAAA;KACf,CAAA;IACD,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,oBAAY,aAAa;IACvB,OAAO,iCAAiC;IACxC,MAAM,iCAAiC;IACvC,SAAS,oCAAoC;IAC7C,cAAc,mCAAmC;CAClD;AAED,eAAO,MAAM,kBAAkB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKrD,CAAA;AASD,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAqBvE;AASD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKzE"}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDefaultFaucetPath = exports.getFaucetHost = exports.FaucetNetworkPaths = exports.FaucetNetwork = void 0;
|
||||
const errors_1 = require("../errors");
|
||||
var FaucetNetwork;
|
||||
(function (FaucetNetwork) {
|
||||
FaucetNetwork["Testnet"] = "faucet.altnet.rippletest.net";
|
||||
FaucetNetwork["Devnet"] = "faucet.devnet.rippletest.net";
|
||||
FaucetNetwork["AMMDevnet"] = "ammfaucet.devnet.rippletest.net";
|
||||
FaucetNetwork["HooksV2Testnet"] = "hooks-testnet-v2.xrpl-labs.com";
|
||||
})(FaucetNetwork = exports.FaucetNetwork || (exports.FaucetNetwork = {}));
|
||||
exports.FaucetNetworkPaths = {
|
||||
[FaucetNetwork.Testnet]: '/accounts',
|
||||
[FaucetNetwork.Devnet]: '/accounts',
|
||||
[FaucetNetwork.AMMDevnet]: '/accounts',
|
||||
[FaucetNetwork.HooksV2Testnet]: '/accounts',
|
||||
};
|
||||
function getFaucetHost(client) {
|
||||
const connectionUrl = client.url;
|
||||
if (connectionUrl.includes('hooks-testnet-v2')) {
|
||||
return FaucetNetwork.HooksV2Testnet;
|
||||
}
|
||||
if (connectionUrl.includes('altnet') || connectionUrl.includes('testnet')) {
|
||||
return FaucetNetwork.Testnet;
|
||||
}
|
||||
if (connectionUrl.includes('amm')) {
|
||||
return FaucetNetwork.AMMDevnet;
|
||||
}
|
||||
if (connectionUrl.includes('devnet')) {
|
||||
return FaucetNetwork.Devnet;
|
||||
}
|
||||
throw new errors_1.XRPLFaucetError('Faucet URL is not defined or inferrable.');
|
||||
}
|
||||
exports.getFaucetHost = getFaucetHost;
|
||||
function getDefaultFaucetPath(hostname) {
|
||||
if (hostname === undefined) {
|
||||
return '/accounts';
|
||||
}
|
||||
return exports.FaucetNetworkPaths[hostname] || '/accounts';
|
||||
}
|
||||
exports.getDefaultFaucetPath = getDefaultFaucetPath;
|
||||
//# sourceMappingURL=defaultFaucets.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"defaultFaucets.js","sourceRoot":"","sources":["../../../src/Wallet/defaultFaucets.ts"],"names":[],"mappings":";;;AACA,sCAA2C;AAY3C,IAAY,aAKX;AALD,WAAY,aAAa;IACvB,yDAAwC,CAAA;IACxC,wDAAuC,CAAA;IACvC,8DAA6C,CAAA;IAC7C,kEAAiD,CAAA;AACnD,CAAC,EALW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAKxB;AAEY,QAAA,kBAAkB,GAA2B;IACxD,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,WAAW;IACpC,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,WAAW;IACnC,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,WAAW;IACtC,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,WAAW;CAC5C,CAAA;AASD,SAAgB,aAAa,CAAC,MAAc;IAC1C,MAAM,aAAa,GAAG,MAAM,CAAC,GAAG,CAAA;IAEhC,IAAI,aAAa,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE;QAC9C,OAAO,aAAa,CAAC,cAAc,CAAA;KACpC;IAGD,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QACzE,OAAO,aAAa,CAAC,OAAO,CAAA;KAC7B;IAED,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE;QACjC,OAAO,aAAa,CAAC,SAAS,CAAA;KAC/B;IAED,IAAI,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;QACpC,OAAO,aAAa,CAAC,MAAM,CAAA;KAC5B;IAED,MAAM,IAAI,wBAAe,CAAC,0CAA0C,CAAC,CAAA;AACvE,CAAC;AArBD,sCAqBC;AASD,SAAgB,oBAAoB,CAAC,QAA4B;IAC/D,IAAI,QAAQ,KAAK,SAAS,EAAE;QAC1B,OAAO,WAAW,CAAA;KACnB;IACD,OAAO,0BAAkB,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAA;AACpD,CAAC;AALD,oDAKC"}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
import type { Client } from '../client';
|
||||
import Wallet from '.';
|
||||
declare function fundWallet(this: Client, wallet?: Wallet | null, options?: {
|
||||
faucetHost?: string;
|
||||
faucetPath?: string;
|
||||
amount?: string;
|
||||
}): Promise<{
|
||||
wallet: Wallet;
|
||||
balance: number;
|
||||
}>;
|
||||
export default fundWallet;
|
||||
//# sourceMappingURL=fundWallet.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fundWallet.d.ts","sourceRoot":"","sources":["../../../src/Wallet/fundWallet.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AASvC,OAAO,MAAM,MAAM,GAAG,CAAA;AAsCtB,iBAAe,UAAU,CACvB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EACtB,OAAO,CAAC,EAAE;IACR,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB,GACA,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAC,CA0CD;AAuMD,eAAe,UAAU,CAAA"}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const https_1 = require("https");
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const errors_1 = require("../errors");
|
||||
const defaultFaucets_1 = require("./defaultFaucets");
|
||||
const _1 = __importDefault(require("."));
|
||||
const INTERVAL_SECONDS = 1;
|
||||
const MAX_ATTEMPTS = 20;
|
||||
function fundWallet(wallet, options) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!this.isConnected()) {
|
||||
throw new errors_1.RippledError('Client not connected, cannot call faucet');
|
||||
}
|
||||
const walletToFund = wallet && (0, ripple_address_codec_1.isValidClassicAddress)(wallet.classicAddress)
|
||||
? wallet
|
||||
: _1.default.generate();
|
||||
const postBody = Buffer.from(new TextEncoder().encode(JSON.stringify({
|
||||
destination: walletToFund.classicAddress,
|
||||
xrpAmount: options === null || options === void 0 ? void 0 : options.amount,
|
||||
})));
|
||||
let startingBalance = 0;
|
||||
try {
|
||||
startingBalance = Number(yield this.getXrpBalance(walletToFund.classicAddress));
|
||||
}
|
||||
catch (_a) {
|
||||
}
|
||||
const httpOptions = getHTTPOptions(this, postBody, {
|
||||
hostname: options === null || options === void 0 ? void 0 : options.faucetHost,
|
||||
pathname: options === null || options === void 0 ? void 0 : options.faucetPath,
|
||||
});
|
||||
return returnPromise(httpOptions, this, startingBalance, walletToFund, postBody);
|
||||
});
|
||||
}
|
||||
function returnPromise(options, client, startingBalance, walletToFund, postBody) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
const request = (0, https_1.request)(options, (response) => {
|
||||
const chunks = [];
|
||||
response.on('data', (data) => chunks.push(data));
|
||||
response.on('end', () => __awaiter(this, void 0, void 0, function* () {
|
||||
return onEnd(response, chunks, client, startingBalance, walletToFund, resolve, reject);
|
||||
}));
|
||||
});
|
||||
request.write(postBody);
|
||||
request.on('error', (error) => {
|
||||
reject(error);
|
||||
});
|
||||
request.end();
|
||||
});
|
||||
});
|
||||
}
|
||||
function getHTTPOptions(client, postBody, options) {
|
||||
var _a, _b;
|
||||
const finalHostname = (_a = options === null || options === void 0 ? void 0 : options.hostname) !== null && _a !== void 0 ? _a : (0, defaultFaucets_1.getFaucetHost)(client);
|
||||
const finalPathname = (_b = options === null || options === void 0 ? void 0 : options.pathname) !== null && _b !== void 0 ? _b : (0, defaultFaucets_1.getDefaultFaucetPath)(finalHostname);
|
||||
return {
|
||||
hostname: finalHostname,
|
||||
port: 443,
|
||||
path: finalPathname,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Content-Length': postBody.length,
|
||||
},
|
||||
};
|
||||
}
|
||||
function onEnd(response, chunks, client, startingBalance, walletToFund, resolve, reject) {
|
||||
var _a;
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const body = Buffer.concat(chunks).toString();
|
||||
if ((_a = response.headers['content-type']) === null || _a === void 0 ? void 0 : _a.startsWith('application/json')) {
|
||||
const faucetWallet = JSON.parse(body);
|
||||
const classicAddress = faucetWallet.account.classicAddress;
|
||||
yield processSuccessfulResponse(client, classicAddress, walletToFund, startingBalance, resolve, reject);
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.XRPLFaucetError(`Content type is not \`application/json\`: ${JSON.stringify({
|
||||
statusCode: response.statusCode,
|
||||
contentType: response.headers['content-type'],
|
||||
body,
|
||||
})}`));
|
||||
}
|
||||
});
|
||||
}
|
||||
function processSuccessfulResponse(client, classicAddress, walletToFund, startingBalance, resolve, reject) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!classicAddress) {
|
||||
reject(new errors_1.XRPLFaucetError(`The faucet account is undefined`));
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const updatedBalance = yield getUpdatedBalance(client, classicAddress, startingBalance);
|
||||
if (updatedBalance > startingBalance) {
|
||||
resolve({
|
||||
wallet: walletToFund,
|
||||
balance: yield getUpdatedBalance(client, walletToFund.classicAddress, startingBalance),
|
||||
});
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.XRPLFaucetError(`Unable to fund address with faucet after waiting ${INTERVAL_SECONDS * MAX_ATTEMPTS} seconds`));
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof Error) {
|
||||
reject(new errors_1.XRPLFaucetError(err.message));
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
function getUpdatedBalance(client, address, originalBalance) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
let attempts = MAX_ATTEMPTS;
|
||||
const interval = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
||||
if (attempts < 0) {
|
||||
clearInterval(interval);
|
||||
resolve(originalBalance);
|
||||
}
|
||||
else {
|
||||
attempts -= 1;
|
||||
}
|
||||
try {
|
||||
let newBalance;
|
||||
try {
|
||||
newBalance = Number(yield client.getXrpBalance(address));
|
||||
}
|
||||
catch (_a) {
|
||||
}
|
||||
if (newBalance > originalBalance) {
|
||||
clearInterval(interval);
|
||||
resolve(newBalance);
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
clearInterval(interval);
|
||||
if (err instanceof Error) {
|
||||
reject(new errors_1.XRPLFaucetError(`Unable to check if the address ${address} balance has increased. Error: ${err.message}`));
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
}), INTERVAL_SECONDS * 1000);
|
||||
});
|
||||
});
|
||||
}
|
||||
exports.default = fundWallet;
|
||||
//# sourceMappingURL=fundWallet.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"fundWallet.js","sourceRoot":"","sources":["../../../src/Wallet/fundWallet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,iCAA+D;AAE/D,+DAA4D;AAG5D,sCAAyD;AAEzD,qDAIyB;AAEzB,yCAAsB;AAGtB,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAE1B,MAAM,YAAY,GAAG,EAAE,CAAA;AAiCvB,SAAe,UAAU,CAEvB,MAAsB,EACtB,OAIC;;QAKD,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE;YACvB,MAAM,IAAI,qBAAY,CAAC,0CAA0C,CAAC,CAAA;SACnE;QAGD,MAAM,YAAY,GAChB,MAAM,IAAI,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ACD,MAAM,CAAC,GAAG,CAAC,CAAA;SACZ;IACH,CAAC;CAAA;AAUD,SAAe,iBAAiB,CAC9B,MAAc,EACd,OAAe,EACf,eAAuB;;QAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,QAAQ,GAAG,YAAY,CAAA;YAE3B,MAAM,QAAQ,GAAG,WAAW,CAAC,GAAS,EAAE;gBACtC,IAAI,QAAQ,GAAG,CAAC,EAAE;oBAChB,aAAa,CAAC,QAAQ,CAAC,CAAA;oBACvB,OAAO,CAAC,eAAe,CAAC,CAAA;iBACzB;qBAAM;oBACL,QAAQ,IAAI,CAAC,CAAA;iBACd;gBAED,IAAI;oBACF,IAAI,UAAU,CAAA;oBACd,IAAI;wBACF,UAAU,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAA;qBACzD;oBAAC,WAAM;qBAEP;oBAED,IAAI,UAAU,GAAG,eAAe,EAAE;wBAChC,aAAa,CAAC,QAAQ,CAAC,CAAA;wBACvB,OAAO,CAAC,UAAU,CAAC,CAAA;qBACpB;iBACF;gBAAC,OAAO,GAAG,EAAE;oBACZ,aAAa,CAAC,QAAQ,CAAC,CAAA;oBACvB,IAAI,GAAG,YAAY,KAAK,EAAE;wBACxB,MAAM,CACJ,IAAI,wBAAe,CACjB,kCAAkC,OAAO,kCAAkC,GAAG,CAAC,OAAO,EAAE,CACzF,CACF,CAAA;qBACF;oBACD,MAAM,CAAC,GAAG,CAAC,CAAA;iBACZ;YACH,CAAC,CAAA,EAAE,gBAAgB,GAAG,IAAI,CAAC,CAAA;QAC7B,CAAC,CAAC,CAAA;IACJ,CAAC;CAAA;AAED,kBAAe,UAAU,CAAA"}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import ECDSA from '../ECDSA';
|
||||
import { Transaction } from '../models/transactions';
|
||||
declare class Wallet {
|
||||
readonly publicKey: string;
|
||||
readonly privateKey: string;
|
||||
readonly classicAddress: string;
|
||||
readonly seed?: string;
|
||||
constructor(publicKey: string, privateKey: string, opts?: {
|
||||
masterAddress?: string;
|
||||
seed?: string;
|
||||
});
|
||||
get address(): string;
|
||||
static generate(algorithm?: ECDSA): Wallet;
|
||||
static fromSeed(seed: string, opts?: {
|
||||
masterAddress?: string;
|
||||
algorithm?: ECDSA;
|
||||
}): Wallet;
|
||||
static fromSecret: typeof Wallet.fromSeed;
|
||||
static fromEntropy(entropy: Uint8Array | number[], opts?: {
|
||||
masterAddress?: string;
|
||||
algorithm?: ECDSA;
|
||||
}): Wallet;
|
||||
static fromMnemonic(mnemonic: string, opts?: {
|
||||
masterAddress?: string;
|
||||
derivationPath?: string;
|
||||
mnemonicEncoding?: 'bip39' | 'rfc1751';
|
||||
algorithm?: ECDSA;
|
||||
}): Wallet;
|
||||
private static fromRFC1751Mnemonic;
|
||||
private static deriveWallet;
|
||||
sign(this: Wallet, transaction: Transaction, multisign?: boolean | string): {
|
||||
tx_blob: string;
|
||||
hash: string;
|
||||
};
|
||||
verifyTransaction(signedTransaction: Transaction | string): boolean;
|
||||
getXAddress(tag?: number | false, isTestnet?: boolean): string;
|
||||
private checkTxSerialization;
|
||||
}
|
||||
export default Wallet;
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Wallet/index.ts"],"names":[],"mappings":"AAyBA,OAAO,KAAK,MAAM,UAAU,CAAA;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAsDpD,cAAM,MAAM;IACV,SAAgB,SAAS,EAAE,MAAM,CAAA;IACjC,SAAgB,UAAU,EAAE,MAAM,CAAA;IAClC,SAAgB,cAAc,EAAE,MAAM,CAAA;IACtC,SAAgB,IAAI,CAAC,EAAE,MAAM,CAAA;gBAY3B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE;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use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const bip32_1 = require("bip32");
|
||||
const bip39_1 = require("bip39");
|
||||
const isEqual_1 = __importDefault(require("lodash/isEqual"));
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
const ECDSA_1 = __importDefault(require("../ECDSA"));
|
||||
const errors_1 = require("../errors");
|
||||
const common_1 = require("../models/transactions/common");
|
||||
const utils_1 = require("../models/utils");
|
||||
const utils_2 = require("../sugar/utils");
|
||||
const hashLedger_1 = require("../utils/hashes/hashLedger");
|
||||
const rfc1751_1 = require("./rfc1751");
|
||||
const DEFAULT_ALGORITHM = ECDSA_1.default.ed25519;
|
||||
const DEFAULT_DERIVATION_PATH = "m/44'/144'/0'/0/0";
|
||||
function hexFromBuffer(buffer) {
|
||||
return buffer.toString('hex').toUpperCase();
|
||||
}
|
||||
class Wallet {
|
||||
constructor(publicKey, privateKey, opts = {}) {
|
||||
this.publicKey = publicKey;
|
||||
this.privateKey = privateKey;
|
||||
this.classicAddress = opts.masterAddress
|
||||
? (0, utils_2.ensureClassicAddress)(opts.masterAddress)
|
||||
: (0, ripple_keypairs_1.deriveAddress)(publicKey);
|
||||
this.seed = opts.seed;
|
||||
}
|
||||
get address() {
|
||||
return this.classicAddress;
|
||||
}
|
||||
static generate(algorithm = DEFAULT_ALGORITHM) {
|
||||
const seed = (0, ripple_keypairs_1.generateSeed)({ algorithm });
|
||||
return Wallet.fromSeed(seed);
|
||||
}
|
||||
static fromSeed(seed, opts = {}) {
|
||||
return Wallet.deriveWallet(seed, {
|
||||
algorithm: opts.algorithm,
|
||||
masterAddress: opts.masterAddress,
|
||||
});
|
||||
}
|
||||
static fromEntropy(entropy, opts = {}) {
|
||||
var _a;
|
||||
const algorithm = (_a = opts.algorithm) !== null && _a !== void 0 ? _a : DEFAULT_ALGORITHM;
|
||||
const options = {
|
||||
entropy: Uint8Array.from(entropy),
|
||||
algorithm,
|
||||
};
|
||||
const seed = (0, ripple_keypairs_1.generateSeed)(options);
|
||||
return Wallet.deriveWallet(seed, {
|
||||
algorithm,
|
||||
masterAddress: opts.masterAddress,
|
||||
});
|
||||
}
|
||||
static fromMnemonic(mnemonic, opts = {}) {
|
||||
var _a;
|
||||
if (opts.mnemonicEncoding === 'rfc1751') {
|
||||
return Wallet.fromRFC1751Mnemonic(mnemonic, {
|
||||
masterAddress: opts.masterAddress,
|
||||
algorithm: opts.algorithm,
|
||||
});
|
||||
}
|
||||
if (!(0, bip39_1.validateMnemonic)(mnemonic)) {
|
||||
throw new errors_1.ValidationError('Unable to parse the given mnemonic using bip39 encoding');
|
||||
}
|
||||
const seed = (0, bip39_1.mnemonicToSeedSync)(mnemonic);
|
||||
const masterNode = (0, bip32_1.fromSeed)(seed);
|
||||
const node = masterNode.derivePath((_a = opts.derivationPath) !== null && _a !== void 0 ? _a : DEFAULT_DERIVATION_PATH);
|
||||
if (node.privateKey === undefined) {
|
||||
throw new errors_1.ValidationError('Unable to derive privateKey from mnemonic input');
|
||||
}
|
||||
const publicKey = hexFromBuffer(node.publicKey);
|
||||
const privateKey = hexFromBuffer(node.privateKey);
|
||||
return new Wallet(publicKey, `00${privateKey}`, {
|
||||
masterAddress: opts.masterAddress,
|
||||
});
|
||||
}
|
||||
static fromRFC1751Mnemonic(mnemonic, opts) {
|
||||
const seed = (0, rfc1751_1.rfc1751MnemonicToKey)(mnemonic);
|
||||
let encodeAlgorithm;
|
||||
if (opts.algorithm === ECDSA_1.default.ed25519) {
|
||||
encodeAlgorithm = 'ed25519';
|
||||
}
|
||||
else {
|
||||
encodeAlgorithm = 'secp256k1';
|
||||
}
|
||||
const encodedSeed = (0, ripple_address_codec_1.encodeSeed)(seed, encodeAlgorithm);
|
||||
return Wallet.fromSeed(encodedSeed, {
|
||||
masterAddress: opts.masterAddress,
|
||||
algorithm: opts.algorithm,
|
||||
});
|
||||
}
|
||||
static deriveWallet(seed, opts = {}) {
|
||||
var _a;
|
||||
const { publicKey, privateKey } = (0, ripple_keypairs_1.deriveKeypair)(seed, {
|
||||
algorithm: (_a = opts.algorithm) !== null && _a !== void 0 ? _a : DEFAULT_ALGORITHM,
|
||||
});
|
||||
return new Wallet(publicKey, privateKey, {
|
||||
seed,
|
||||
masterAddress: opts.masterAddress,
|
||||
});
|
||||
}
|
||||
sign(transaction, multisign) {
|
||||
let multisignAddress = false;
|
||||
if (typeof multisign === 'string' && multisign.startsWith('X')) {
|
||||
multisignAddress = multisign;
|
||||
}
|
||||
else if (multisign) {
|
||||
multisignAddress = this.classicAddress;
|
||||
}
|
||||
const tx = Object.assign({}, transaction);
|
||||
if (tx.TxnSignature || tx.Signers) {
|
||||
throw new errors_1.ValidationError('txJSON must not contain "TxnSignature" or "Signers" properties');
|
||||
}
|
||||
removeTrailingZeros(tx);
|
||||
const txToSignAndEncode = Object.assign({}, tx);
|
||||
txToSignAndEncode.SigningPubKey = multisignAddress ? '' : this.publicKey;
|
||||
if (multisignAddress) {
|
||||
const signer = {
|
||||
Account: multisignAddress,
|
||||
SigningPubKey: this.publicKey,
|
||||
TxnSignature: computeSignature(txToSignAndEncode, this.privateKey, multisignAddress),
|
||||
};
|
||||
txToSignAndEncode.Signers = [{ Signer: signer }];
|
||||
}
|
||||
else {
|
||||
txToSignAndEncode.TxnSignature = computeSignature(txToSignAndEncode, this.privateKey);
|
||||
}
|
||||
const serialized = (0, ripple_binary_codec_1.encode)(txToSignAndEncode);
|
||||
this.checkTxSerialization(serialized, tx);
|
||||
return {
|
||||
tx_blob: serialized,
|
||||
hash: (0, hashLedger_1.hashSignedTx)(serialized),
|
||||
};
|
||||
}
|
||||
verifyTransaction(signedTransaction) {
|
||||
const tx = typeof signedTransaction === 'string'
|
||||
? (0, ripple_binary_codec_1.decode)(signedTransaction)
|
||||
: signedTransaction;
|
||||
const messageHex = (0, ripple_binary_codec_1.encodeForSigning)(tx);
|
||||
const signature = tx.TxnSignature;
|
||||
return (0, ripple_keypairs_1.verify)(messageHex, signature, this.publicKey);
|
||||
}
|
||||
getXAddress(tag = false, isTestnet = false) {
|
||||
return (0, ripple_address_codec_1.classicAddressToXAddress)(this.classicAddress, tag, isTestnet);
|
||||
}
|
||||
checkTxSerialization(serialized, tx) {
|
||||
var _a;
|
||||
const decoded = (0, ripple_binary_codec_1.decode)(serialized);
|
||||
const txCopy = Object.assign({}, tx);
|
||||
if (!decoded.TxnSignature && !decoded.Signers) {
|
||||
throw new errors_1.ValidationError('Serialized transaction must have a TxnSignature or Signers property');
|
||||
}
|
||||
delete decoded.TxnSignature;
|
||||
delete decoded.Signers;
|
||||
if (!tx.SigningPubKey) {
|
||||
delete decoded.SigningPubKey;
|
||||
}
|
||||
(_a = txCopy.Memos) === null || _a === void 0 ? void 0 : _a.map((memo) => {
|
||||
const memoCopy = Object.assign({}, memo);
|
||||
if (memo.Memo.MemoData) {
|
||||
if (!(0, utils_1.isHex)(memo.Memo.MemoData)) {
|
||||
throw new errors_1.ValidationError('MemoData field must be a hex value');
|
||||
}
|
||||
memoCopy.Memo.MemoData = memo.Memo.MemoData.toUpperCase();
|
||||
}
|
||||
if (memo.Memo.MemoType) {
|
||||
if (!(0, utils_1.isHex)(memo.Memo.MemoType)) {
|
||||
throw new errors_1.ValidationError('MemoType field must be a hex value');
|
||||
}
|
||||
memoCopy.Memo.MemoType = memo.Memo.MemoType.toUpperCase();
|
||||
}
|
||||
if (memo.Memo.MemoFormat) {
|
||||
if (!(0, utils_1.isHex)(memo.Memo.MemoFormat)) {
|
||||
throw new errors_1.ValidationError('MemoFormat field must be a hex value');
|
||||
}
|
||||
memoCopy.Memo.MemoFormat = memo.Memo.MemoFormat.toUpperCase();
|
||||
}
|
||||
return memo;
|
||||
});
|
||||
if (txCopy.TransactionType === 'NFTokenMint' && txCopy.URI) {
|
||||
if (!(0, utils_1.isHex)(txCopy.URI)) {
|
||||
throw new errors_1.ValidationError('URI must be a hex value');
|
||||
}
|
||||
txCopy.URI = txCopy.URI.toUpperCase();
|
||||
}
|
||||
Object.keys(txCopy).forEach((key) => {
|
||||
const standard_currency_code_len = 3;
|
||||
if (txCopy[key] && (0, common_1.isIssuedCurrency)(txCopy[key])) {
|
||||
const decodedAmount = decoded[key];
|
||||
const decodedCurrency = decodedAmount.currency;
|
||||
const txCurrency = txCopy[key].currency;
|
||||
if (txCurrency.length === standard_currency_code_len &&
|
||||
txCurrency.toUpperCase() === 'XRP') {
|
||||
throw new errors_1.XrplError(`Trying to sign an issued currency with a similar standard code to XRP (received '${txCurrency}'). XRP is not an issued currency.`);
|
||||
}
|
||||
const amount = txCopy[key];
|
||||
if (amount.currency.length !== decodedCurrency.length) {
|
||||
if (decodedCurrency.length === standard_currency_code_len) {
|
||||
decodedAmount.currency = isoToHex(decodedCurrency);
|
||||
}
|
||||
else {
|
||||
txCopy[key].currency = isoToHex(txCopy[key].currency);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (!(0, isEqual_1.default)(decoded, txCopy)) {
|
||||
const data = {
|
||||
decoded,
|
||||
tx,
|
||||
};
|
||||
const error = new errors_1.ValidationError('Serialized transaction does not match original txJSON. See error.data', data);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
Wallet.fromSecret = Wallet.fromSeed;
|
||||
function computeSignature(tx, privateKey, signAs) {
|
||||
if (signAs) {
|
||||
const classicAddress = (0, ripple_address_codec_1.isValidXAddress)(signAs)
|
||||
? (0, ripple_address_codec_1.xAddressToClassicAddress)(signAs).classicAddress
|
||||
: signAs;
|
||||
return (0, ripple_keypairs_1.sign)((0, ripple_binary_codec_1.encodeForMultisigning)(tx, classicAddress), privateKey);
|
||||
}
|
||||
return (0, ripple_keypairs_1.sign)((0, ripple_binary_codec_1.encodeForSigning)(tx), privateKey);
|
||||
}
|
||||
function removeTrailingZeros(tx) {
|
||||
if (tx.TransactionType === 'Payment' &&
|
||||
typeof tx.Amount !== 'string' &&
|
||||
tx.Amount.value.includes('.') &&
|
||||
tx.Amount.value.endsWith('0')) {
|
||||
tx.Amount = Object.assign({}, tx.Amount);
|
||||
tx.Amount.value = new bignumber_js_1.default(tx.Amount.value).toString();
|
||||
}
|
||||
}
|
||||
function isoToHex(iso) {
|
||||
const bytes = Buffer.alloc(20);
|
||||
if (iso !== 'XRP') {
|
||||
const isoBytes = iso.split('').map((chr) => chr.charCodeAt(0));
|
||||
bytes.set(isoBytes, 12);
|
||||
}
|
||||
return bytes.toString('hex').toUpperCase();
|
||||
}
|
||||
exports.default = Wallet;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+5
@@ -0,0 +1,5 @@
|
||||
/// <reference types="node" />
|
||||
declare function keyToRFC1751Mnemonic(hex_key: string): string;
|
||||
declare function rfc1751MnemonicToKey(english: string): Buffer;
|
||||
export { rfc1751MnemonicToKey, keyToRFC1751Mnemonic };
|
||||
//# sourceMappingURL=rfc1751.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"rfc1751.d.ts","sourceRoot":"","sources":["../../../src/Wallet/rfc1751.ts"],"names":[],"mappings":";AA2DA,iBAAS,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA+BrD;AASD,iBAAS,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CA4BrD;AA8DD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,CAAA"}
|
||||
+113
@@ -0,0 +1,113 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.keyToRFC1751Mnemonic = exports.rfc1751MnemonicToKey = void 0;
|
||||
const rfc1751Words_json_1 = __importDefault(require("./rfc1751Words.json"));
|
||||
const rfc1751WordList = rfc1751Words_json_1.default;
|
||||
const BINARY = ['0000', '0001', '0010', '0011', '0100', '0101', '0110', '0111',
|
||||
'1000', '1001', '1010', '1011', '1100', '1101', '1110', '1111'];
|
||||
function keyToBinary(key) {
|
||||
let res = '';
|
||||
for (const num of key) {
|
||||
res += BINARY[num >> 4] + BINARY[num & 0x0f];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
function extract(key, start, length) {
|
||||
const subKey = key.substring(start, start + length);
|
||||
let acc = 0;
|
||||
for (let index = 0; index < subKey.length; index++) {
|
||||
acc = acc * 2 + subKey.charCodeAt(index) - 48;
|
||||
}
|
||||
return acc;
|
||||
}
|
||||
function keyToRFC1751Mnemonic(hex_key) {
|
||||
const buf = Buffer.from(hex_key.replace(/\s+/gu, ''), 'hex');
|
||||
let key = bufferToArray(swap128(buf));
|
||||
const padding = [];
|
||||
for (let index = 0; index < (8 - (key.length % 8)) % 8; index++) {
|
||||
padding.push(0);
|
||||
}
|
||||
key = padding.concat(key);
|
||||
const english = [];
|
||||
for (let index = 0; index < key.length; index += 8) {
|
||||
const subKey = key.slice(index, index + 8);
|
||||
let skbin = keyToBinary(subKey);
|
||||
let parity = 0;
|
||||
for (let j = 0; j < 64; j += 2) {
|
||||
parity += extract(skbin, j, 2);
|
||||
}
|
||||
subKey.push((parity << 6) & 0xff);
|
||||
skbin = keyToBinary(subKey);
|
||||
for (let j = 0; j < 64; j += 11) {
|
||||
english.push(rfc1751WordList[extract(skbin, j, 11)]);
|
||||
}
|
||||
}
|
||||
return english.join(' ');
|
||||
}
|
||||
exports.keyToRFC1751Mnemonic = keyToRFC1751Mnemonic;
|
||||
function rfc1751MnemonicToKey(english) {
|
||||
const words = english.split(' ');
|
||||
let key = [];
|
||||
for (let index = 0; index < words.length; index += 6) {
|
||||
const { subKey, word } = getSubKey(words, index);
|
||||
const skbin = keyToBinary(subKey);
|
||||
let parity = 0;
|
||||
for (let j = 0; j < 64; j += 2) {
|
||||
parity += extract(skbin, j, 2);
|
||||
}
|
||||
const cs0 = extract(skbin, 64, 2);
|
||||
const cs1 = parity & 3;
|
||||
if (cs0 !== cs1) {
|
||||
throw new Error(`Parity error at ${word}`);
|
||||
}
|
||||
key = key.concat(subKey.slice(0, 8));
|
||||
}
|
||||
const bufferKey = swap128(Buffer.from(key));
|
||||
return bufferKey;
|
||||
}
|
||||
exports.rfc1751MnemonicToKey = rfc1751MnemonicToKey;
|
||||
function getSubKey(words, index) {
|
||||
const sublist = words.slice(index, index + 6);
|
||||
let bits = 0;
|
||||
const ch = [0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
let word = '';
|
||||
for (word of sublist) {
|
||||
const idx = rfc1751WordList.indexOf(word.toUpperCase());
|
||||
if (idx === -1) {
|
||||
throw new TypeError(`Expected an RFC1751 word, but received '${word}'. ` +
|
||||
`For the full list of words in the RFC1751 encoding see https://datatracker.ietf.org/doc/html/rfc1751`);
|
||||
}
|
||||
const shift = (8 - ((bits + 11) % 8)) % 8;
|
||||
const y = idx << shift;
|
||||
const cl = y >> 16;
|
||||
const cc = (y >> 8) & 0xff;
|
||||
const cr = y & 0xff;
|
||||
const t = Math.floor(bits / 8);
|
||||
if (shift > 5) {
|
||||
ch[t] |= cl;
|
||||
ch[t + 1] |= cc;
|
||||
ch[t + 2] |= cr;
|
||||
}
|
||||
else if (shift > -3) {
|
||||
ch[t] |= cc;
|
||||
ch[t + 1] |= cr;
|
||||
}
|
||||
else {
|
||||
ch[t] |= cr;
|
||||
}
|
||||
bits += 11;
|
||||
}
|
||||
const subKey = ch.slice();
|
||||
return { subKey, word };
|
||||
}
|
||||
function bufferToArray(buf) {
|
||||
return Array.prototype.slice.call(buf);
|
||||
}
|
||||
function swap128(buf) {
|
||||
const reversedBytes = buf.swap64();
|
||||
return Buffer.concat([reversedBytes.slice(8, 16), reversedBytes.slice(0, 8)], 16);
|
||||
}
|
||||
//# sourceMappingURL=rfc1751.js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CAAC,CAAC,IAAI,EAAE,CAAA;SAChB;aAAM;YACL,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAA;SACZ;QACD,IAAI,IAAI,EAAE,CAAA;KACX;IACD,MAAM,MAAM,GAAa,EAAE,CAAC,KAAK,EAAE,CAAA;IACnC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,CAAA;AACzB,CAAC;AAED,SAAS,aAAa,CAAC,GAAW;IAEhC,OAAO,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAa,CAAA;AACpD,CAAC;AAQD,SAAS,OAAO,CAAC,GAAW;IAE1B,MAAM,aAAa,GAAG,GAAG,CAAC,MAAM,EAAE,CAAA;IAGlC,OAAO,MAAM,CAAC,MAAM,CAClB,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EACvD,EAAE,CACH,CAAA;AACH,CAAC"}
|
||||
+243
@@ -0,0 +1,243 @@
|
||||
["A", "ABE", "ACE", "ACT", "AD", "ADA", "ADD",
|
||||
"AGO", "AID", "AIM", "AIR", "ALL", "ALP", "AM", "AMY", "AN", "ANA",
|
||||
"AND", "ANN", "ANT", "ANY", "APE", "APS", "APT", "ARC", "ARE", "ARK",
|
||||
"ARM", "ART", "AS", "ASH", "ASK", "AT", "ATE", "AUG", "AUK", "AVE",
|
||||
"AWE", "AWK", "AWL", "AWN", "AX", "AYE", "BAD", "BAG", "BAH", "BAM",
|
||||
"BAN", "BAR", "BAT", "BAY", "BE", "BED", "BEE", "BEG", "BEN", "BET",
|
||||
"BEY", "BIB", "BID", "BIG", "BIN", "BIT", "BOB", "BOG", "BON", "BOO",
|
||||
"BOP", "BOW", "BOY", "BUB", "BUD", "BUG", "BUM", "BUN", "BUS", "BUT",
|
||||
"BUY", "BY", "BYE", "CAB", "CAL", "CAM", "CAN", "CAP", "CAR", "CAT",
|
||||
"CAW", "COD", "COG", "COL", "CON", "COO", "COP", "COT", "COW", "COY",
|
||||
"CRY", "CUB", "CUE", "CUP", "CUR", "CUT", "DAB", "DAD", "DAM", "DAN",
|
||||
"DAR", "DAY", "DEE", "DEL", "DEN", "DES", "DEW", "DID", "DIE", "DIG",
|
||||
"DIN", "DIP", "DO", "DOE", "DOG", "DON", "DOT", "DOW", "DRY", "DUB",
|
||||
"DUD", "DUE", "DUG", "DUN", "EAR", "EAT", "ED", "EEL", "EGG", "EGO",
|
||||
"ELI", "ELK", "ELM", "ELY", "EM", "END", "EST", "ETC", "EVA", "EVE",
|
||||
"EWE", "EYE", "FAD", "FAN", "FAR", "FAT", "FAY", "FED", "FEE", "FEW",
|
||||
"FIB", "FIG", "FIN", "FIR", "FIT", "FLO", "FLY", "FOE", "FOG", "FOR",
|
||||
"FRY", "FUM", "FUN", "FUR", "GAB", "GAD", "GAG", "GAL", "GAM", "GAP",
|
||||
"GAS", "GAY", "GEE", "GEL", "GEM", "GET", "GIG", "GIL", "GIN", "GO",
|
||||
"GOT", "GUM", "GUN", "GUS", "GUT", "GUY", "GYM", "GYP", "HA", "HAD",
|
||||
"HAL", "HAM", "HAN", "HAP", "HAS", "HAT", "HAW", "HAY", "HE", "HEM",
|
||||
"HEN", "HER", "HEW", "HEY", "HI", "HID", "HIM", "HIP", "HIS", "HIT",
|
||||
"HO", "HOB", "HOC", "HOE", "HOG", "HOP", "HOT", "HOW", "HUB", "HUE",
|
||||
"HUG", "HUH", "HUM", "HUT", "I", "ICY", "IDA", "IF", "IKE", "ILL",
|
||||
"INK", "INN", "IO", "ION", "IQ", "IRA", "IRE", "IRK", "IS", "IT",
|
||||
"ITS", "IVY", "JAB", "JAG", "JAM", "JAN", "JAR", "JAW", "JAY", "JET",
|
||||
"JIG", "JIM", "JO", "JOB", "JOE", "JOG", "JOT", "JOY", "JUG", "JUT",
|
||||
"KAY", "KEG", "KEN", "KEY", "KID", "KIM", "KIN", "KIT", "LA", "LAB",
|
||||
"LAC", "LAD", "LAG", "LAM", "LAP", "LAW", "LAY", "LEA", "LED", "LEE",
|
||||
"LEG", "LEN", "LEO", "LET", "LEW", "LID", "LIE", "LIN", "LIP", "LIT",
|
||||
"LO", "LOB", "LOG", "LOP", "LOS", "LOT", "LOU", "LOW", "LOY", "LUG",
|
||||
"LYE", "MA", "MAC", "MAD", "MAE", "MAN", "MAO", "MAP", "MAT", "MAW",
|
||||
"MAY", "ME", "MEG", "MEL", "MEN", "MET", "MEW", "MID", "MIN", "MIT",
|
||||
"MOB", "MOD", "MOE", "MOO", "MOP", "MOS", "MOT", "MOW", "MUD", "MUG",
|
||||
"MUM", "MY", "NAB", "NAG", "NAN", "NAP", "NAT", "NAY", "NE", "NED",
|
||||
"NEE", "NET", "NEW", "NIB", "NIL", "NIP", "NIT", "NO", "NOB", "NOD",
|
||||
"NON", "NOR", "NOT", "NOV", "NOW", "NU", "NUN", "NUT", "O", "OAF",
|
||||
"OAK", "OAR", "OAT", "ODD", "ODE", "OF", "OFF", "OFT", "OH", "OIL",
|
||||
"OK", "OLD", "ON", "ONE", "OR", "ORB", "ORE", "ORR", "OS", "OTT",
|
||||
"OUR", "OUT", "OVA", "OW", "OWE", "OWL", "OWN", "OX", "PA", "PAD",
|
||||
"PAL", "PAM", "PAN", "PAP", "PAR", "PAT", "PAW", "PAY", "PEA", "PEG",
|
||||
"PEN", "PEP", "PER", "PET", "PEW", "PHI", "PI", "PIE", "PIN", "PIT",
|
||||
"PLY", "PO", "POD", "POE", "POP", "POT", "POW", "PRO", "PRY", "PUB",
|
||||
"PUG", "PUN", "PUP", "PUT", "QUO", "RAG", "RAM", "RAN", "RAP", "RAT",
|
||||
"RAW", "RAY", "REB", "RED", "REP", "RET", "RIB", "RID", "RIG", "RIM",
|
||||
"RIO", "RIP", "ROB", "ROD", "ROE", "RON", "ROT", "ROW", "ROY", "RUB",
|
||||
"RUE", "RUG", "RUM", "RUN", "RYE", "SAC", "SAD", "SAG", "SAL", "SAM",
|
||||
"SAN", "SAP", "SAT", "SAW", "SAY", "SEA", "SEC", "SEE", "SEN", "SET",
|
||||
"SEW", "SHE", "SHY", "SIN", "SIP", "SIR", "SIS", "SIT", "SKI", "SKY",
|
||||
"SLY", "SO", "SOB", "SOD", "SON", "SOP", "SOW", "SOY", "SPA", "SPY",
|
||||
"SUB", "SUD", "SUE", "SUM", "SUN", "SUP", "TAB", "TAD", "TAG", "TAN",
|
||||
"TAP", "TAR", "TEA", "TED", "TEE", "TEN", "THE", "THY", "TIC", "TIE",
|
||||
"TIM", "TIN", "TIP", "TO", "TOE", "TOG", "TOM", "TON", "TOO", "TOP",
|
||||
"TOW", "TOY", "TRY", "TUB", "TUG", "TUM", "TUN", "TWO", "UN", "UP",
|
||||
"US", "USE", "VAN", "VAT", "VET", "VIE", "WAD", "WAG", "WAR", "WAS",
|
||||
"WAY", "WE", "WEB", "WED", "WEE", "WET", "WHO", "WHY", "WIN", "WIT",
|
||||
"WOK", "WON", "WOO", "WOW", "WRY", "WU", "YAM", "YAP", "YAW", "YE",
|
||||
"YEA", "YES", "YET", "YOU", "ABED", "ABEL", "ABET", "ABLE", "ABUT",
|
||||
"ACHE", "ACID", "ACME", "ACRE", "ACTA", "ACTS", "ADAM", "ADDS",
|
||||
"ADEN", "AFAR", "AFRO", "AGEE", "AHEM", "AHOY", "AIDA", "AIDE",
|
||||
"AIDS", "AIRY", "AJAR", "AKIN", "ALAN", "ALEC", "ALGA", "ALIA",
|
||||
"ALLY", "ALMA", "ALOE", "ALSO", "ALTO", "ALUM", "ALVA", "AMEN",
|
||||
"AMES", "AMID", "AMMO", "AMOK", "AMOS", "AMRA", "ANDY", "ANEW",
|
||||
"ANNA", "ANNE", "ANTE", "ANTI", "AQUA", "ARAB", "ARCH", "AREA",
|
||||
"ARGO", "ARID", "ARMY", "ARTS", "ARTY", "ASIA", "ASKS", "ATOM",
|
||||
"AUNT", "AURA", "AUTO", "AVER", "AVID", "AVIS", "AVON", "AVOW",
|
||||
"AWAY", "AWRY", "BABE", "BABY", "BACH", "BACK", "BADE", "BAIL",
|
||||
"BAIT", "BAKE", "BALD", "BALE", "BALI", "BALK", "BALL", "BALM",
|
||||
"BAND", "BANE", "BANG", "BANK", "BARB", "BARD", "BARE", "BARK",
|
||||
"BARN", "BARR", "BASE", "BASH", "BASK", "BASS", "BATE", "BATH",
|
||||
"BAWD", "BAWL", "BEAD", "BEAK", "BEAM", "BEAN", "BEAR", "BEAT",
|
||||
"BEAU", "BECK", "BEEF", "BEEN", "BEER",
|
||||
"BEET", "BELA", "BELL", "BELT", "BEND", "BENT", "BERG", "BERN",
|
||||
"BERT", "BESS", "BEST", "BETA", "BETH", "BHOY", "BIAS", "BIDE",
|
||||
"BIEN", "BILE", "BILK", "BILL", "BIND", "BING", "BIRD", "BITE",
|
||||
"BITS", "BLAB", "BLAT", "BLED", "BLEW", "BLOB", "BLOC", "BLOT",
|
||||
"BLOW", "BLUE", "BLUM", "BLUR", "BOAR", "BOAT", "BOCA", "BOCK",
|
||||
"BODE", "BODY", "BOGY", "BOHR", "BOIL", "BOLD", "BOLO", "BOLT",
|
||||
"BOMB", "BONA", "BOND", "BONE", "BONG", "BONN", "BONY", "BOOK",
|
||||
"BOOM", "BOON", "BOOT", "BORE", "BORG", "BORN", "BOSE", "BOSS",
|
||||
"BOTH", "BOUT", "BOWL", "BOYD", "BRAD", "BRAE", "BRAG", "BRAN",
|
||||
"BRAY", "BRED", "BREW", "BRIG", "BRIM", "BROW", "BUCK", "BUDD",
|
||||
"BUFF", "BULB", "BULK", "BULL", "BUNK", "BUNT", "BUOY", "BURG",
|
||||
"BURL", "BURN", "BURR", "BURT", "BURY", "BUSH", "BUSS", "BUST",
|
||||
"BUSY", "BYTE", "CADY", "CAFE", "CAGE", "CAIN", "CAKE", "CALF",
|
||||
"CALL", "CALM", "CAME", "CANE", "CANT", "CARD", "CARE", "CARL",
|
||||
"CARR", "CART", "CASE", "CASH", "CASK", "CAST", "CAVE", "CEIL",
|
||||
"CELL", "CENT", "CERN", "CHAD", "CHAR", "CHAT", "CHAW", "CHEF",
|
||||
"CHEN", "CHEW", "CHIC", "CHIN", "CHOU", "CHOW", "CHUB", "CHUG",
|
||||
"CHUM", "CITE", "CITY", "CLAD", "CLAM", "CLAN", "CLAW", "CLAY",
|
||||
"CLOD", "CLOG", "CLOT", "CLUB", "CLUE", "COAL", "COAT", "COCA",
|
||||
"COCK", "COCO", "CODA", "CODE", "CODY", "COED", "COIL", "COIN",
|
||||
"COKE", "COLA", "COLD", "COLT", "COMA", "COMB", "COME", "COOK",
|
||||
"COOL", "COON", "COOT", "CORD", "CORE", "CORK", "CORN", "COST",
|
||||
"COVE", "COWL", "CRAB", "CRAG", "CRAM", "CRAY", "CREW", "CRIB",
|
||||
"CROW", "CRUD", "CUBA", "CUBE", "CUFF", "CULL", "CULT", "CUNY",
|
||||
"CURB", "CURD", "CURE", "CURL", "CURT", "CUTS", "DADE", "DALE",
|
||||
"DAME", "DANA", "DANE", "DANG", "DANK", "DARE", "DARK", "DARN",
|
||||
"DART", "DASH", "DATA", "DATE", "DAVE", "DAVY", "DAWN", "DAYS",
|
||||
"DEAD", "DEAF", "DEAL", "DEAN", "DEAR", "DEBT", "DECK", "DEED",
|
||||
"DEEM", "DEER", "DEFT", "DEFY", "DELL", "DENT", "DENY", "DESK",
|
||||
"DIAL", "DICE", "DIED", "DIET", "DIME", "DINE", "DING", "DINT",
|
||||
"DIRE", "DIRT", "DISC", "DISH", "DISK", "DIVE", "DOCK", "DOES",
|
||||
"DOLE", "DOLL", "DOLT", "DOME", "DONE", "DOOM", "DOOR", "DORA",
|
||||
"DOSE", "DOTE", "DOUG", "DOUR", "DOVE", "DOWN", "DRAB", "DRAG",
|
||||
"DRAM", "DRAW", "DREW", "DRUB", "DRUG", "DRUM", "DUAL", "DUCK",
|
||||
"DUCT", "DUEL", "DUET", "DUKE", "DULL", "DUMB", "DUNE", "DUNK",
|
||||
"DUSK", "DUST", "DUTY", "EACH", "EARL", "EARN", "EASE", "EAST",
|
||||
"EASY", "EBEN", "ECHO", "EDDY", "EDEN", "EDGE", "EDGY", "EDIT",
|
||||
"EDNA", "EGAN", "ELAN", "ELBA", "ELLA", "ELSE", "EMIL", "EMIT",
|
||||
"EMMA", "ENDS", "ERIC", "EROS", "EVEN", "EVER", "EVIL", "EYED",
|
||||
"FACE", "FACT", "FADE", "FAIL", "FAIN", "FAIR", "FAKE", "FALL",
|
||||
"FAME", "FANG", "FARM", "FAST", "FATE", "FAWN", "FEAR", "FEAT",
|
||||
"FEED", "FEEL", "FEET", "FELL", "FELT", "FEND", "FERN", "FEST",
|
||||
"FEUD", "FIEF", "FIGS", "FILE", "FILL", "FILM", "FIND", "FINE",
|
||||
"FINK", "FIRE", "FIRM", "FISH", "FISK", "FIST", "FITS", "FIVE",
|
||||
"FLAG", "FLAK", "FLAM", "FLAT", "FLAW", "FLEA", "FLED", "FLEW",
|
||||
"FLIT", "FLOC", "FLOG", "FLOW", "FLUB", "FLUE", "FOAL", "FOAM",
|
||||
"FOGY", "FOIL", "FOLD", "FOLK", "FOND", "FONT", "FOOD", "FOOL",
|
||||
"FOOT", "FORD", "FORE", "FORK", "FORM", "FORT", "FOSS", "FOUL",
|
||||
"FOUR", "FOWL", "FRAU", "FRAY", "FRED", "FREE", "FRET", "FREY",
|
||||
"FROG", "FROM", "FUEL", "FULL", "FUME", "FUND", "FUNK", "FURY",
|
||||
"FUSE", "FUSS", "GAFF", "GAGE", "GAIL", "GAIN", "GAIT", "GALA",
|
||||
"GALE", "GALL", "GALT", "GAME", "GANG", "GARB", "GARY", "GASH",
|
||||
"GATE", "GAUL", "GAUR", "GAVE", "GAWK", "GEAR", "GELD", "GENE",
|
||||
"GENT", "GERM", "GETS", "GIBE", "GIFT", "GILD", "GILL", "GILT",
|
||||
"GINA", "GIRD", "GIRL", "GIST", "GIVE", "GLAD", "GLEE", "GLEN",
|
||||
"GLIB", "GLOB", "GLOM", "GLOW", "GLUE", "GLUM", "GLUT", "GOAD",
|
||||
"GOAL", "GOAT", "GOER", "GOES", "GOLD", "GOLF", "GONE", "GONG",
|
||||
"GOOD", "GOOF", "GORE", "GORY", "GOSH", "GOUT", "GOWN", "GRAB",
|
||||
"GRAD", "GRAY", "GREG", "GREW", "GREY", "GRID", "GRIM", "GRIN",
|
||||
"GRIT", "GROW", "GRUB", "GULF", "GULL", "GUNK", "GURU", "GUSH",
|
||||
"GUST", "GWEN", "GWYN", "HAAG", "HAAS", "HACK", "HAIL", "HAIR",
|
||||
"HALE", "HALF", "HALL", "HALO", "HALT", "HAND", "HANG", "HANK",
|
||||
"HANS", "HARD", "HARK", "HARM", "HART", "HASH", "HAST", "HATE",
|
||||
"HATH", "HAUL", "HAVE", "HAWK", "HAYS", "HEAD", "HEAL", "HEAR",
|
||||
"HEAT", "HEBE", "HECK", "HEED", "HEEL", "HEFT", "HELD", "HELL",
|
||||
"HELM", "HERB", "HERD", "HERE", "HERO", "HERS", "HESS", "HEWN",
|
||||
"HICK", "HIDE", "HIGH", "HIKE", "HILL", "HILT", "HIND", "HINT",
|
||||
"HIRE", "HISS", "HIVE", "HOBO", "HOCK", "HOFF", "HOLD", "HOLE",
|
||||
"HOLM", "HOLT", "HOME", "HONE", "HONK", "HOOD", "HOOF", "HOOK",
|
||||
"HOOT", "HORN", "HOSE", "HOST", "HOUR", "HOVE", "HOWE", "HOWL",
|
||||
"HOYT", "HUCK", "HUED", "HUFF", "HUGE", "HUGH", "HUGO", "HULK",
|
||||
"HULL", "HUNK", "HUNT", "HURD", "HURL", "HURT", "HUSH", "HYDE",
|
||||
"HYMN", "IBIS", "ICON", "IDEA", "IDLE", "IFFY", "INCA", "INCH",
|
||||
"INTO", "IONS", "IOTA", "IOWA", "IRIS", "IRMA", "IRON", "ISLE",
|
||||
"ITCH", "ITEM", "IVAN", "JACK", "JADE", "JAIL", "JAKE", "JANE",
|
||||
"JAVA", "JEAN", "JEFF", "JERK", "JESS", "JEST", "JIBE", "JILL",
|
||||
"JILT", "JIVE", "JOAN", "JOBS", "JOCK", "JOEL", "JOEY", "JOHN",
|
||||
"JOIN", "JOKE", "JOLT", "JOVE", "JUDD", "JUDE", "JUDO", "JUDY",
|
||||
"JUJU", "JUKE", "JULY", "JUNE", "JUNK", "JUNO", "JURY", "JUST",
|
||||
"JUTE", "KAHN", "KALE", "KANE", "KANT", "KARL", "KATE", "KEEL",
|
||||
"KEEN", "KENO", "KENT", "KERN", "KERR", "KEYS", "KICK", "KILL",
|
||||
"KIND", "KING", "KIRK", "KISS", "KITE", "KLAN", "KNEE", "KNEW",
|
||||
"KNIT", "KNOB", "KNOT", "KNOW", "KOCH", "KONG", "KUDO", "KURD",
|
||||
"KURT", "KYLE", "LACE", "LACK", "LACY", "LADY", "LAID", "LAIN",
|
||||
"LAIR", "LAKE", "LAMB", "LAME", "LAND", "LANE", "LANG", "LARD",
|
||||
"LARK", "LASS", "LAST", "LATE", "LAUD", "LAVA", "LAWN", "LAWS",
|
||||
"LAYS", "LEAD", "LEAF", "LEAK", "LEAN", "LEAR", "LEEK", "LEER",
|
||||
"LEFT", "LEND", "LENS", "LENT", "LEON", "LESK", "LESS", "LEST",
|
||||
"LETS", "LIAR", "LICE", "LICK", "LIED", "LIEN", "LIES", "LIEU",
|
||||
"LIFE", "LIFT", "LIKE", "LILA", "LILT", "LILY", "LIMA", "LIMB",
|
||||
"LIME", "LIND", "LINE", "LINK", "LINT", "LION", "LISA", "LIST",
|
||||
"LIVE", "LOAD", "LOAF", "LOAM", "LOAN", "LOCK", "LOFT", "LOGE",
|
||||
"LOIS", "LOLA", "LONE", "LONG", "LOOK", "LOON", "LOOT", "LORD",
|
||||
"LORE", "LOSE", "LOSS", "LOST", "LOUD", "LOVE", "LOWE", "LUCK",
|
||||
"LUCY", "LUGE", "LUKE", "LULU", "LUND", "LUNG", "LURA", "LURE",
|
||||
"LURK", "LUSH", "LUST", "LYLE", "LYNN", "LYON", "LYRA", "MACE",
|
||||
"MADE", "MAGI", "MAID", "MAIL", "MAIN", "MAKE", "MALE", "MALI",
|
||||
"MALL", "MALT", "MANA", "MANN", "MANY", "MARC", "MARE", "MARK",
|
||||
"MARS", "MART", "MARY", "MASH", "MASK", "MASS", "MAST", "MATE",
|
||||
"MATH", "MAUL", "MAYO", "MEAD", "MEAL", "MEAN", "MEAT", "MEEK",
|
||||
"MEET", "MELD", "MELT", "MEMO", "MEND", "MENU", "MERT", "MESH",
|
||||
"MESS", "MICE", "MIKE", "MILD", "MILE", "MILK", "MILL", "MILT",
|
||||
"MIMI", "MIND", "MINE", "MINI", "MINK", "MINT", "MIRE", "MISS",
|
||||
"MIST", "MITE", "MITT", "MOAN", "MOAT", "MOCK", "MODE", "MOLD",
|
||||
"MOLE", "MOLL", "MOLT", "MONA", "MONK", "MONT", "MOOD", "MOON",
|
||||
"MOOR", "MOOT", "MORE", "MORN", "MORT", "MOSS", "MOST", "MOTH",
|
||||
"MOVE", "MUCH", "MUCK", "MUDD", "MUFF", "MULE", "MULL", "MURK",
|
||||
"MUSH", "MUST", "MUTE", "MUTT", "MYRA", "MYTH", "NAGY", "NAIL",
|
||||
"NAIR", "NAME", "NARY", "NASH", "NAVE", "NAVY", "NEAL", "NEAR",
|
||||
"NEAT", "NECK", "NEED", "NEIL", "NELL", "NEON", "NERO", "NESS",
|
||||
"NEST", "NEWS", "NEWT", "NIBS", "NICE", "NICK", "NILE", "NINA",
|
||||
"NINE", "NOAH", "NODE", "NOEL", "NOLL", "NONE", "NOOK", "NOON",
|
||||
"NORM", "NOSE", "NOTE", "NOUN", "NOVA", "NUDE", "NULL", "NUMB",
|
||||
"OATH", "OBEY", "OBOE", "ODIN", "OHIO", "OILY", "OINT", "OKAY",
|
||||
"OLAF", "OLDY", "OLGA", "OLIN", "OMAN", "OMEN", "OMIT", "ONCE",
|
||||
"ONES", "ONLY", "ONTO", "ONUS", "ORAL", "ORGY", "OSLO", "OTIS",
|
||||
"OTTO", "OUCH", "OUST", "OUTS", "OVAL", "OVEN", "OVER", "OWLY",
|
||||
"OWNS", "QUAD", "QUIT", "QUOD", "RACE", "RACK", "RACY", "RAFT",
|
||||
"RAGE", "RAID", "RAIL", "RAIN", "RAKE", "RANK", "RANT", "RARE",
|
||||
"RASH", "RATE", "RAVE", "RAYS", "READ", "REAL", "REAM", "REAR",
|
||||
"RECK", "REED", "REEF", "REEK", "REEL", "REID", "REIN", "RENA",
|
||||
"REND", "RENT", "REST", "RICE", "RICH", "RICK", "RIDE", "RIFT",
|
||||
"RILL", "RIME", "RING", "RINK", "RISE", "RISK", "RITE", "ROAD",
|
||||
"ROAM", "ROAR", "ROBE", "ROCK", "RODE", "ROIL", "ROLL", "ROME",
|
||||
"ROOD", "ROOF", "ROOK", "ROOM", "ROOT", "ROSA", "ROSE", "ROSS",
|
||||
"ROSY", "ROTH", "ROUT", "ROVE", "ROWE", "ROWS", "RUBE", "RUBY",
|
||||
"RUDE", "RUDY", "RUIN", "RULE", "RUNG", "RUNS", "RUNT", "RUSE",
|
||||
"RUSH", "RUSK", "RUSS", "RUST", "RUTH", "SACK", "SAFE", "SAGE",
|
||||
"SAID", "SAIL", "SALE", "SALK", "SALT", "SAME", "SAND", "SANE",
|
||||
"SANG", "SANK", "SARA", "SAUL", "SAVE", "SAYS", "SCAN", "SCAR",
|
||||
"SCAT", "SCOT", "SEAL", "SEAM", "SEAR", "SEAT", "SEED", "SEEK",
|
||||
"SEEM", "SEEN", "SEES", "SELF", "SELL", "SEND", "SENT", "SETS",
|
||||
"SEWN", "SHAG", "SHAM", "SHAW", "SHAY", "SHED", "SHIM", "SHIN",
|
||||
"SHOD", "SHOE", "SHOT", "SHOW", "SHUN", "SHUT", "SICK", "SIDE",
|
||||
"SIFT", "SIGH", "SIGN", "SILK", "SILL", "SILO", "SILT", "SINE",
|
||||
"SING", "SINK", "SIRE", "SITE", "SITS", "SITU", "SKAT", "SKEW",
|
||||
"SKID", "SKIM", "SKIN", "SKIT", "SLAB", "SLAM", "SLAT", "SLAY",
|
||||
"SLED", "SLEW", "SLID", "SLIM", "SLIT", "SLOB", "SLOG", "SLOT",
|
||||
"SLOW", "SLUG", "SLUM", "SLUR", "SMOG", "SMUG", "SNAG", "SNOB",
|
||||
"SNOW", "SNUB", "SNUG", "SOAK", "SOAR", "SOCK", "SODA", "SOFA",
|
||||
"SOFT", "SOIL", "SOLD", "SOME", "SONG", "SOON", "SOOT", "SORE",
|
||||
"SORT", "SOUL", "SOUR", "SOWN", "STAB", "STAG", "STAN", "STAR",
|
||||
"STAY", "STEM", "STEW", "STIR", "STOW", "STUB", "STUN", "SUCH",
|
||||
"SUDS", "SUIT", "SULK", "SUMS", "SUNG", "SUNK", "SURE", "SURF",
|
||||
"SWAB", "SWAG", "SWAM", "SWAN", "SWAT", "SWAY", "SWIM", "SWUM",
|
||||
"TACK", "TACT", "TAIL", "TAKE", "TALE", "TALK", "TALL", "TANK",
|
||||
"TASK", "TATE", "TAUT", "TEAL", "TEAM", "TEAR", "TECH", "TEEM",
|
||||
"TEEN", "TEET", "TELL", "TEND", "TENT", "TERM", "TERN", "TESS",
|
||||
"TEST", "THAN", "THAT", "THEE", "THEM", "THEN", "THEY", "THIN",
|
||||
"THIS", "THUD", "THUG", "TICK", "TIDE", "TIDY", "TIED", "TIER",
|
||||
"TILE", "TILL", "TILT", "TIME", "TINA", "TINE", "TINT", "TINY",
|
||||
"TIRE", "TOAD", "TOGO", "TOIL", "TOLD", "TOLL", "TONE", "TONG",
|
||||
"TONY", "TOOK", "TOOL", "TOOT", "TORE", "TORN", "TOTE", "TOUR",
|
||||
"TOUT", "TOWN", "TRAG", "TRAM", "TRAY", "TREE", "TREK", "TRIG",
|
||||
"TRIM", "TRIO", "TROD", "TROT", "TROY", "TRUE", "TUBA", "TUBE",
|
||||
"TUCK", "TUFT", "TUNA", "TUNE", "TUNG", "TURF", "TURN", "TUSK",
|
||||
"TWIG", "TWIN", "TWIT", "ULAN", "UNIT", "URGE", "USED", "USER",
|
||||
"USES", "UTAH", "VAIL", "VAIN", "VALE", "VARY", "VASE", "VAST",
|
||||
"VEAL", "VEDA", "VEIL", "VEIN", "VEND", "VENT", "VERB", "VERY",
|
||||
"VETO", "VICE", "VIEW", "VINE", "VISE", "VOID", "VOLT", "VOTE",
|
||||
"WACK", "WADE", "WAGE", "WAIL", "WAIT", "WAKE", "WALE", "WALK",
|
||||
"WALL", "WALT", "WAND", "WANE", "WANG", "WANT", "WARD", "WARM",
|
||||
"WARN", "WART", "WASH", "WAST", "WATS", "WATT", "WAVE", "WAVY",
|
||||
"WAYS", "WEAK", "WEAL", "WEAN", "WEAR", "WEED", "WEEK", "WEIR",
|
||||
"WELD", "WELL", "WELT", "WENT", "WERE", "WERT", "WEST", "WHAM",
|
||||
"WHAT", "WHEE", "WHEN", "WHET", "WHOA", "WHOM", "WICK", "WIFE",
|
||||
"WILD", "WILL", "WIND", "WINE", "WING", "WINK", "WINO", "WIRE",
|
||||
"WISE", "WISH", "WITH", "WOLF", "WONT", "WOOD", "WOOL", "WORD",
|
||||
"WORE", "WORK", "WORM", "WORN", "WOVE", "WRIT", "WYNN", "YALE",
|
||||
"YANG", "YANK", "YARD", "YARN", "YAWL", "YAWN", "YEAH", "YEAR",
|
||||
"YELL", "YOGA", "YOKE"]
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Transaction } from '../models/transactions';
|
||||
import Wallet from '.';
|
||||
declare function multisign(transactions: Array<Transaction | string>): string;
|
||||
declare function authorizeChannel(wallet: Wallet, channelId: string, amount: string): string;
|
||||
declare function verifySignature(tx: Transaction | string): boolean;
|
||||
export { authorizeChannel, verifySignature, multisign };
|
||||
//# sourceMappingURL=signer.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../src/Wallet/signer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAY,MAAM,wBAAwB,CAAA;AAE9D,OAAO,MAAM,MAAM,GAAG,CAAA;AActB,iBAAS,SAAS,CAAC,YAAY,EAAE,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,GAAG,MAAM,CAmCpE;AAWD,iBAAS,gBAAgB,CACvB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,MAAM,CAOR;AASD,iBAAS,eAAe,CAAC,EAAE,EAAE,WAAW,GAAG,MAAM,GAAG,OAAO,CAO1D;AAuED,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,CAAA"}
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.multisign = exports.verifySignature = exports.authorizeChannel = void 0;
|
||||
const bignumber_js_1 = require("bignumber.js");
|
||||
const lodash_1 = require("lodash");
|
||||
const ripple_address_codec_1 = require("ripple-address-codec");
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const ripple_keypairs_1 = require("ripple-keypairs");
|
||||
const errors_1 = require("../errors");
|
||||
const transactions_1 = require("../models/transactions");
|
||||
function multisign(transactions) {
|
||||
if (transactions.length === 0) {
|
||||
throw new errors_1.ValidationError('There were 0 transactions to multisign');
|
||||
}
|
||||
transactions.forEach((txOrBlob) => {
|
||||
const tx = getDecodedTransaction(txOrBlob);
|
||||
(0, transactions_1.validate)(tx);
|
||||
if (tx.Signers == null || tx.Signers.length === 0) {
|
||||
throw new errors_1.ValidationError("For multisigning all transactions must include a Signers field containing an array of signatures. You may have forgotten to pass the 'forMultisign' parameter when signing.");
|
||||
}
|
||||
if (tx.SigningPubKey !== '') {
|
||||
throw new errors_1.ValidationError('SigningPubKey must be an empty string for all transactions when multisigning.');
|
||||
}
|
||||
});
|
||||
const decodedTransactions = transactions.map((txOrBlob) => {
|
||||
return getDecodedTransaction(txOrBlob);
|
||||
});
|
||||
validateTransactionEquivalence(decodedTransactions);
|
||||
return (0, ripple_binary_codec_1.encode)(getTransactionWithAllSigners(decodedTransactions));
|
||||
}
|
||||
exports.multisign = multisign;
|
||||
function authorizeChannel(wallet, channelId, amount) {
|
||||
const signingData = (0, ripple_binary_codec_1.encodeForSigningClaim)({
|
||||
channel: channelId,
|
||||
amount,
|
||||
});
|
||||
return (0, ripple_keypairs_1.sign)(signingData, wallet.privateKey);
|
||||
}
|
||||
exports.authorizeChannel = authorizeChannel;
|
||||
function verifySignature(tx) {
|
||||
const decodedTx = getDecodedTransaction(tx);
|
||||
return (0, ripple_keypairs_1.verify)((0, ripple_binary_codec_1.encodeForSigning)(decodedTx), decodedTx.TxnSignature, decodedTx.SigningPubKey);
|
||||
}
|
||||
exports.verifySignature = verifySignature;
|
||||
function validateTransactionEquivalence(transactions) {
|
||||
const exampleTransaction = JSON.stringify(Object.assign(Object.assign({}, transactions[0]), { Signers: null }));
|
||||
if (transactions
|
||||
.slice(1)
|
||||
.some((tx) => JSON.stringify(Object.assign(Object.assign({}, tx), { Signers: null })) !== exampleTransaction)) {
|
||||
throw new errors_1.ValidationError('txJSON is not the same for all signedTransactions');
|
||||
}
|
||||
}
|
||||
function getTransactionWithAllSigners(transactions) {
|
||||
const sortedSigners = (0, lodash_1.flatMap)(transactions, (tx) => { var _a; return (_a = tx.Signers) !== null && _a !== void 0 ? _a : []; }).sort(compareSigners);
|
||||
return Object.assign(Object.assign({}, transactions[0]), { Signers: sortedSigners });
|
||||
}
|
||||
function compareSigners(left, right) {
|
||||
return addressToBigNumber(left.Signer.Account).comparedTo(addressToBigNumber(right.Signer.Account));
|
||||
}
|
||||
function addressToBigNumber(address) {
|
||||
const hex = Buffer.from((0, ripple_address_codec_1.decodeAccountID)(address)).toString('hex');
|
||||
const numberOfBitsInHex = 16;
|
||||
return new bignumber_js_1.BigNumber(hex, numberOfBitsInHex);
|
||||
}
|
||||
function getDecodedTransaction(txOrBlob) {
|
||||
if (typeof txOrBlob === 'object') {
|
||||
return (0, ripple_binary_codec_1.decode)((0, ripple_binary_codec_1.encode)(txOrBlob));
|
||||
}
|
||||
return (0, ripple_binary_codec_1.decode)(txOrBlob);
|
||||
}
|
||||
//# sourceMappingUR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H,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,IAAA,sCAAe,EAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IACjE,MAAM,iBAAiB,GAAG,EAAE,CAAA;IAC5B,OAAO,IAAI,wBAAS,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAA;AAC9C,CAAC;AAED,SAAS,qBAAqB,CAAC,QAA8B;IAC3D,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAGhC,OAAO,IAAA,4BAAM,EAAC,IAAA,4BAAM,EAAC,QAAQ,CAAC,CAA2B,CAAA;KAC1D;IAGD,OAAO,IAAA,4BAAM,EAAC,QAAQ,CAA2B,CAAA;AACnD,CAAC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import { Client, ClientOptions } from '.';
|
||||
export default class BroadcastClient extends Client {
|
||||
private readonly clients;
|
||||
constructor(servers: string[], options?: ClientOptions);
|
||||
private getMethodNames;
|
||||
}
|
||||
//# sourceMappingURL=BroadcastClient.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BroadcastClient.d.ts","sourceRoot":"","sources":["../../../src/client/BroadcastClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,CAAA;AAiBzC,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,MAAM;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBASf,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,GAAE,aAAkB;IAsCjE,OAAO,CAAC,cAAc;CAkBvB"}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const _1 = require(".");
|
||||
class BroadcastClient extends _1.Client {
|
||||
constructor(servers, options = {}) {
|
||||
super(servers[0], options);
|
||||
const clients = servers.map((server) => new _1.Client(server, options));
|
||||
this.clients = clients;
|
||||
this.getMethodNames().forEach((name) => {
|
||||
this[name] = (...args) => __awaiter(this, void 0, void 0, function* () { return Promise.race(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client[name](...args); }))); });
|
||||
});
|
||||
this.connect = () => __awaiter(this, void 0, void 0, function* () {
|
||||
yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.connect(); })));
|
||||
});
|
||||
this.disconnect = () => __awaiter(this, void 0, void 0, function* () {
|
||||
yield Promise.all(clients.map((client) => __awaiter(this, void 0, void 0, function* () { return client.disconnect(); })));
|
||||
});
|
||||
this.isConnected = () => clients.map((client) => client.isConnected()).every(Boolean);
|
||||
clients.forEach((client) => {
|
||||
client.on('error', (errorCode, errorMessage, data) => this.emit('error', errorCode, errorMessage, data));
|
||||
});
|
||||
}
|
||||
getMethodNames() {
|
||||
const methodNames = [];
|
||||
const firstClient = this.clients[0];
|
||||
const methods = Object.getOwnPropertyNames(firstClient);
|
||||
methods.push(...Object.getOwnPropertyNames(Object.getPrototypeOf(firstClient)));
|
||||
for (const name of methods) {
|
||||
if (typeof firstClient[name] === 'function' &&
|
||||
name !== 'constructor' &&
|
||||
name !== 'on') {
|
||||
methodNames.push(name);
|
||||
}
|
||||
}
|
||||
return methodNames;
|
||||
}
|
||||
}
|
||||
exports.default = BroadcastClient;
|
||||
//# sourceMappingURL=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CAAA;QACvE,CAAC,CAAA,CAAA;QACD,IAAI,CAAC,WAAW,GAAG,GAAY,EAAE,CAC/B,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;QAE9D,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;YACzB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CACnD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,CAAC,CAClD,CAAA;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAOO,cAAc;QACpB,MAAM,WAAW,GAAa,EAAE,CAAA;QAChC,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;QACnC,MAAM,OAAO,GAAG,MAAM,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CACV,GAAG,MAAM,CAAC,mBAAmB,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAClE,CAAA;QACD,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YAC1B,IACE,OAAO,WAAW,CAAC,IAAI,CAAC,KAAK,UAAU;gBACvC,IAAI,KAAK,aAAa;gBACtB,IAAI,KAAK,IAAI,EACb;gBACA,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACvB;SACF;QACD,OAAO,WAAW,CAAA;IACpB,CAAC;CACF;AAlED,kCAkEC"}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
export default class ConnectionManager {
|
||||
private promisesAwaitingConnection;
|
||||
resolveAllAwaiting(): void;
|
||||
rejectAllAwaiting(error: Error): void;
|
||||
awaitConnection(): Promise<void>;
|
||||
}
|
||||
//# sourceMappingURL=ConnectionManager.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ConnectionManager.d.ts","sourceRoot":"","sources":["../../../src/client/ConnectionManager.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,OAAO,CAAC,0BAA0B,CAG3B;IAKA,kBAAkB,IAAI,IAAI;IAU1B,iBAAiB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAU/B,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAK9C"}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
class ConnectionManager {
|
||||
constructor() {
|
||||
this.promisesAwaitingConnection = [];
|
||||
}
|
||||
resolveAllAwaiting() {
|
||||
this.promisesAwaitingConnection.map(({ resolve }) => resolve());
|
||||
this.promisesAwaitingConnection = [];
|
||||
}
|
||||
rejectAllAwaiting(error) {
|
||||
this.promisesAwaitingConnection.map(({ reject }) => reject(error));
|
||||
this.promisesAwaitingConnection = [];
|
||||
}
|
||||
awaitConnection() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.promisesAwaitingConnection.push({ resolve, reject });
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.default = ConnectionManager;
|
||||
//# sourceMappingURL=ConnectionManager.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../src/client/ConnectionManager.ts"],"names":[],"mappings":";;;;;;;;;;;AAKA,MAAqB,iBAAiB;IAAtC;QACU,+BAA0B,GAG7B,EAAE,CAAA;IA8BT,CAAC;IAzBQ,kBAAkB;QACvB,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAA;QAC/D,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAA;IACtC,CAAC;IAOM,iBAAiB,CAAC,KAAY;QACnC,IAAI,CAAC,0BAA0B,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC,0BAA0B,GAAG,EAAE,CAAA;IACtC,CAAC;IAOY,eAAe;;YAC1B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBACrC,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAA;YAC3D,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AAlCD,oCAkCC"}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
interface ExponentialBackoffOptions {
|
||||
min?: number;
|
||||
max?: number;
|
||||
}
|
||||
export default class ExponentialBackoff {
|
||||
private readonly ms;
|
||||
private readonly max;
|
||||
private readonly factor;
|
||||
private numAttempts;
|
||||
constructor(opts?: ExponentialBackoffOptions);
|
||||
get attempts(): number;
|
||||
duration(): number;
|
||||
reset(): void;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=ExponentialBackoff.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExponentialBackoff.d.ts","sourceRoot":"","sources":["../../../src/client/ExponentialBackoff.ts"],"names":[],"mappings":"AAcA,UAAU,yBAAyB;IAEjC,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AASD,MAAM,CAAC,OAAO,OAAO,kBAAkB;IACrC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAQ;IAC3B,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,WAAW,CAAI;gBAOJ,IAAI,GAAE,yBAA8B;IAUvD,IAAW,QAAQ,IAAI,MAAM,CAE5B;IAOM,QAAQ,IAAI,MAAM;IASlB,KAAK,IAAI,IAAI;CAGrB"}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const DEFAULT_MIN = 100;
|
||||
const DEFAULT_MAX = 1000;
|
||||
class ExponentialBackoff {
|
||||
constructor(opts = {}) {
|
||||
var _a, _b;
|
||||
this.factor = 2;
|
||||
this.numAttempts = 0;
|
||||
this.ms = (_a = opts.min) !== null && _a !== void 0 ? _a : DEFAULT_MIN;
|
||||
this.max = (_b = opts.max) !== null && _b !== void 0 ? _b : DEFAULT_MAX;
|
||||
}
|
||||
get attempts() {
|
||||
return this.numAttempts;
|
||||
}
|
||||
duration() {
|
||||
const ms = this.ms * Math.pow(this.factor, this.numAttempts);
|
||||
this.numAttempts += 1;
|
||||
return Math.floor(Math.min(ms, this.max));
|
||||
}
|
||||
reset() {
|
||||
this.numAttempts = 0;
|
||||
}
|
||||
}
|
||||
exports.default = ExponentialBackoff;
|
||||
//# sourceMappingURL=ExponentialBackoff.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"ExponentialBackoff.js","sourceRoot":"","sources":["../../../src/client/ExponentialBackoff.ts"],"names":[],"mappings":";;AAqBA,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,WAAW,GAAG,IAAI,CAAA;AAMxB,MAAqB,kBAAkB;IAWrC,YAAmB,OAAkC,EAAE;;QARtC,WAAM,GAAW,CAAC,CAAA;QAC3B,gBAAW,GAAG,CAAC,CAAA;QAQrB,IAAI,CAAC,EAAE,GAAG,MAAA,IAAI,CAAC,GAAG,mCAAI,WAAW,CAAA;QACjC,IAAI,CAAC,GAAG,GAAG,MAAA,IAAI,CAAC,GAAG,mCAAI,WAAW,CAAA;IACpC,CAAC;IAOD,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAOM,QAAQ;QACb,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,GAAG,SAAA,IAAI,CAAC,MAAM,EAAI,IAAI,CAAC,WAAW,CAAA,CAAA;QACpD,IAAI,CAAC,WAAW,IAAI,CAAC,CAAA;QACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC;IAKM,KAAK;QACV,IAAI,CAAC,WAAW,GAAG,CAAC,CAAA;IACtB,CAAC;CACF;AA1CD,qCA0CC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Response } from '../models/methods';
|
||||
import { BaseRequest, ErrorResponse } from '../models/methods/baseMethod';
|
||||
export default class RequestManager {
|
||||
private nextId;
|
||||
private readonly promisesAwaitingResponse;
|
||||
resolve(id: string | number, response: Response): void;
|
||||
reject(id: string | number, error: Error): void;
|
||||
rejectAll(error: Error): void;
|
||||
createRequest<T extends BaseRequest>(request: T, timeout: number): [string | number, string, Promise<Response>];
|
||||
handleResponse(response: Partial<Response | ErrorResponse>): void;
|
||||
private deletePromise;
|
||||
}
|
||||
//# sourceMappingURL=RequestManager.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestManager.d.ts","sourceRoot":"","sources":["../../../src/client/RequestManager.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC5C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAQzE,MAAM,CAAC,OAAO,OAAO,cAAc;IACjC,OAAO,CAAC,MAAM,CAAI;IAClB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAOtC;IASI,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAoBtD,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI;IAmB/C,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAiB7B,aAAa,CAAC,CAAC,SAAS,WAAW,EACxC,OAAO,EAAE,CAAC,EACV,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAuDxC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,GAAG,IAAI;IA2CxE,OAAO,CAAC,aAAa;CAGtB"}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const errors_1 = require("../errors");
|
||||
class RequestManager {
|
||||
constructor() {
|
||||
this.nextId = 0;
|
||||
this.promisesAwaitingResponse = new Map();
|
||||
}
|
||||
resolve(id, response) {
|
||||
const promise = this.promisesAwaitingResponse.get(id);
|
||||
if (promise == null) {
|
||||
throw new errors_1.XrplError(`No existing promise with id ${id}`, {
|
||||
type: 'resolve',
|
||||
response,
|
||||
});
|
||||
}
|
||||
clearTimeout(promise.timer);
|
||||
promise.resolve(response);
|
||||
this.deletePromise(id);
|
||||
}
|
||||
reject(id, error) {
|
||||
const promise = this.promisesAwaitingResponse.get(id);
|
||||
if (promise == null) {
|
||||
throw new errors_1.XrplError(`No existing promise with id ${id}`, {
|
||||
type: 'reject',
|
||||
error,
|
||||
});
|
||||
}
|
||||
clearTimeout(promise.timer);
|
||||
promise.reject(error);
|
||||
this.deletePromise(id);
|
||||
}
|
||||
rejectAll(error) {
|
||||
this.promisesAwaitingResponse.forEach((_promise, id, _map) => {
|
||||
this.reject(id, error);
|
||||
this.deletePromise(id);
|
||||
});
|
||||
}
|
||||
createRequest(request, timeout) {
|
||||
let newId;
|
||||
if (request.id == null) {
|
||||
newId = this.nextId;
|
||||
this.nextId += 1;
|
||||
}
|
||||
else {
|
||||
newId = request.id;
|
||||
}
|
||||
const newRequest = JSON.stringify(Object.assign(Object.assign({}, request), { id: newId }));
|
||||
const timer = setTimeout(() => {
|
||||
this.reject(newId, new errors_1.TimeoutError(`Timeout for request: ${JSON.stringify(request)} with id ${newId}`, request));
|
||||
}, timeout);
|
||||
if (timer.unref) {
|
||||
;
|
||||
timer.unref();
|
||||
}
|
||||
if (this.promisesAwaitingResponse.has(newId)) {
|
||||
clearTimeout(timer);
|
||||
throw new errors_1.XrplError(`Response with id '${newId}' is already pending`, request);
|
||||
}
|
||||
const newPromise = new Promise((resolve, reject) => {
|
||||
this.promisesAwaitingResponse.set(newId, { resolve, reject, timer });
|
||||
});
|
||||
return [newId, newRequest, newPromise];
|
||||
}
|
||||
handleResponse(response) {
|
||||
var _a, _b;
|
||||
if (response.id == null ||
|
||||
!(typeof response.id === 'string' || typeof response.id === 'number')) {
|
||||
throw new errors_1.ResponseFormatError('valid id not found in response', response);
|
||||
}
|
||||
if (!this.promisesAwaitingResponse.has(response.id)) {
|
||||
return;
|
||||
}
|
||||
if (response.status == null) {
|
||||
const error = new errors_1.ResponseFormatError('Response has no status');
|
||||
this.reject(response.id, error);
|
||||
}
|
||||
if (response.status === 'error') {
|
||||
const errorResponse = response;
|
||||
const error = new errors_1.RippledError((_a = errorResponse.error_message) !== null && _a !== void 0 ? _a : errorResponse.error, errorResponse);
|
||||
this.reject(response.id, error);
|
||||
return;
|
||||
}
|
||||
if (response.status !== 'success') {
|
||||
const error = new errors_1.ResponseFormatError(`unrecognized response.status: ${(_b = response.status) !== null && _b !== void 0 ? _b : ''}`, response);
|
||||
this.reject(response.id, error);
|
||||
return;
|
||||
}
|
||||
delete response.status;
|
||||
this.resolve(response.id, response);
|
||||
}
|
||||
deletePromise(id) {
|
||||
this.promisesAwaitingResponse.delete(id);
|
||||
}
|
||||
}
|
||||
exports.default = RequestManager;
|
||||
//# sourceMappingURL=RequestManager.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"RequestManager.js","sourceRoot":"","sources":["../../../src/client/RequestManager.ts"],"names":[],"mappings":";;AAAA,sCAKkB;AAUlB,MAAqB,cAAc;IAAnC;QACU,WAAM,GAAG,CAAC,CAAA;QACD,6BAAwB,GAAG,IAAI,GAAG,EAOhD,CAAA;IAyKL,CAAC;IAhKQ,OAAO,CAAC,EAAmB,EAAE,QAAkB;QACpD,MAAM,OAAO,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACrD,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,kBAAS,CAAC,+BAA+B,EAAE,EAAE,EAAE;gBACvD,IAAI,EAAE,SAAS;gBACf,QAAQ;aACT,CAAC,CAAA;SACH;QACD,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAC3B,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACzB,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC,CAAA;IACxB,CAAC;IASM,MAAM,CAAC,EAAmB,EAAE,KAAY;QAC7C,MAAM,OAAO,GAAG,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;QACrD,IAAI,OAAO,IAAI,IAAI,EAAE;YACnB,MAAM,IAAI,kBAAS,CAAC,+BAA+B,EAAE,EAAE,EAAE;gBACvD,IAAI,EAAE,QAAQ;gBACd,KAAK;aACN,CAAC,CAAA;SACH;QACD,YAAY,CAAC,OAAO,CAAC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B,CACnC,iCAAiC,MAAA,QAAQ,CAAC,MAAM,mCAAI,EAAE,EAAE,EACxD,QAAQ,CACT,CAAA;YACD,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAA;YAC/B,OAAM;SACP;QAED,OAAO,QAAQ,CAAC,MAAM,CAAA;QAEtB,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,EAAE,QAA+B,CAAC,CAAA;IAC5D,CAAC;IAOO,aAAa,CAAC,EAAmB;QACvC,IAAI,CAAC,wBAAwB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IAC1C,CAAC;CACF;AAlLD,iCAkLC"}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
interface WSWrapperOptions {
|
||||
perMessageDeflate: boolean;
|
||||
handshakeTimeout: number;
|
||||
protocolVersion: number;
|
||||
origin: string;
|
||||
maxPayload: number;
|
||||
followRedirects: boolean;
|
||||
maxRedirects: number;
|
||||
}
|
||||
export default class WSWrapper extends EventEmitter {
|
||||
static CONNECTING: number;
|
||||
static OPEN: number;
|
||||
static CLOSING: number;
|
||||
static CLOSED: number;
|
||||
private readonly ws;
|
||||
constructor(url: string, _protocols: string | string[] | WSWrapperOptions | undefined, _websocketOptions: WSWrapperOptions);
|
||||
get readyState(): number;
|
||||
close(code?: number, reason?: Buffer): void;
|
||||
send(message: string): void;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=WSWrapper.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WSWrapper.d.ts","sourceRoot":"","sources":["../../../src/client/WSWrapper.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAcrC,UAAU,gBAAgB;IACxB,iBAAiB,EAAE,OAAO,CAAA;IAC1B,gBAAgB,EAAE,MAAM,CAAA;IACxB,eAAe,EAAE,MAAM,CAAA;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,eAAe,EAAE,OAAO,CAAA;IACxB,YAAY,EAAE,MAAM,CAAA;CACrB;AAMD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,YAAY;IACjD,OAAc,UAAU,SAAI;IAC5B,OAAc,IAAI,SAAI;IACtB,OAAc,OAAO,SAAI;IAEzB,OAAc,MAAM,SAAI;IACxB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAW;gBAU5B,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,gBAAgB,GAAG,SAAS,EAC5D,iBAAiB,EAAE,gBAAgB;IAkCrC,IAAW,UAAU,IAAI,MAAM,CAE9B;IAQM,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAW3C,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;CAGnC"}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const events_1 = require("events");
|
||||
class WSWrapper extends events_1.EventEmitter {
|
||||
constructor(url, _protocols, _websocketOptions) {
|
||||
super();
|
||||
this.setMaxListeners(Infinity);
|
||||
this.ws = new WebSocket(url);
|
||||
this.ws.onclose = (closeEvent) => {
|
||||
let reason;
|
||||
if (closeEvent.reason) {
|
||||
const enc = new TextEncoder();
|
||||
reason = enc.encode(closeEvent.reason);
|
||||
}
|
||||
this.emit('close', closeEvent.code, reason);
|
||||
};
|
||||
this.ws.onopen = () => {
|
||||
this.emit('open');
|
||||
};
|
||||
this.ws.onerror = (error) => {
|
||||
this.emit('error', error);
|
||||
};
|
||||
this.ws.onmessage = (message) => {
|
||||
this.emit('message', message.data);
|
||||
};
|
||||
}
|
||||
get readyState() {
|
||||
return this.ws.readyState;
|
||||
}
|
||||
close(code, reason) {
|
||||
if (this.readyState === 1) {
|
||||
this.ws.close(code, reason);
|
||||
}
|
||||
}
|
||||
send(message) {
|
||||
this.ws.send(message);
|
||||
}
|
||||
}
|
||||
exports.default = WSWrapper;
|
||||
WSWrapper.CONNECTING = 0;
|
||||
WSWrapper.OPEN = 1;
|
||||
WSWrapper.CLOSING = 2;
|
||||
WSWrapper.CLOSED = 3;
|
||||
//# sourceMappingURL=WSWrapper.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"WSWrapper.js","sourceRoot":"","sources":["../../../src/client/WSWrapper.ts"],"names":[],"mappings":";;AACA,mCAAqC;AA4BrC,MAAqB,SAAU,SAAQ,qBAAY;IAejD,YACE,GAAW,EACX,UAA4D,EAC5D,iBAAmC;QAEnC,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAA;QAE9B,IAAI,CAAC,EAAE,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,CAAA;QAE5B,IAAI,CAAC,EAAE,CAAC,OAAO,GAAG,CAAC,UAAsB,EAAQ,EAAE;YACjD,IAAI,MAA8B,CAAA;YAClC,IAAI,UAAU,CAAC,MAAM,EAAE;gBACrB,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;gBAC7B,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAA;aACvC;YACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,GAAS,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnB,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,OAAO,GAAG,CAAC,KAAK,EAAQ,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;QAC3B,CAAC,CAAA;QAED,IAAI,CAAC,EAAE,CAAC,SAAS,GAAG,CAAC,OAAqB,EAAQ,EAAE;YAClD,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;QACpC,CAAC,CAAA;IACH,CAAC;IAOD,IAAW,UAAU;QACnB,OAAO,IAAI,CAAC,EAAE,CAAC,UAAU,CAAA;IAC3B,CAAC;IAQM,KAAK,CAAC,IAAa,EAAE,MAAe;QACzC,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,EAAE;YACzB,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;SAC5B;IACH,CAAC;IAOM,IAAI,CAAC,OAAe;QACzB,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IACvB,CAAC;;AA3EH,4BA4EC;AA3Ee,oBAAU,GAAG,CAAC,CAAA;AACd,cAAI,GAAG,CAAC,CAAA;AACR,iBAAO,GAAG,CAAC,CAAA;AAEX,gBAAM,GAAG,CAAC,CAAA"}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { BaseRequest } from '../models/methods/baseMethod';
|
||||
interface ConnectionOptions {
|
||||
trace?: boolean | ((id: string, message: string) => void);
|
||||
proxy?: string;
|
||||
proxyAuthorization?: string;
|
||||
authorization?: string;
|
||||
trustedCertificates?: string[];
|
||||
key?: string;
|
||||
passphrase?: string;
|
||||
certificate?: string;
|
||||
timeout: number;
|
||||
connectionTimeout: number;
|
||||
headers?: {
|
||||
[key: string]: string;
|
||||
};
|
||||
}
|
||||
export type ConnectionUserOptions = Partial<ConnectionOptions>;
|
||||
export declare const INTENTIONAL_DISCONNECT_CODE = 4000;
|
||||
export declare class Connection extends EventEmitter {
|
||||
private readonly url;
|
||||
private ws;
|
||||
private reconnectTimeoutID;
|
||||
private heartbeatIntervalID;
|
||||
private readonly retryConnectionBackoff;
|
||||
private readonly config;
|
||||
private readonly requestManager;
|
||||
private readonly connectionManager;
|
||||
constructor(url?: string, options?: ConnectionUserOptions);
|
||||
private get state();
|
||||
private get shouldBeConnected();
|
||||
isConnected(): boolean;
|
||||
connect(): Promise<void>;
|
||||
disconnect(): Promise<number | undefined>;
|
||||
reconnect(): Promise<void>;
|
||||
request<T extends BaseRequest>(request: T, timeout?: number): Promise<unknown>;
|
||||
getUrl(): string;
|
||||
readonly trace: (id: string, message: string) => void;
|
||||
private onMessage;
|
||||
private onceOpen;
|
||||
private intentionalDisconnect;
|
||||
private clearHeartbeatInterval;
|
||||
private startHeartbeatInterval;
|
||||
private heartbeat;
|
||||
private onConnectionFailed;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=connection.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/client/connection.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAYrC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAa1D,UAAU,iBAAiB;IACzB,KAAK,CAAC,EAAE,OAAO,GAAG,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,CAAA;IACzD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,OAAO,EAAE,MAAM,CAAA;IACf,iBAAiB,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE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";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Connection = exports.INTENTIONAL_DISCONNECT_CODE = void 0;
|
||||
const events_1 = require("events");
|
||||
const omitBy_1 = __importDefault(require("lodash/omitBy"));
|
||||
const ws_1 = __importDefault(require("ws"));
|
||||
const errors_1 = require("../errors");
|
||||
const ConnectionManager_1 = __importDefault(require("./ConnectionManager"));
|
||||
const ExponentialBackoff_1 = __importDefault(require("./ExponentialBackoff"));
|
||||
const RequestManager_1 = __importDefault(require("./RequestManager"));
|
||||
const SECONDS_PER_MINUTE = 60;
|
||||
const TIMEOUT = 20;
|
||||
const CONNECTION_TIMEOUT = 5;
|
||||
exports.INTENTIONAL_DISCONNECT_CODE = 4000;
|
||||
function getAgent(url, config) {
|
||||
if (config.proxy == null) {
|
||||
return undefined;
|
||||
}
|
||||
const parsedURL = new URL(url);
|
||||
const parsedProxyURL = new URL(config.proxy);
|
||||
const proxyOptions = (0, omitBy_1.default)({
|
||||
secureEndpoint: parsedURL.protocol === 'wss:',
|
||||
secureProxy: parsedProxyURL.protocol === 'https:',
|
||||
auth: config.proxyAuthorization,
|
||||
ca: config.trustedCertificates,
|
||||
key: config.key,
|
||||
passphrase: config.passphrase,
|
||||
cert: config.certificate,
|
||||
href: parsedProxyURL.href,
|
||||
origin: parsedProxyURL.origin,
|
||||
protocol: parsedProxyURL.protocol,
|
||||
username: parsedProxyURL.username,
|
||||
password: parsedProxyURL.password,
|
||||
host: parsedProxyURL.host,
|
||||
hostname: parsedProxyURL.hostname,
|
||||
port: parsedProxyURL.port,
|
||||
pathname: parsedProxyURL.pathname,
|
||||
search: parsedProxyURL.search,
|
||||
hash: parsedProxyURL.hash,
|
||||
}, (value) => value == null);
|
||||
let HttpsProxyAgent;
|
||||
try {
|
||||
HttpsProxyAgent = require('https-proxy-agent');
|
||||
}
|
||||
catch (_error) {
|
||||
throw new Error('"proxy" option is not supported in the browser');
|
||||
}
|
||||
return new HttpsProxyAgent(proxyOptions);
|
||||
}
|
||||
function createWebSocket(url, config) {
|
||||
const options = {};
|
||||
options.agent = getAgent(url, config);
|
||||
if (config.headers) {
|
||||
options.headers = config.headers;
|
||||
}
|
||||
if (config.authorization != null) {
|
||||
const base64 = Buffer.from(config.authorization).toString('base64');
|
||||
options.headers = Object.assign(Object.assign({}, options.headers), { Authorization: `Basic ${base64}` });
|
||||
}
|
||||
const optionsOverrides = (0, omitBy_1.default)({
|
||||
ca: config.trustedCertificates,
|
||||
key: config.key,
|
||||
passphrase: config.passphrase,
|
||||
cert: config.certificate,
|
||||
}, (value) => value == null);
|
||||
const websocketOptions = Object.assign(Object.assign({}, options), optionsOverrides);
|
||||
const websocket = new ws_1.default(url, websocketOptions);
|
||||
if (typeof websocket.setMaxListeners === 'function') {
|
||||
websocket.setMaxListeners(Infinity);
|
||||
}
|
||||
return websocket;
|
||||
}
|
||||
function websocketSendAsync(ws, message) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return new Promise((resolve, reject) => {
|
||||
ws.send(message, (error) => {
|
||||
if (error) {
|
||||
reject(new errors_1.DisconnectedError(error.message, error));
|
||||
}
|
||||
else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
class Connection extends events_1.EventEmitter {
|
||||
constructor(url, options = {}) {
|
||||
super();
|
||||
this.ws = null;
|
||||
this.reconnectTimeoutID = null;
|
||||
this.heartbeatIntervalID = null;
|
||||
this.retryConnectionBackoff = new ExponentialBackoff_1.default({
|
||||
min: 100,
|
||||
max: SECONDS_PER_MINUTE * 1000,
|
||||
});
|
||||
this.requestManager = new RequestManager_1.default();
|
||||
this.connectionManager = new ConnectionManager_1.default();
|
||||
this.trace = () => { };
|
||||
this.setMaxListeners(Infinity);
|
||||
this.url = url;
|
||||
this.config = Object.assign({ timeout: TIMEOUT * 1000, connectionTimeout: CONNECTION_TIMEOUT * 1000 }, options);
|
||||
if (typeof options.trace === 'function') {
|
||||
this.trace = options.trace;
|
||||
}
|
||||
else if (options.trace) {
|
||||
this.trace = console.log;
|
||||
}
|
||||
}
|
||||
get state() {
|
||||
return this.ws ? this.ws.readyState : ws_1.default.CLOSED;
|
||||
}
|
||||
get shouldBeConnected() {
|
||||
return this.ws !== null;
|
||||
}
|
||||
isConnected() {
|
||||
return this.state === ws_1.default.OPEN;
|
||||
}
|
||||
connect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.isConnected()) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
if (this.state === ws_1.default.CONNECTING) {
|
||||
return this.connectionManager.awaitConnection();
|
||||
}
|
||||
if (!this.url) {
|
||||
return Promise.reject(new errors_1.ConnectionError('Cannot connect because no server was specified'));
|
||||
}
|
||||
if (this.ws != null) {
|
||||
return Promise.reject(new errors_1.XrplError('Websocket connection never cleaned up.', {
|
||||
state: this.state,
|
||||
}));
|
||||
}
|
||||
const connectionTimeoutID = setTimeout(() => {
|
||||
this.onConnectionFailed(new errors_1.ConnectionError(`Error: connect() timed out after ${this.config.connectionTimeout} ms. If your internet connection is working, the ` +
|
||||
`rippled server may be blocked or inaccessible. You can also try setting the 'connectionTimeout' option in the Client constructor.`));
|
||||
}, this.config.connectionTimeout);
|
||||
this.ws = createWebSocket(this.url, this.config);
|
||||
if (this.ws == null) {
|
||||
throw new errors_1.XrplError('Connect: created null websocket');
|
||||
}
|
||||
this.ws.on('error', (error) => this.onConnectionFailed(error));
|
||||
this.ws.on('error', () => clearTimeout(connectionTimeoutID));
|
||||
this.ws.on('close', (reason) => this.onConnectionFailed(reason));
|
||||
this.ws.on('close', () => clearTimeout(connectionTimeoutID));
|
||||
this.ws.once('open', () => {
|
||||
void this.onceOpen(connectionTimeoutID);
|
||||
});
|
||||
return this.connectionManager.awaitConnection();
|
||||
});
|
||||
}
|
||||
disconnect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.clearHeartbeatInterval();
|
||||
if (this.reconnectTimeoutID !== null) {
|
||||
clearTimeout(this.reconnectTimeoutID);
|
||||
this.reconnectTimeoutID = null;
|
||||
}
|
||||
if (this.state === ws_1.default.CLOSED) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
if (this.ws == null) {
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
if (this.ws == null) {
|
||||
resolve(undefined);
|
||||
}
|
||||
if (this.ws != null) {
|
||||
this.ws.once('close', (code) => resolve(code));
|
||||
}
|
||||
if (this.ws != null && this.state !== ws_1.default.CLOSING) {
|
||||
this.ws.close(exports.INTENTIONAL_DISCONNECT_CODE);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
reconnect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.emit('reconnect');
|
||||
yield this.disconnect();
|
||||
yield this.connect();
|
||||
});
|
||||
}
|
||||
request(request, timeout) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!this.shouldBeConnected || this.ws == null) {
|
||||
throw new errors_1.NotConnectedError(JSON.stringify(request), request);
|
||||
}
|
||||
const [id, message, responsePromise] = this.requestManager.createRequest(request, timeout !== null && timeout !== void 0 ? timeout : this.config.timeout);
|
||||
this.trace('send', message);
|
||||
websocketSendAsync(this.ws, message).catch((error) => {
|
||||
this.requestManager.reject(id, error);
|
||||
});
|
||||
return responsePromise;
|
||||
});
|
||||
}
|
||||
getUrl() {
|
||||
var _a;
|
||||
return (_a = this.url) !== null && _a !== void 0 ? _a : '';
|
||||
}
|
||||
onMessage(message) {
|
||||
this.trace('receive', message);
|
||||
let data;
|
||||
try {
|
||||
data = JSON.parse(message);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error) {
|
||||
this.emit('error', 'badMessage', error.message, message);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (data.type == null && data.error) {
|
||||
this.emit('error', data.error, data.error_message, data);
|
||||
return;
|
||||
}
|
||||
if (data.type) {
|
||||
this.emit(data.type, data);
|
||||
}
|
||||
if (data.type === 'response') {
|
||||
try {
|
||||
this.requestManager.handleResponse(data);
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error) {
|
||||
this.emit('error', 'badMessage', error.message, message);
|
||||
}
|
||||
else {
|
||||
this.emit('error', 'badMessage', error, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
onceOpen(connectionTimeoutID) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (this.ws == null) {
|
||||
throw new errors_1.XrplError('onceOpen: ws is null');
|
||||
}
|
||||
this.ws.removeAllListeners();
|
||||
clearTimeout(connectionTimeoutID);
|
||||
this.ws.on('message', (message) => this.onMessage(message));
|
||||
this.ws.on('error', (error) => this.emit('error', 'websocket', error.message, error));
|
||||
this.ws.once('close', (code, reason) => {
|
||||
if (this.ws == null) {
|
||||
throw new errors_1.XrplError('onceClose: ws is null');
|
||||
}
|
||||
this.clearHeartbeatInterval();
|
||||
this.requestManager.rejectAll(new errors_1.DisconnectedError(`websocket was closed, ${new TextDecoder('utf-8').decode(reason)}`));
|
||||
this.ws.removeAllListeners();
|
||||
this.ws = null;
|
||||
if (code === undefined) {
|
||||
const internalErrorCode = 1011;
|
||||
this.emit('disconnected', internalErrorCode);
|
||||
}
|
||||
else {
|
||||
this.emit('disconnected', code);
|
||||
}
|
||||
if (code !== exports.INTENTIONAL_DISCONNECT_CODE && code !== undefined) {
|
||||
this.intentionalDisconnect();
|
||||
}
|
||||
});
|
||||
try {
|
||||
this.retryConnectionBackoff.reset();
|
||||
this.startHeartbeatInterval();
|
||||
this.connectionManager.resolveAllAwaiting();
|
||||
this.emit('connected');
|
||||
}
|
||||
catch (error) {
|
||||
if (error instanceof Error) {
|
||||
this.connectionManager.rejectAllAwaiting(error);
|
||||
yield this.disconnect().catch(() => { });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
intentionalDisconnect() {
|
||||
const retryTimeout = this.retryConnectionBackoff.duration();
|
||||
this.trace('reconnect', `Retrying connection in ${retryTimeout}ms.`);
|
||||
this.emit('reconnecting', this.retryConnectionBackoff.attempts);
|
||||
this.reconnectTimeoutID = setTimeout(() => {
|
||||
this.reconnect().catch((error) => {
|
||||
this.emit('error', 'reconnect', error.message, error);
|
||||
});
|
||||
}, retryTimeout);
|
||||
}
|
||||
clearHeartbeatInterval() {
|
||||
if (this.heartbeatIntervalID) {
|
||||
clearInterval(this.heartbeatIntervalID);
|
||||
}
|
||||
}
|
||||
startHeartbeatInterval() {
|
||||
this.clearHeartbeatInterval();
|
||||
this.heartbeatIntervalID = setInterval(() => {
|
||||
void this.heartbeat();
|
||||
}, this.config.timeout);
|
||||
}
|
||||
heartbeat() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.request({ command: 'ping' }).catch(() => __awaiter(this, void 0, void 0, function* () {
|
||||
return this.reconnect().catch((error) => {
|
||||
this.emit('error', 'reconnect', error.message, error);
|
||||
});
|
||||
}));
|
||||
});
|
||||
}
|
||||
onConnectionFailed(errorOrCode) {
|
||||
if (this.ws) {
|
||||
this.ws.removeAllListeners();
|
||||
this.ws.on('error', () => {
|
||||
});
|
||||
this.ws.close();
|
||||
this.ws = null;
|
||||
}
|
||||
if (typeof errorOrCode === 'number') {
|
||||
this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError(`Connection failed with code ${errorOrCode}.`, {
|
||||
code: errorOrCode,
|
||||
}));
|
||||
}
|
||||
else if (errorOrCode === null || errorOrCode === void 0 ? void 0 : errorOrCode.message) {
|
||||
this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError(errorOrCode.message, errorOrCode));
|
||||
}
|
||||
else {
|
||||
this.connectionManager.rejectAllAwaiting(new errors_1.NotConnectedError('Connection failed.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Connection = Connection;
|
||||
//# sourceMappingURL=connection.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+92
@@ -0,0 +1,92 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
import { 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, FeeRequest, FeeResponse, ManifestRequest, ManifestResponse, ServerInfoRequest, ServerInfoResponse, ServerStateRequest, ServerStateResponse, PingRequest, PingResponse, RandomRequest, RandomResponse, LedgerStream, ValidationStream, TransactionStream, PathFindStream, PeerStatusStream, ConsensusStream, SubscribeRequest, SubscribeResponse, UnsubscribeRequest, UnsubscribeResponse, NFTBuyOffersRequest, NFTBuyOffersResponse, NFTSellOffersRequest, NFTSellOffersResponse } from '../models/methods';
|
||||
import { BaseRequest, BaseResponse } from '../models/methods/baseMethod';
|
||||
import { autofill, getLedgerIndex, getOrderbook, getBalances, getXrpBalance, submit, submitAndWait } from '../sugar';
|
||||
import fundWallet from '../Wallet/fundWallet';
|
||||
import { Connection, ConnectionUserOptions } from './connection';
|
||||
export interface ClientOptions extends ConnectionUserOptions {
|
||||
feeCushion?: number;
|
||||
maxFeeXRP?: string;
|
||||
proxy?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
declare class Client extends EventEmitter {
|
||||
readonly connection: Connection;
|
||||
readonly feeCushion: number;
|
||||
readonly maxFeeXRP: string;
|
||||
constructor(server: string, options?: ClientOptions);
|
||||
get url(): string;
|
||||
request(r: AccountChannelsRequest): Promise<AccountChannelsResponse>;
|
||||
request(r: AccountCurrenciesRequest): Promise<AccountCurrenciesResponse>;
|
||||
request(r: AccountInfoRequest): Promise<AccountInfoResponse>;
|
||||
request(r: AccountLinesRequest): Promise<AccountLinesResponse>;
|
||||
request(r: AccountNFTsRequest): Promise<AccountNFTsResponse>;
|
||||
request(r: AccountObjectsRequest): Promise<AccountObjectsResponse>;
|
||||
request(r: AccountOffersRequest): Promise<AccountOffersResponse>;
|
||||
request(r: AccountTxRequest): Promise<AccountTxResponse>;
|
||||
request(r: BookOffersRequest): Promise<BookOffersResponse>;
|
||||
request(r: ChannelVerifyRequest): Promise<ChannelVerifyResponse>;
|
||||
request(r: DepositAuthorizedRequest): Promise<DepositAuthorizedResponse>;
|
||||
request(r: FeeRequest): Promise<FeeResponse>;
|
||||
request(r: GatewayBalancesRequest): Promise<GatewayBalancesResponse>;
|
||||
request(r: LedgerRequest): Promise<LedgerResponse>;
|
||||
request(r: LedgerClosedRequest): Promise<LedgerClosedResponse>;
|
||||
request(r: LedgerCurrentRequest): Promise<LedgerCurrentResponse>;
|
||||
request(r: LedgerDataRequest): Promise<LedgerDataResponse>;
|
||||
request(r: LedgerEntryRequest): Promise<LedgerEntryResponse>;
|
||||
request(r: ManifestRequest): Promise<ManifestResponse>;
|
||||
request(r: NFTBuyOffersRequest): Promise<NFTBuyOffersResponse>;
|
||||
request(r: NFTSellOffersRequest): Promise<NFTSellOffersResponse>;
|
||||
request(r: NoRippleCheckRequest): Promise<NoRippleCheckResponse>;
|
||||
request(r: PathFindRequest): Promise<PathFindResponse>;
|
||||
request(r: PingRequest): Promise<PingResponse>;
|
||||
request(r: RandomRequest): Promise<RandomResponse>;
|
||||
request(r: RipplePathFindRequest): Promise<RipplePathFindResponse>;
|
||||
request(r: ServerInfoRequest): Promise<ServerInfoResponse>;
|
||||
request(r: ServerStateRequest): Promise<ServerStateResponse>;
|
||||
request(r: SubmitRequest): Promise<SubmitResponse>;
|
||||
request(r: SubmitMultisignedRequest): Promise<SubmitMultisignedResponse>;
|
||||
request(r: SubscribeRequest): Promise<SubscribeResponse>;
|
||||
request(r: UnsubscribeRequest): Promise<UnsubscribeResponse>;
|
||||
request(r: TransactionEntryRequest): Promise<TransactionEntryResponse>;
|
||||
request(r: TxRequest): Promise<TxResponse>;
|
||||
request<R extends BaseRequest, T extends BaseResponse>(r: R): Promise<T>;
|
||||
requestNextPage(req: AccountChannelsRequest, resp: AccountChannelsResponse): Promise<AccountChannelsResponse>;
|
||||
requestNextPage(req: AccountLinesRequest, resp: AccountLinesResponse): Promise<AccountLinesResponse>;
|
||||
requestNextPage(req: AccountObjectsRequest, resp: AccountObjectsResponse): Promise<AccountObjectsResponse>;
|
||||
requestNextPage(req: AccountOffersRequest, resp: AccountOffersResponse): Promise<AccountOffersResponse>;
|
||||
requestNextPage(req: AccountTxRequest, resp: AccountTxResponse): Promise<AccountTxResponse>;
|
||||
requestNextPage(req: LedgerDataRequest, resp: LedgerDataResponse): Promise<LedgerDataResponse>;
|
||||
on(event: 'connected', listener: () => void): this;
|
||||
on(event: 'disconnected', listener: (code: number) => void): this;
|
||||
on(event: 'ledgerClosed', listener: (ledger: LedgerStream) => void): this;
|
||||
on(event: 'validationReceived', listener: (validation: ValidationStream) => void): this;
|
||||
on(event: 'transaction', listener: (tx: TransactionStream) => void): this;
|
||||
on(event: 'peerStatusChange', listener: (status: PeerStatusStream) => void): this;
|
||||
on(event: 'consensusPhase', listener: (phase: ConsensusStream) => void): this;
|
||||
on(event: 'manifestReceived', listener: (manifest: ManifestResponse) => void): this;
|
||||
on(event: 'path_find', listener: (path: PathFindStream) => void): this;
|
||||
on(event: 'error', listener: (...err: any[]) => void): this;
|
||||
requestAll(req: AccountChannelsRequest): Promise<AccountChannelsResponse[]>;
|
||||
requestAll(req: AccountLinesRequest): Promise<AccountLinesResponse[]>;
|
||||
requestAll(req: AccountObjectsRequest): Promise<AccountObjectsResponse[]>;
|
||||
requestAll(req: AccountOffersRequest): Promise<AccountOffersResponse[]>;
|
||||
requestAll(req: AccountTxRequest): Promise<AccountTxResponse[]>;
|
||||
requestAll(req: BookOffersRequest): Promise<BookOffersResponse[]>;
|
||||
requestAll(req: LedgerDataRequest): Promise<LedgerDataResponse[]>;
|
||||
connect(): Promise<void>;
|
||||
disconnect(): Promise<void>;
|
||||
isConnected(): boolean;
|
||||
autofill: typeof autofill;
|
||||
submit: typeof submit;
|
||||
submitAndWait: typeof submitAndWait;
|
||||
prepareTransaction: typeof autofill;
|
||||
getXrpBalance: typeof getXrpBalance;
|
||||
getBalances: typeof getBalances;
|
||||
getOrderbook: typeof getOrderbook;
|
||||
getLedgerIndex: typeof getLedgerIndex;
|
||||
fundWallet: typeof fundWallet;
|
||||
}
|
||||
export { Client };
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
File diff suppressed because one or more lines are too long
+202
@@ -0,0 +1,202 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Client = void 0;
|
||||
const assert = __importStar(require("assert"));
|
||||
const events_1 = require("events");
|
||||
const errors_1 = require("../errors");
|
||||
const sugar_1 = require("../sugar");
|
||||
const fundWallet_1 = __importDefault(require("../Wallet/fundWallet"));
|
||||
const connection_1 = require("./connection");
|
||||
const partialPayment_1 = require("./partialPayment");
|
||||
function getCollectKeyFromCommand(command) {
|
||||
switch (command) {
|
||||
case 'account_channels':
|
||||
return 'channels';
|
||||
case 'account_lines':
|
||||
return 'lines';
|
||||
case 'account_objects':
|
||||
return 'account_objects';
|
||||
case 'account_tx':
|
||||
return 'transactions';
|
||||
case 'account_offers':
|
||||
case 'book_offers':
|
||||
return 'offers';
|
||||
case 'ledger_data':
|
||||
return 'state';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function clamp(value, min, max) {
|
||||
assert.ok(min <= max, 'Illegal clamp bounds');
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
const DEFAULT_FEE_CUSHION = 1.2;
|
||||
const DEFAULT_MAX_FEE_XRP = '2';
|
||||
const MIN_LIMIT = 10;
|
||||
const MAX_LIMIT = 400;
|
||||
const NORMAL_DISCONNECT_CODE = 1000;
|
||||
class Client extends events_1.EventEmitter {
|
||||
constructor(server, options = {}) {
|
||||
var _a, _b;
|
||||
super();
|
||||
this.autofill = sugar_1.autofill;
|
||||
this.submit = sugar_1.submit;
|
||||
this.submitAndWait = sugar_1.submitAndWait;
|
||||
this.prepareTransaction = sugar_1.autofill;
|
||||
this.getXrpBalance = sugar_1.getXrpBalance;
|
||||
this.getBalances = sugar_1.getBalances;
|
||||
this.getOrderbook = sugar_1.getOrderbook;
|
||||
this.getLedgerIndex = sugar_1.getLedgerIndex;
|
||||
this.fundWallet = fundWallet_1.default;
|
||||
if (typeof server !== 'string' || !/wss?(?:\+unix)?:\/\//u.exec(server)) {
|
||||
throw new errors_1.ValidationError('server URI must start with `wss://`, `ws://`, `wss+unix://`, or `ws+unix://`.');
|
||||
}
|
||||
this.feeCushion = (_a = options.feeCushion) !== null && _a !== void 0 ? _a : DEFAULT_FEE_CUSHION;
|
||||
this.maxFeeXRP = (_b = options.maxFeeXRP) !== null && _b !== void 0 ? _b : DEFAULT_MAX_FEE_XRP;
|
||||
this.connection = new connection_1.Connection(server, options);
|
||||
this.connection.on('error', (errorCode, errorMessage, data) => {
|
||||
this.emit('error', errorCode, errorMessage, data);
|
||||
});
|
||||
this.connection.on('connected', () => {
|
||||
this.emit('connected');
|
||||
});
|
||||
this.connection.on('disconnected', (code) => {
|
||||
let finalCode = code;
|
||||
if (finalCode === connection_1.INTENTIONAL_DISCONNECT_CODE) {
|
||||
finalCode = NORMAL_DISCONNECT_CODE;
|
||||
}
|
||||
this.emit('disconnected', finalCode);
|
||||
});
|
||||
this.connection.on('ledgerClosed', (ledger) => {
|
||||
this.emit('ledgerClosed', ledger);
|
||||
});
|
||||
this.connection.on('transaction', (tx) => {
|
||||
(0, partialPayment_1.handleStreamPartialPayment)(tx, this.connection.trace);
|
||||
this.emit('transaction', tx);
|
||||
});
|
||||
this.connection.on('validationReceived', (validation) => {
|
||||
this.emit('validationReceived', validation);
|
||||
});
|
||||
this.connection.on('manifestReceived', (manifest) => {
|
||||
this.emit('manifestReceived', manifest);
|
||||
});
|
||||
this.connection.on('peerStatusChange', (status) => {
|
||||
this.emit('peerStatusChange', status);
|
||||
});
|
||||
this.connection.on('consensusPhase', (consensus) => {
|
||||
this.emit('consensusPhase', consensus);
|
||||
});
|
||||
this.connection.on('path_find', (path) => {
|
||||
this.emit('path_find', path);
|
||||
});
|
||||
}
|
||||
get url() {
|
||||
return this.connection.getUrl();
|
||||
}
|
||||
request(req) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const response = (yield this.connection.request(Object.assign(Object.assign({}, req), { account: req.account
|
||||
?
|
||||
(0, sugar_1.ensureClassicAddress)(req.account)
|
||||
: undefined })));
|
||||
(0, partialPayment_1.handlePartialPayment)(req.command, response);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
requestNextPage(req, resp) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!resp.result.marker) {
|
||||
return Promise.reject(new errors_1.NotFoundError('response does not have a next page'));
|
||||
}
|
||||
const nextPageRequest = Object.assign(Object.assign({}, req), { marker: resp.result.marker });
|
||||
return this.request(nextPageRequest);
|
||||
});
|
||||
}
|
||||
on(eventName, listener) {
|
||||
return super.on(eventName, listener);
|
||||
}
|
||||
requestAll(request, collect) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const collectKey = collect !== null && collect !== void 0 ? collect : getCollectKeyFromCommand(request.command);
|
||||
if (!collectKey) {
|
||||
throw new errors_1.ValidationError(`no collect key for command ${request.command}`);
|
||||
}
|
||||
const countTo = request.limit == null ? Infinity : request.limit;
|
||||
let count = 0;
|
||||
let marker = request.marker;
|
||||
let lastBatchLength;
|
||||
const results = [];
|
||||
do {
|
||||
const countRemaining = clamp(countTo - count, MIN_LIMIT, MAX_LIMIT);
|
||||
const repeatProps = Object.assign(Object.assign({}, request), { limit: countRemaining, marker });
|
||||
const singleResponse = yield this.connection.request(repeatProps);
|
||||
const singleResult = singleResponse.result;
|
||||
if (!(collectKey in singleResult)) {
|
||||
throw new errors_1.XrplError(`${collectKey} not in result`);
|
||||
}
|
||||
const collectedData = singleResult[collectKey];
|
||||
marker = singleResult.marker;
|
||||
results.push(singleResponse);
|
||||
if (Array.isArray(collectedData)) {
|
||||
count += collectedData.length;
|
||||
lastBatchLength = collectedData.length;
|
||||
}
|
||||
else {
|
||||
lastBatchLength = 0;
|
||||
}
|
||||
} while (Boolean(marker) && count < countTo && lastBatchLength !== 0);
|
||||
return results;
|
||||
});
|
||||
}
|
||||
connect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
return this.connection.connect();
|
||||
});
|
||||
}
|
||||
disconnect() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield this.connection.disconnect();
|
||||
});
|
||||
}
|
||||
isConnected() {
|
||||
return this.connection.isConnected();
|
||||
}
|
||||
}
|
||||
exports.Client = Client;
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+4
@@ -0,0 +1,4 @@
|
||||
import type { Response, TransactionStream } from '..';
|
||||
export declare function handlePartialPayment(command: string, response: Response): void;
|
||||
export declare function handleStreamPartialPayment(stream: TransactionStream, log: (id: string, message: string) => void): void;
|
||||
//# sourceMappingURL=partialPayment.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"partialPayment.d.ts","sourceRoot":"","sources":["../../../src/client/partialPayment.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,QAAQ,EAER,iBAAiB,EAElB,MAAM,IAAI,CAAA;AAmGX,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,QAAQ,GACjB,IAAI,CAaN;AAQD,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,GACzC,IAAI,CAgBN"}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handleStreamPartialPayment = exports.handlePartialPayment = void 0;
|
||||
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
||||
const ripple_binary_codec_1 = require("ripple-binary-codec");
|
||||
const transactions_1 = require("../models/transactions");
|
||||
const utils_1 = require("../models/utils");
|
||||
const WARN_PARTIAL_PAYMENT_CODE = 2001;
|
||||
function amountsEqual(amt1, amt2) {
|
||||
if (typeof amt1 === 'string' && typeof amt2 === 'string') {
|
||||
return amt1 === amt2;
|
||||
}
|
||||
if (typeof amt1 === 'string' || typeof amt2 === 'string') {
|
||||
return false;
|
||||
}
|
||||
const aValue = new bignumber_js_1.default(amt1.value);
|
||||
const bValue = new bignumber_js_1.default(amt2.value);
|
||||
return (amt1.currency === amt2.currency &&
|
||||
amt1.issuer === amt2.issuer &&
|
||||
aValue.isEqualTo(bValue));
|
||||
}
|
||||
function isPartialPayment(tx, metadata) {
|
||||
var _a;
|
||||
if (tx == null || metadata == null || tx.TransactionType !== 'Payment') {
|
||||
return false;
|
||||
}
|
||||
let meta = metadata;
|
||||
if (typeof meta === 'string') {
|
||||
if (meta === 'unavailable') {
|
||||
return false;
|
||||
}
|
||||
meta = (0, ripple_binary_codec_1.decode)(meta);
|
||||
}
|
||||
const tfPartial = typeof tx.Flags === 'number'
|
||||
? (0, utils_1.isFlagEnabled)(tx.Flags, transactions_1.PaymentFlags.tfPartialPayment)
|
||||
: (_a = tx.Flags) === null || _a === void 0 ? void 0 : _a.tfPartialPayment;
|
||||
if (!tfPartial) {
|
||||
return false;
|
||||
}
|
||||
const delivered = meta.delivered_amount;
|
||||
const amount = tx.Amount;
|
||||
if (delivered === undefined) {
|
||||
return false;
|
||||
}
|
||||
return !amountsEqual(delivered, amount);
|
||||
}
|
||||
function txHasPartialPayment(response) {
|
||||
return isPartialPayment(response.result, response.result.meta);
|
||||
}
|
||||
function txEntryHasPartialPayment(response) {
|
||||
return isPartialPayment(response.result.tx_json, response.result.metadata);
|
||||
}
|
||||
function accountTxHasPartialPayment(response) {
|
||||
const { transactions } = response.result;
|
||||
const foo = transactions.some((tx) => isPartialPayment(tx.tx, tx.meta));
|
||||
return foo;
|
||||
}
|
||||
function hasPartialPayment(command, response) {
|
||||
switch (command) {
|
||||
case 'tx':
|
||||
return txHasPartialPayment(response);
|
||||
case 'transaction_entry':
|
||||
return txEntryHasPartialPayment(response);
|
||||
case 'account_tx':
|
||||
return accountTxHasPartialPayment(response);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function handlePartialPayment(command, response) {
|
||||
var _a;
|
||||
if (hasPartialPayment(command, response)) {
|
||||
const warnings = (_a = response.warnings) !== null && _a !== void 0 ? _a : [];
|
||||
const warning = {
|
||||
id: WARN_PARTIAL_PAYMENT_CODE,
|
||||
message: 'This response contains a Partial Payment',
|
||||
};
|
||||
warnings.push(warning);
|
||||
response.warnings = warnings;
|
||||
}
|
||||
}
|
||||
exports.handlePartialPayment = handlePartialPayment;
|
||||
function handleStreamPartialPayment(stream, log) {
|
||||
var _a;
|
||||
if (isPartialPayment(stream.transaction, stream.meta)) {
|
||||
const warnings = (_a = stream.warnings) !== null && _a !== void 0 ? _a : [];
|
||||
const warning = {
|
||||
id: WARN_PARTIAL_PAYMENT_CODE,
|
||||
message: 'This response contains a Partial Payment',
|
||||
};
|
||||
warnings.push(warning);
|
||||
stream.warnings = warnings;
|
||||
log('Partial payment received', JSON.stringify(stream));
|
||||
}
|
||||
}
|
||||
exports.handleStreamPartialPayment = handleStreamPartialPayment;
|
||||
//# sourceMappingURL=partialPayment.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"partialPayment.js","sourceRoot":"","sources":["../../../src/client/partialPayment.ts"],"names":[],"mappings":";;;;;;AAAA,gEAAoC;AACpC,6DAA4C;AAU5C,yDAAkE;AAElE,2CAA+C;AAE/C,MAAM,yBAAyB,GAAG,IAAI,CAAA;AAEtC,SAAS,YAAY,CAAC,IAAY,EAAE,IAAY;IAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACxD,OAAO,IAAI,KAAK,IAAI,CAAA;KACrB;IAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;QACxD,OAAO,KAAK,CAAA;KACb;IAED,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IACxC,MAAM,MAAM,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAExC,OAAO,CACL,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ;QAC/B,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM;QAC3B,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CACzB,CAAA;AACH,CAAC;AAED,SAAS,gBAAgB,CACvB,EAAgB,EAChB,QAAuC;;IAEvC,IAAI,EAAE,IAAI,IAAI,IAAI,QAAQ,IAAI,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GAAG,CAAC,0BAA0B,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;KACxD;AACH,CAAC;AAnBD,gEAmBC"}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
declare class XrplError extends Error {
|
||||
readonly name: string;
|
||||
readonly message: string;
|
||||
readonly data?: unknown;
|
||||
constructor(message?: string, data?: unknown);
|
||||
toString(): string;
|
||||
inspect(): string;
|
||||
}
|
||||
declare class RippledError extends XrplError {
|
||||
}
|
||||
declare class UnexpectedError extends XrplError {
|
||||
}
|
||||
declare class ConnectionError extends XrplError {
|
||||
}
|
||||
declare class NotConnectedError extends ConnectionError {
|
||||
}
|
||||
declare class DisconnectedError extends ConnectionError {
|
||||
}
|
||||
declare class RippledNotInitializedError extends ConnectionError {
|
||||
}
|
||||
declare class TimeoutError extends ConnectionError {
|
||||
}
|
||||
declare class ResponseFormatError extends ConnectionError {
|
||||
}
|
||||
declare class ValidationError extends XrplError {
|
||||
}
|
||||
declare class XRPLFaucetError extends XrplError {
|
||||
}
|
||||
declare class NotFoundError extends XrplError {
|
||||
constructor(message?: string);
|
||||
}
|
||||
export { XrplError, UnexpectedError, ConnectionError, RippledError, NotConnectedError, DisconnectedError, RippledNotInitializedError, TimeoutError, ResponseFormatError, ValidationError, NotFoundError, XRPLFaucetError, };
|
||||
//# sourceMappingURL=errors.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AASA,cAAM,SAAU,SAAQ,KAAK;IAC3B,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,OAAO,EAAE,MAAM,CAAA;IAC/B,SAAgB,IAAI,CAAC,EAAE,OAAO,CAAA;gBAQX,OAAO,SAAK,EAAE,IAAI,CAAC,EAAE,OAAO;IAiBxC,QAAQ,IAAI,MAAM;IAgBlB,OAAO,IAAI,MAAM;CAGzB;AAOD,cAAM,YAAa,SAAQ,SAAS;CAAG;AAOvC,cAAM,eAAgB,SAAQ,SAAS;CAAG;AAO1C,cAAM,eAAgB,SAAQ,SAAS;CAAG;AAO1C,cAAM,iBAAkB,SAAQ,eAAe;CAAG;AAOlD,cAAM,iBAAkB,SAAQ,eAAe;CAAG;AAOlD,cAAM,0BAA2B,SAAQ,eAAe;CAAG;AAO3D,cAAM,YAAa,SAAQ,eAAe;CAAG;AAO7C,cAAM,mBAAoB,SAAQ,eAAe;CAAG;AAOpD,cAAM,eAAgB,SAAQ,SAAS;CAAG;AAS1C,cAAM,eAAgB,SAAQ,SAAS;CAAG;AAQ1C,cAAM,aAAc,SAAQ,SAAS;gBAMhB,OAAO,SAAc;CAGzC;AAED,OAAO,EACL,SAAS,EACT,eAAe,EACf,eAAe,EACf,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,EAC1B,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,eAAe,GAChB,CAAA"}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.XRPLFaucetError = exports.NotFoundError = exports.ValidationError = exports.ResponseFormatError = exports.TimeoutError = exports.RippledNotInitializedError = exports.DisconnectedError = exports.NotConnectedError = exports.RippledError = exports.ConnectionError = exports.UnexpectedError = exports.XrplError = void 0;
|
||||
const util_1 = require("util");
|
||||
class XrplError extends Error {
|
||||
constructor(message = '', data) {
|
||||
super(message);
|
||||
this.name = this.constructor.name;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
if (Error.captureStackTrace != null) {
|
||||
Error.captureStackTrace(this, this.constructor);
|
||||
}
|
||||
}
|
||||
toString() {
|
||||
let result = `[${this.name}(${this.message}`;
|
||||
if (this.data) {
|
||||
result += `, ${(0, util_1.inspect)(this.data)}`;
|
||||
}
|
||||
result += ')]';
|
||||
return result;
|
||||
}
|
||||
inspect() {
|
||||
return this.toString();
|
||||
}
|
||||
}
|
||||
exports.XrplError = XrplError;
|
||||
class RippledError extends XrplError {
|
||||
}
|
||||
exports.RippledError = RippledError;
|
||||
class UnexpectedError extends XrplError {
|
||||
}
|
||||
exports.UnexpectedError = UnexpectedError;
|
||||
class ConnectionError extends XrplError {
|
||||
}
|
||||
exports.ConnectionError = ConnectionError;
|
||||
class NotConnectedError extends ConnectionError {
|
||||
}
|
||||
exports.NotConnectedError = NotConnectedError;
|
||||
class DisconnectedError extends ConnectionError {
|
||||
}
|
||||
exports.DisconnectedError = DisconnectedError;
|
||||
class RippledNotInitializedError extends ConnectionError {
|
||||
}
|
||||
exports.RippledNotInitializedError = RippledNotInitializedError;
|
||||
class TimeoutError extends ConnectionError {
|
||||
}
|
||||
exports.TimeoutError = TimeoutError;
|
||||
class ResponseFormatError extends ConnectionError {
|
||||
}
|
||||
exports.ResponseFormatError = ResponseFormatError;
|
||||
class ValidationError extends XrplError {
|
||||
}
|
||||
exports.ValidationError = ValidationError;
|
||||
class XRPLFaucetError extends XrplError {
|
||||
}
|
||||
exports.XRPLFaucetError = XRPLFaucetError;
|
||||
class NotFoundError extends XrplError {
|
||||
constructor(message = 'Not found') {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
exports.NotFoundError = NotFoundError;
|
||||
//# sourceMappingURL=errors.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AACA,+BAA8B;AAQ9B,MAAM,SAAU,SAAQ,KAAK;IAW3B,YAAmB,OAAO,GAAG,EAAE,EAAE,IAAc;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAA;QAEd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAEhB,IAAI,KAAK,CAAC,iBAAiB,IAAI,IAAI,EAAE;YACnC,KAA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} from './client';
|
||||
export * from './models';
|
||||
export * from './utils';
|
||||
export * from './errors';
|
||||
export { default as Wallet } from './Wallet';
|
||||
export { keyToRFC1751Mnemonic, rfc1751MnemonicToKey } from './Wallet/rfc1751';
|
||||
export * from './Wallet/signer';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAErE,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAEhD,cAAc,UAAU,CAAA;AAExB,cAAc,SAAS,CAAA;AAEvB,cAAc,UAAU,CAAA;AAExB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAE5C,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAE7E,cAAc,iBAAiB,CAAA"}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.rfc1751MnemonicToKey = exports.keyToRFC1751Mnemonic = exports.Wallet = exports.Client = exports.BroadcastClient = void 0;
|
||||
var BroadcastClient_1 = require("./client/BroadcastClient");
|
||||
Object.defineProperty(exports, "BroadcastClient", { enumerable: true, get: function () { return __importDefault(BroadcastClient_1).default; } });
|
||||
var client_1 = require("./client");
|
||||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
||||
__exportStar(require("./models"), exports);
|
||||
__exportStar(require("./utils"), exports);
|
||||
__exportStar(require("./errors"), exports);
|
||||
var Wallet_1 = require("./Wallet");
|
||||
Object.defineProperty(exports, "Wallet", { enumerable: true, get: function () { return __importDefault(Wallet_1).default; } });
|
||||
var rfc1751_1 = require("./Wallet/rfc1751");
|
||||
Object.defineProperty(exports, "keyToRFC1751Mnemonic", { enumerable: true, get: function () { return rfc1751_1.keyToRFC1751Mnemonic; } });
|
||||
Object.defineProperty(exports, "rfc1751MnemonicToKey", { enumerable: true, get: function () { return rfc1751_1.rfc1751MnemonicToKey; } });
|
||||
__exportStar(require("./Wallet/signer"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AACA,4DAAqE;AAA5D,mIAAA,OAAO,OAAmB;AAEnC,mCAAgD;AAAvC,gGAAA,MAAM,OAAA;AAEf,2CAAwB;AAExB,0CAAuB;AAEvB,2CAAwB;AAExB,mCAA4C;AAAnC,iHAAA,OAAO,OAAU;AAE1B,4CAA6E;AAApE,+GAAA,oBAAoB,OAAA;AAAE,+GAAA,oBAAoB,OAAA;AAEnD,kDAA+B"}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
export type LedgerIndex = number | ('validated' | 'closed' | 'current');
|
||||
interface XRP {
|
||||
currency: 'XRP';
|
||||
}
|
||||
interface IssuedCurrency {
|
||||
currency: string;
|
||||
issuer: string;
|
||||
}
|
||||
export type Currency = IssuedCurrency | XRP;
|
||||
export interface IssuedCurrencyAmount extends IssuedCurrency {
|
||||
value: string;
|
||||
}
|
||||
export type Amount = IssuedCurrencyAmount | string;
|
||||
export interface Signer {
|
||||
Signer: {
|
||||
Account: string;
|
||||
TxnSignature: string;
|
||||
SigningPubKey: string;
|
||||
};
|
||||
}
|
||||
export interface Memo {
|
||||
Memo: {
|
||||
MemoData?: string;
|
||||
MemoType?: string;
|
||||
MemoFormat?: string;
|
||||
};
|
||||
}
|
||||
export type StreamType = 'consensus' | 'ledger' | 'manifests' | 'peer_status' | 'transactions' | 'transactions_proposed' | 'server' | 'validations';
|
||||
interface PathStep {
|
||||
account?: string;
|
||||
currency?: string;
|
||||
issuer?: string;
|
||||
}
|
||||
export type Path = PathStep[];
|
||||
export interface SignerEntry {
|
||||
SignerEntry: {
|
||||
Account: string;
|
||||
SignerWeight: number;
|
||||
WalletLocator?: string;
|
||||
};
|
||||
}
|
||||
export interface ResponseOnlyTxInfo {
|
||||
date?: number;
|
||||
hash?: string;
|
||||
ledger_index?: number;
|
||||
inLedger?: number;
|
||||
}
|
||||
export interface NFTOffer {
|
||||
amount: Amount;
|
||||
flags: number;
|
||||
nft_offer_index: string;
|
||||
owner: string;
|
||||
destination?: string;
|
||||
expiration?: number;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/models/common/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,CAAC,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC,CAAA;AAEvE,UAAU,GAAG;IACX,QAAQ,EAAE,KAAK,CAAA;CAChB;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,MAAM,QAAQ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,CAAA;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/models/common/index.ts"],"names":[],"mappings":""}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
export * as LedgerEntry from './ledger';
|
||||
export { setTransactionFlagsToNumber, parseAccountRootFlags, } from './utils/flags';
|
||||
export * from './methods';
|
||||
export * from './transactions';
|
||||
//# sourceMappingURL=index.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,WAAW,MAAM,UAAU,CAAA;AACvC,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,eAAe,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA"}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseAccountRootFlags = exports.setTransactionFlagsToNumber = exports.LedgerEntry = void 0;
|
||||
exports.LedgerEntry = __importStar(require("./ledger"));
|
||||
var flags_1 = require("./utils/flags");
|
||||
Object.defineProperty(exports, "setTransactionFlagsToNumber", { enumerable: true, get: function () { return flags_1.setTransactionFlagsToNumber; } });
|
||||
Object.defineProperty(exports, "parseAccountRootFlags", { enumerable: true, get: function () { return flags_1.parseAccountRootFlags; } });
|
||||
__exportStar(require("./methods"), exports);
|
||||
__exportStar(require("./transactions"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/models/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,wDAAuC;AACvC,uCAGsB;AAFpB,oHAAA,2BAA2B,OAAA;AAC3B,8GAAA,qBAAqB,OAAA;AAEvB,4CAAyB;AACzB,iDAA8B"}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
export default interface AccountRoot extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'AccountRoot';
|
||||
Account: string;
|
||||
Balance: string;
|
||||
Flags: number;
|
||||
OwnerCount: number;
|
||||
PreviousTxnID: string;
|
||||
PreviousTxnLgrSeq: number;
|
||||
Sequence: number;
|
||||
AccountTxnID?: string;
|
||||
Domain?: string;
|
||||
EmailHash?: string;
|
||||
MessageKey?: string;
|
||||
RegularKey?: string;
|
||||
TicketCount?: number;
|
||||
TickSize?: number;
|
||||
TransferRate?: number;
|
||||
}
|
||||
export interface AccountRootFlagsInterface {
|
||||
lsfPasswordSpent?: boolean;
|
||||
lsfRequireDestTag?: boolean;
|
||||
lsfRequireAuth?: boolean;
|
||||
lsfDisallowXRP?: boolean;
|
||||
lsfDisableMaster?: boolean;
|
||||
lsfNoFreeze?: boolean;
|
||||
lsfGlobalFreeze?: boolean;
|
||||
lsfDefaultRipple?: boolean;
|
||||
lsfDepositAuth?: boolean;
|
||||
lsfDisallowIncomingNFTokenOffer?: boolean;
|
||||
lsfDisallowIncomingCheck?: boolean;
|
||||
lsfDisallowIncomingPayChan?: boolean;
|
||||
lsfDisallowIncomingTrustline?: boolean;
|
||||
}
|
||||
export declare enum AccountRootFlags {
|
||||
lsfPasswordSpent = 65536,
|
||||
lsfRequireDestTag = 131072,
|
||||
lsfRequireAuth = 262144,
|
||||
lsfDisallowXRP = 524288,
|
||||
lsfDisableMaster = 1048576,
|
||||
lsfNoFreeze = 2097152,
|
||||
lsfGlobalFreeze = 4194304,
|
||||
lsfDefaultRipple = 8388608,
|
||||
lsfDepositAuth = 16777216,
|
||||
lsfDisallowIncomingNFTokenOffer = 67108864,
|
||||
lsfDisallowIncomingCheck = 134217728,
|
||||
lsfDisallowIncomingPayChan = 268435456,
|
||||
lsfDisallowIncomingTrustline = 536870912
|
||||
}
|
||||
//# sourceMappingURL=AccountRoot.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AccountRoot.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/AccountRoot.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,CAAC,OAAO,WAAW,WAAY,SAAQ,eAAe;IAC1D,eAAe,EAAE,aAAa,CAAA;IAE9B,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AAa;IAK7B,cAAc,WAAa;IAI3B,+BAA+B,WAAa;IAI5C,wBAAwB,YAAa;IAIrC,0BAA0B,YAAa;IAIvC,4BAA4B,YAAa;CAC1C"}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AccountRootFlags = void 0;
|
||||
var AccountRootFlags;
|
||||
(function (AccountRootFlags) {
|
||||
AccountRootFlags[AccountRootFlags["lsfPasswordSpent"] = 65536] = "lsfPasswordSpent";
|
||||
AccountRootFlags[AccountRootFlags["lsfRequireDestTag"] = 131072] = "lsfRequireDestTag";
|
||||
AccountRootFlags[AccountRootFlags["lsfRequireAuth"] = 262144] = "lsfRequireAuth";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisallowXRP"] = 524288] = "lsfDisallowXRP";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisableMaster"] = 1048576] = "lsfDisableMaster";
|
||||
AccountRootFlags[AccountRootFlags["lsfNoFreeze"] = 2097152] = "lsfNoFreeze";
|
||||
AccountRootFlags[AccountRootFlags["lsfGlobalFreeze"] = 4194304] = "lsfGlobalFreeze";
|
||||
AccountRootFlags[AccountRootFlags["lsfDefaultRipple"] = 8388608] = "lsfDefaultRipple";
|
||||
AccountRootFlags[AccountRootFlags["lsfDepositAuth"] = 16777216] = "lsfDepositAuth";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisallowIncomingNFTokenOffer"] = 67108864] = "lsfDisallowIncomingNFTokenOffer";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisallowIncomingCheck"] = 134217728] = "lsfDisallowIncomingCheck";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisallowIncomingPayChan"] = 268435456] = "lsfDisallowIncomingPayChan";
|
||||
AccountRootFlags[AccountRootFlags["lsfDisallowIncomingTrustline"] = 536870912] = "lsfDisallowIncomingTrustline";
|
||||
})(AccountRootFlags = exports.AccountRootFlags || (exports.AccountRootFlags = {}));
|
||||
//# sourceMappingURL=AccountRoot.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"AccountRoot.js","sourceRoot":"","sources":["../../../../src/models/ledger/AccountRoot.ts"],"names":[],"mappings":";;;AAwIA,IAAY,gBAsDX;AAtDD,WAAY,gBAAgB;IAI1B,mFAA6B,CAAA;IAI7B,sFAA8B,CAAA;IAI9B,gFAA2B,CAAA;IAI3B,gFAA2B,CAAA;IAI3B,qFAA6B,CAAA;IAI7B,2EAAwB,CAAA;IAIxB,mFAA4B,CAAA;IAI5B,qFAA6B,CAAA;IAK7B,kFAA2B,CAAA;IAI3B,oHAA4C,CAAA;IAI5C,uGAAqC,CAAA;IAIrC,2GAAuC,CAAA;IAIvC,+GAAyC,CAAA;AAC3C,CAAC,EAtDW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAsD3B"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
interface Majority {
|
||||
Majority: {
|
||||
Amendment: string;
|
||||
CloseTime: number;
|
||||
};
|
||||
}
|
||||
export default interface Amendments extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'Amendments';
|
||||
Amendments?: string[];
|
||||
Majorities?: Majority[];
|
||||
Flags: 0;
|
||||
}
|
||||
export {};
|
||||
//# sourceMappingURL=Amendments.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Amendments.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/Amendments.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAE/C,UAAU,QAAQ;IAChB,QAAQ,EAAE;QAER,SAAS,EAAE,MAAM,CAAA;QAKjB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAQD,MAAM,CAAC,OAAO,WAAW,UAAW,SAAQ,eAAe;IACzD,eAAe,EAAE,YAAY,CAAA;IAK7B,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;IAMrB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAA;IAKvB,KAAK,EAAE,CAAC,CAAA;CACT"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Amendments.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Amendments.js","sourceRoot":"","sources":["../../../../src/models/ledger/Amendments.ts"],"names":[],"mappings":""}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
export default interface BaseLedgerEntry {
|
||||
index: string;
|
||||
}
|
||||
//# sourceMappingURL=BaseLedgerEntry.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BaseLedgerEntry.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/BaseLedgerEntry.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,eAAe;IACtC,KAAK,EAAE,MAAM,CAAA;CACd"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=BaseLedgerEntry.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"BaseLedgerEntry.js","sourceRoot":"","sources":["../../../../src/models/ledger/BaseLedgerEntry.ts"],"names":[],"mappings":""}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
import { Amount } from '../common';
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
export default interface Check extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'Check';
|
||||
Account: string;
|
||||
Destination: string;
|
||||
Flags: 0;
|
||||
OwnerNode: string;
|
||||
PreviousTxnID: string;
|
||||
PreviousTxnLgrSeq: number;
|
||||
SendMax: Amount;
|
||||
Sequence: number;
|
||||
DestinationNode?: string;
|
||||
DestinationTag?: number;
|
||||
Expiration?: number;
|
||||
InvoiceID?: string;
|
||||
SourceTag?: number;
|
||||
}
|
||||
//# sourceMappingURL=Check.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Check.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/Check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAElC,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,CAAC,OAAO,WAAW,KAAM,SAAQ,eAAe;IACpD,eAAe,EAAE,OAAO,CAAA;IAExB,OAAO,EAAE,MAAM,CAAA;IAKf,WAAW,EAAE,MAAM,CAAA;IAKnB,KAAK,EAAE,CAAC,CAAA;IAKR,SAAS,EAAE,MAAM,CAAA;IAKjB,aAAa,EAAE,MAAM,CAAA;IAKrB,iBAAiB,EAAE,MAAM,CAAA;IAMzB,OAAO,EAAE,MAAM,CAAA;IAEf,QAAQ,EAAE,MAAM,CAAA;IAKhB,eAAe,CAAC,EAAE,MAAM,CAAA;IAKxB,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB,UAAU,CAAC,EAAE,MAAM,CAAA;IAKnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAKlB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Check.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Check.js","sourceRoot":"","sources":["../../../../src/models/ledger/Check.ts"],"names":[],"mappings":""}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
export default interface DepositPreauth extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'DepositPreauth';
|
||||
Account: string;
|
||||
Authorize: string;
|
||||
Flags: 0;
|
||||
OwnerNode: string;
|
||||
PreviousTxnID: string;
|
||||
PreviousTxnLgrSeq: number;
|
||||
}
|
||||
//# sourceMappingURL=DepositPreauth.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DepositPreauth.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/DepositPreauth.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,CAAC,OAAO,WAAW,cAAe,SAAQ,eAAe;IAC7D,eAAe,EAAE,gBAAgB,CAAA;IAEjC,OAAO,EAAE,MAAM,CAAA;IAEf,SAAS,EAAE,MAAM,CAAA;IAKjB,KAAK,EAAE,CAAC,CAAA;IAKR,SAAS,EAAE,MAAM,CAAA;IAKjB,aAAa,EAAE,MAAM,CAAA;IAKrB,iBAAiB,EAAE,MAAM,CAAA;CAC1B"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=DepositPreauth.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DepositPreauth.js","sourceRoot":"","sources":["../../../../src/models/ledger/DepositPreauth.ts"],"names":[],"mappings":""}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
export default interface DirectoryNode extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'DirectoryNode';
|
||||
Flags: number;
|
||||
RootIndex: string;
|
||||
Indexes: string[];
|
||||
IndexNext?: number;
|
||||
IndexPrevious?: number;
|
||||
Owner?: string;
|
||||
TakerPaysCurrency?: string;
|
||||
TakerPaysIssuer?: string;
|
||||
TakerGetsCurrency?: string;
|
||||
TakerGetsIssuer?: string;
|
||||
}
|
||||
//# sourceMappingURL=DirectoryNode.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DirectoryNode.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/DirectoryNode.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,CAAC,OAAO,WAAW,aAAc,SAAQ,eAAe;IAC5D,eAAe,EAAE,eAAe,CAAA;IAKhC,KAAK,EAAE,MAAM,CAAA;IAEb,SAAS,EAAE,MAAM,CAAA;IAEjB,OAAO,EAAE,MAAM,EAAE,CAAA;IAKjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAKlB,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,KAAK,CAAC,EAAE,MAAM,CAAA;IAKd,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B,eAAe,CAAC,EAAE,MAAM,CAAA;IAKxB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=DirectoryNode.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"DirectoryNode.js","sourceRoot":"","sources":["../../../../src/models/ledger/DirectoryNode.ts"],"names":[],"mappings":""}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
import BaseLedgerEntry from './BaseLedgerEntry';
|
||||
export default interface Escrow extends BaseLedgerEntry {
|
||||
LedgerEntryType: 'Escrow';
|
||||
Account: string;
|
||||
Destination: string;
|
||||
Amount: string;
|
||||
Condition?: string;
|
||||
CancelAfter?: number;
|
||||
FinishAfter?: number;
|
||||
Flags: number;
|
||||
SourceTag?: number;
|
||||
DestinationTag?: number;
|
||||
OwnerNode: string;
|
||||
DestinationNode?: string;
|
||||
PreviousTxnID: string;
|
||||
PreviousTxnLgrSeq: number;
|
||||
}
|
||||
//# sourceMappingURL=Escrow.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Escrow.d.ts","sourceRoot":"","sources":["../../../../src/models/ledger/Escrow.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,mBAAmB,CAAA;AAQ/C,MAAM,CAAC,OAAO,WAAW,MAAO,SAAQ,eAAe;IACrD,eAAe,EAAE,QAAQ,CAAA;IAMzB,OAAO,EAAE,MAAM,CAAA;IAKf,WAAW,EAAE,MAAM,CAAA;IAEnB,MAAM,EAAE,MAAM,CAAA;IAMd,SAAS,CAAC,EAAE,MAAM,CAAA;IAIlB,WAAW,CAAC,EAAE,MAAM,CAAA;IAKpB,WAAW,CAAC,EAAE,MAAM,CAAA;IAKpB,KAAK,EAAE,MAAM,CAAA;IAKb,SAAS,CAAC,EAAE,MAAM,CAAA;IAKlB,cAAc,CAAC,EAAE,MAAM,CAAA;IAKvB,SAAS,EAAE,MAAM,CAAA;IAKjB,eAAe,CAAC,EAAE,MAAM,CAAA;IAKxB,aAAa,EAAE,MAAM,CAAA;IAKrB,iBAAiB,EAAE,MAAM,CAAA;CAC1B"}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
//# sourceMappingURL=Escrow.js.map
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user