@ledgerhq/coin-xrp 0.2.0-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +27 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +6 -0
- package/lib/api/index.d.ts +12 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +117 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/types.d.ts +188 -0
- package/lib/api/types.d.ts.map +1 -0
- package/lib/api/types.js +3 -0
- package/lib/api/types.js.map +1 -0
- package/lib/bridge/js.d.ts +10 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +47 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/broadcast.d.ts +4 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +25 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/cli-transaction.d.ts +26 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +32 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/config.d.ts +9 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +16 -0
- package/lib/config.js.map +1 -0
- package/lib/createTransaction.d.ts +3 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +18 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/dataset-1.d.ts +5 -0
- package/lib/datasets/dataset-1.d.ts.map +1 -0
- package/lib/datasets/dataset-1.js +154 -0
- package/lib/datasets/dataset-1.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +11 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +27 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +4 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +31 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +4 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +82 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +24 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +11 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +93 -0
- package/lib/logic.js.map +1 -0
- package/lib/prepareTransaction.d.ts +4 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +53 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/signOperation.d.ts +6 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +99 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +11 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +66 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +4 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +49 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronization.d.ts +3 -0
- package/lib/synchronization.d.ts.map +1 -0
- package/lib/synchronization.js +74 -0
- package/lib/synchronization.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +56 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +30 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib-es/api/index.d.ts +12 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +105 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/types.d.ts +188 -0
- package/lib-es/api/types.d.ts.map +1 -0
- package/lib-es/api/types.js +2 -0
- package/lib-es/api/types.js.map +1 -0
- package/lib-es/bridge/js.d.ts +10 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +40 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/broadcast.d.ts +4 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +21 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +26 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +26 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/config.d.ts +9 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +11 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/createTransaction.d.ts +3 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +11 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/dataset-1.d.ts +5 -0
- package/lib-es/datasets/dataset-1.d.ts.map +1 -0
- package/lib-es/datasets/dataset-1.js +148 -0
- package/lib-es/datasets/dataset-1.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +25 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +24 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +4 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +75 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +22 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +11 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +82 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +4 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +46 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/signOperation.d.ts +6 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +92 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +11 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +61 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +4 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +46 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronization.d.ts +3 -0
- package/lib-es/synchronization.d.ts.map +1 -0
- package/lib-es/synchronization.js +67 -0
- package/lib-es/synchronization.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +50 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types.d.ts +30 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +2 -0
- package/lib-es/types.js.map +1 -0
- package/package.json +80 -0
- package/src/api/index.ts +138 -0
- package/src/api/types.ts +191 -0
- package/src/bridge/js.ts +56 -0
- package/src/broadcast.ts +20 -0
- package/src/cli-transaction.ts +44 -0
- package/src/config.ts +19 -0
- package/src/createTransaction.ts +12 -0
- package/src/datasets/dataset-1.ts +153 -0
- package/src/deviceTransactionConfig.ts +41 -0
- package/src/estimateMaxSpendable.ts +25 -0
- package/src/getTransactionStatus.ts +89 -0
- package/src/hw-getAddress.ts +21 -0
- package/src/logic.ts +101 -0
- package/src/prepareTransaction.ts +45 -0
- package/src/signOperation.ts +129 -0
- package/src/signer.ts +17 -0
- package/src/specs.ts +73 -0
- package/src/speculos-deviceActions.ts +53 -0
- package/src/synchronization.ts +73 -0
- package/src/transaction.ts +79 -0
- package/src/types.ts +39 -0
- package/tsconfig.json +12 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es6: true,
|
|
5
|
+
},
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["src/**/*.test.{ts,tsx}"],
|
|
9
|
+
env: {
|
|
10
|
+
"jest/globals": true,
|
|
11
|
+
},
|
|
12
|
+
plugins: ["jest"],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
rules: {
|
|
16
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
17
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entry": [
|
|
3
|
+
"src/api/index.ts",
|
|
4
|
+
"src/bridge/js.ts",
|
|
5
|
+
"src/cli-transaction.ts",
|
|
6
|
+
"src/deviceTransactionConfig.ts",
|
|
7
|
+
"src/errors.ts",
|
|
8
|
+
"src/hw-getAddress.ts",
|
|
9
|
+
"src/serialization.ts",
|
|
10
|
+
"src/specs.ts",
|
|
11
|
+
"src/transaction.ts",
|
|
12
|
+
"src/datasets/dataset-1.ts"
|
|
13
|
+
],
|
|
14
|
+
"ignorePatterns": [
|
|
15
|
+
"**/node_modules/**",
|
|
16
|
+
"**/*.fixture.ts",
|
|
17
|
+
"**/*.mock.ts",
|
|
18
|
+
"**/*.test.{js,jsx,ts,tsx}"
|
|
19
|
+
],
|
|
20
|
+
"ignoreUnresolved": [
|
|
21
|
+
"jest-get-type",
|
|
22
|
+
"jest-matcher-utils",
|
|
23
|
+
"jest-message-util"
|
|
24
|
+
],
|
|
25
|
+
"ignoreUnimported": [],
|
|
26
|
+
"ignoreUnused": []
|
|
27
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @ledgerhq/coin-xrp
|
|
2
|
+
|
|
3
|
+
## 0.2.0-nightly.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#6822](https://github.com/LedgerHQ/ledger-live/pull/6822) [`801265b`](https://github.com/LedgerHQ/ledger-live/commit/801265b7ff3ed7ebd0012eb50f70898557a2dd52) Thanks [@lambertkevin](https://github.com/lambertkevin)! - Creation of the `coin-xrp` module, with support for better spendable balance (monitoring base reserve & trustlines), better typing, signer injection & removal of unmaintained libs like `ripple-bs58check`
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [[`b9f1f71`](https://github.com/LedgerHQ/ledger-live/commit/b9f1f715355752d8c57c24ecd6a6d166b80f689d), [`801265b`](https://github.com/LedgerHQ/ledger-live/commit/801265b7ff3ed7ebd0012eb50f70898557a2dd52)]:
|
|
12
|
+
- @ledgerhq/coin-framework@0.13.1-nightly.0
|
|
13
|
+
- @ledgerhq/cryptoassets@13.1.0-nightly.0
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Ledger https://www.ledger.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { AccountInfoResponse, AccountTxResponse, ServerInfoResponse, SubmitReponse } from "./types";
|
|
3
|
+
export declare const parseAPIValue: (value: string) => BigNumber;
|
|
4
|
+
export declare const submit: (signature: string) => Promise<SubmitReponse>;
|
|
5
|
+
export declare const getAccountInfo: (recipient: string, current?: boolean) => Promise<AccountInfoResponse>;
|
|
6
|
+
export declare const getServerInfos: (endpointConfig?: string | null | undefined) => Promise<ServerInfoResponse>;
|
|
7
|
+
export declare const getTransactions: (address: string, options: {
|
|
8
|
+
ledger_index_min?: number;
|
|
9
|
+
ledger_index_max?: number;
|
|
10
|
+
} | undefined) => Promise<AccountTxResponse["transactions"]>;
|
|
11
|
+
export declare function getLedgerIndex(): Promise<number>;
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAEjB,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AAIjB,eAAO,MAAM,aAAa,UAAW,MAAM,KAAG,SAAiD,CAAC;AAEhG,eAAO,MAAM,MAAM,cAAqB,MAAM,KAAG,QAAQ,aAAa,CAgBrE,CAAC;AAEF,eAAO,MAAM,cAAc,cACd,MAAM,YACP,OAAO,KAChB,QAAQ,mBAAmB,CAsB7B,CAAC;AAEF,eAAO,MAAM,cAAc,oBACR,MAAM,GAAG,IAAI,GAAG,SAAS,KACzC,QAAQ,kBAAkB,CAqB5B,CAAC;AAEF,eAAO,MAAM,eAAe,YACjB,MAAM,WACN;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,KAC5E,QAAQ,iBAAiB,CAAC,cAAc,CAAC,CAuB3C,CAAC;AAEF,wBAAsB,cAAc,IAAI,OAAO,CAAC,MAAM,CAAC,CAqBtD"}
|
package/lib/api/index.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getLedgerIndex = exports.getTransactions = exports.getServerInfos = exports.getAccountInfo = exports.submit = exports.parseAPIValue = void 0;
|
|
16
|
+
const network_1 = __importDefault(require("@ledgerhq/live-network/network"));
|
|
17
|
+
const currencies_1 = require("@ledgerhq/coin-framework/currencies");
|
|
18
|
+
const currencies_2 = require("@ledgerhq/cryptoassets/currencies");
|
|
19
|
+
const logic_1 = require("../logic");
|
|
20
|
+
const config_1 = require("../config");
|
|
21
|
+
const rippleUnit = (0, currencies_2.getCryptoCurrencyById)("ripple").units[0];
|
|
22
|
+
const parseAPIValue = (value) => (0, currencies_1.parseCurrencyUnit)(rippleUnit, value);
|
|
23
|
+
exports.parseAPIValue = parseAPIValue;
|
|
24
|
+
const submit = (signature) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
const { data: { result }, } = yield (0, network_1.default)({
|
|
26
|
+
method: "POST",
|
|
27
|
+
url: (0, config_1.getCoinConfig)().node,
|
|
28
|
+
data: {
|
|
29
|
+
method: "submit",
|
|
30
|
+
params: [
|
|
31
|
+
{
|
|
32
|
+
tx_blob: signature,
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
return result;
|
|
38
|
+
});
|
|
39
|
+
exports.submit = submit;
|
|
40
|
+
const getAccountInfo = (recipient, current) => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
const { data: { result }, } = yield (0, network_1.default)({
|
|
42
|
+
method: "POST",
|
|
43
|
+
url: (0, config_1.getCoinConfig)().node,
|
|
44
|
+
data: {
|
|
45
|
+
method: "account_info",
|
|
46
|
+
params: [
|
|
47
|
+
{
|
|
48
|
+
account: recipient,
|
|
49
|
+
ledger_index: current ? "current" : "validated",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
if (result.status !== "success" && result.error !== logic_1.NEW_ACCOUNT_ERROR_MESSAGE) {
|
|
55
|
+
throw new Error(`couldn't fetch account info ${recipient}`);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
});
|
|
59
|
+
exports.getAccountInfo = getAccountInfo;
|
|
60
|
+
const getServerInfos = (endpointConfig) => __awaiter(void 0, void 0, void 0, function* () {
|
|
61
|
+
const { data: { result }, } = yield (0, network_1.default)({
|
|
62
|
+
method: "POST",
|
|
63
|
+
url: endpointConfig !== null && endpointConfig !== void 0 ? endpointConfig : (0, config_1.getCoinConfig)().node,
|
|
64
|
+
data: {
|
|
65
|
+
method: "server_info",
|
|
66
|
+
params: [
|
|
67
|
+
{
|
|
68
|
+
ledger_index: "validated",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
if (result.status !== "success") {
|
|
74
|
+
throw new Error(`couldn't fetch server info`);
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
});
|
|
78
|
+
exports.getServerInfos = getServerInfos;
|
|
79
|
+
const getTransactions = (address, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
80
|
+
const { data: { result }, } = yield (0, network_1.default)({
|
|
81
|
+
method: "POST",
|
|
82
|
+
url: (0, config_1.getCoinConfig)().node,
|
|
83
|
+
data: {
|
|
84
|
+
method: "account_tx",
|
|
85
|
+
params: [
|
|
86
|
+
Object.assign({ account: address, ledger_index: "validated" }, options),
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
if (result.status !== "success") {
|
|
91
|
+
throw new Error(`couldn't getTransactions for ${address}`);
|
|
92
|
+
}
|
|
93
|
+
return result.transactions;
|
|
94
|
+
});
|
|
95
|
+
exports.getTransactions = getTransactions;
|
|
96
|
+
function getLedgerIndex() {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
98
|
+
const { data: { result }, } = yield (0, network_1.default)({
|
|
99
|
+
method: "POST",
|
|
100
|
+
url: (0, config_1.getCoinConfig)().node,
|
|
101
|
+
data: {
|
|
102
|
+
method: "ledger",
|
|
103
|
+
params: [
|
|
104
|
+
{
|
|
105
|
+
ledger_index: "validated",
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
if (result.status !== "success") {
|
|
111
|
+
throw new Error(`couldn't fetch getLedgerIndex`);
|
|
112
|
+
}
|
|
113
|
+
return result.ledger_index;
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
exports.getLedgerIndex = getLedgerIndex;
|
|
117
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,6EAAqD;AACrD,oEAAwE;AACxE,kEAA0E;AAC1E,oCAAqD;AACrD,sCAA0C;AAS1C,MAAM,UAAU,GAAG,IAAA,kCAAqB,EAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAErD,MAAM,aAAa,GAAG,CAAC,KAAa,EAAa,EAAE,CAAC,IAAA,8BAAiB,EAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAAnF,QAAA,aAAa,iBAAsE;AAEzF,MAAM,MAAM,GAAG,CAAO,SAAiB,EAA0B,EAAE;IACxE,MAAM,EACJ,IAAI,EAAE,EAAE,MAAM,EAAE,GACjB,GAAG,MAAM,IAAA,iBAAO,EAA4B;QAC3C,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,IAAA,sBAAa,GAAE,CAAC,IAAI;QACzB,IAAI,EAAE;YACJ,MAAM,EAAE,QAAQ;YAChB,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C"}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
export type XrplOperation = {
|
|
2
|
+
meta: {
|
|
3
|
+
AffectedNodes: {
|
|
4
|
+
ModifiedNode: {
|
|
5
|
+
FinalFields: {
|
|
6
|
+
Account: string;
|
|
7
|
+
Balance: string;
|
|
8
|
+
Flags: number;
|
|
9
|
+
OwnerCount: number;
|
|
10
|
+
Sequence: number;
|
|
11
|
+
};
|
|
12
|
+
LedgerEntryType: string;
|
|
13
|
+
LedgerIndex: string;
|
|
14
|
+
PreviousFields: {
|
|
15
|
+
Balance: string;
|
|
16
|
+
};
|
|
17
|
+
PreviousTxnID: string;
|
|
18
|
+
PreviousTxnLgrSeq: number;
|
|
19
|
+
};
|
|
20
|
+
}[];
|
|
21
|
+
TransactionIndex: number;
|
|
22
|
+
TransactionResult: string;
|
|
23
|
+
delivered_amount: string;
|
|
24
|
+
};
|
|
25
|
+
tx: {
|
|
26
|
+
Account: string;
|
|
27
|
+
Amount: string;
|
|
28
|
+
DeliverMax: string;
|
|
29
|
+
Destination: string;
|
|
30
|
+
DestinationTag: number;
|
|
31
|
+
Fee: string;
|
|
32
|
+
Flags: number;
|
|
33
|
+
LastLedgerSequence: number;
|
|
34
|
+
Memos: {
|
|
35
|
+
Memo: {
|
|
36
|
+
MemoData: string;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
Sequence: number;
|
|
40
|
+
SigningPubKey: string;
|
|
41
|
+
TransactionType: string;
|
|
42
|
+
TxnSignature: string;
|
|
43
|
+
date: number;
|
|
44
|
+
hash: string;
|
|
45
|
+
inLedger: number;
|
|
46
|
+
ledger_index: number;
|
|
47
|
+
};
|
|
48
|
+
validated: boolean;
|
|
49
|
+
};
|
|
50
|
+
type ResponseStatus = {
|
|
51
|
+
status: string;
|
|
52
|
+
error?: never;
|
|
53
|
+
} | {
|
|
54
|
+
status?: never;
|
|
55
|
+
error: string;
|
|
56
|
+
};
|
|
57
|
+
export type AccountInfoResponse = {
|
|
58
|
+
account_data: {
|
|
59
|
+
Account: string;
|
|
60
|
+
Balance: string;
|
|
61
|
+
Flags: number;
|
|
62
|
+
LedgerEntryType: string;
|
|
63
|
+
OwnerCount: number;
|
|
64
|
+
PreviousTxnID: string;
|
|
65
|
+
PreviousTxnLgrSeq: number;
|
|
66
|
+
Sequence: number;
|
|
67
|
+
index: string;
|
|
68
|
+
};
|
|
69
|
+
account_flags: {
|
|
70
|
+
allowTrustLineClawback: boolean;
|
|
71
|
+
defaultRipple: boolean;
|
|
72
|
+
depositAuth: boolean;
|
|
73
|
+
disableMasterKey: boolean;
|
|
74
|
+
disallowIncomingCheck: boolean;
|
|
75
|
+
disallowIncomingNFTokenOffer: boolean;
|
|
76
|
+
disallowIncomingPayChan: boolean;
|
|
77
|
+
disallowIncomingTrustline: boolean;
|
|
78
|
+
disallowIncomingXRP: boolean;
|
|
79
|
+
globalFreeze: boolean;
|
|
80
|
+
noFreeze: boolean;
|
|
81
|
+
passwordSpent: boolean;
|
|
82
|
+
requireAuthorization: boolean;
|
|
83
|
+
requireDestinationTag: boolean;
|
|
84
|
+
};
|
|
85
|
+
ledger_hash: string;
|
|
86
|
+
ledger_index: number;
|
|
87
|
+
validated: boolean;
|
|
88
|
+
} & ResponseStatus;
|
|
89
|
+
export type SubmitReponse = {
|
|
90
|
+
accepted: boolean;
|
|
91
|
+
account_sequence_available: number;
|
|
92
|
+
account_sequence_next: number;
|
|
93
|
+
applied: boolean;
|
|
94
|
+
broadcast: boolean;
|
|
95
|
+
engine_result: string;
|
|
96
|
+
engine_result_code: 0;
|
|
97
|
+
engine_result_message: string;
|
|
98
|
+
kept: boolean;
|
|
99
|
+
open_ledger_cost: string;
|
|
100
|
+
queued: false;
|
|
101
|
+
status: string;
|
|
102
|
+
tx_blob: string;
|
|
103
|
+
tx_json: {
|
|
104
|
+
Account: string;
|
|
105
|
+
Amount: string;
|
|
106
|
+
Destination: string;
|
|
107
|
+
Fee: string;
|
|
108
|
+
Flags: number;
|
|
109
|
+
LastLedgerSequence: number;
|
|
110
|
+
Sequence: number;
|
|
111
|
+
SigningPubKey: string;
|
|
112
|
+
TransactionType: string;
|
|
113
|
+
TxnSignature: string;
|
|
114
|
+
hash: string;
|
|
115
|
+
};
|
|
116
|
+
validated_ledger_index: number;
|
|
117
|
+
};
|
|
118
|
+
export type ServerInfoResponse = {
|
|
119
|
+
info: {
|
|
120
|
+
build_version: string;
|
|
121
|
+
complete_ledgers: string;
|
|
122
|
+
hostid: string;
|
|
123
|
+
initial_sync_duration_us: string;
|
|
124
|
+
io_latency_ms: number;
|
|
125
|
+
jq_trans_overflow: string;
|
|
126
|
+
last_close: {
|
|
127
|
+
converge_time_s: number;
|
|
128
|
+
proposers: number;
|
|
129
|
+
};
|
|
130
|
+
load_factor: number;
|
|
131
|
+
network_id: number;
|
|
132
|
+
peer_disconnects: string;
|
|
133
|
+
peer_disconnects_resources: string;
|
|
134
|
+
peers: number;
|
|
135
|
+
ports: {
|
|
136
|
+
port: string;
|
|
137
|
+
protocol: ["ws" | "http" | "peer"];
|
|
138
|
+
}[];
|
|
139
|
+
pubkey_node: string;
|
|
140
|
+
server_state: string;
|
|
141
|
+
server_state_duration_us: string;
|
|
142
|
+
state_accounting: Record<"connected" | "disconnected" | "full" | "syncing" | "tracking", {
|
|
143
|
+
duration_us: string;
|
|
144
|
+
transitions: string;
|
|
145
|
+
}>;
|
|
146
|
+
time: string;
|
|
147
|
+
uptime: number;
|
|
148
|
+
validated_ledger: {
|
|
149
|
+
age: number;
|
|
150
|
+
base_fee_xrp: number;
|
|
151
|
+
hash: string;
|
|
152
|
+
reserve_base_xrp: number;
|
|
153
|
+
reserve_inc_xrp: number;
|
|
154
|
+
seq: number;
|
|
155
|
+
};
|
|
156
|
+
validation_quorum: number;
|
|
157
|
+
};
|
|
158
|
+
} & ResponseStatus;
|
|
159
|
+
export type AccountTxResponse = {
|
|
160
|
+
account: string;
|
|
161
|
+
ledger_index_max: number;
|
|
162
|
+
ledger_index_min: number;
|
|
163
|
+
limit: number;
|
|
164
|
+
transactions: XrplOperation[];
|
|
165
|
+
validated: boolean;
|
|
166
|
+
} & ResponseStatus;
|
|
167
|
+
export type LedgerResponse = {
|
|
168
|
+
ledger: {
|
|
169
|
+
account_hash: string;
|
|
170
|
+
close_flags: number;
|
|
171
|
+
close_time: number;
|
|
172
|
+
close_time_human: string;
|
|
173
|
+
close_time_iso: string;
|
|
174
|
+
close_time_resolution: number;
|
|
175
|
+
closed: boolean;
|
|
176
|
+
ledger_hash: string;
|
|
177
|
+
ledger_index: string;
|
|
178
|
+
parent_close_time: number;
|
|
179
|
+
parent_hash: string;
|
|
180
|
+
total_coins: string;
|
|
181
|
+
transaction_hash: string;
|
|
182
|
+
};
|
|
183
|
+
ledger_hash: string;
|
|
184
|
+
ledger_index: number;
|
|
185
|
+
validated: boolean;
|
|
186
|
+
} & ResponseStatus;
|
|
187
|
+
export {};
|
|
188
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE;QACJ,aAAa,EAAE;YACb,YAAY,EAAE;gBACZ,WAAW,EAAE;oBACX,OAAO,EAAE,MAAM,CAAC;oBAChB,OAAO,EAAE,MAAM,CAAC;oBAChB,KAAK,EAAE,MAAM,CAAC;oBACd,UAAU,EAAE,MAAM,CAAC;oBACnB,QAAQ,EAAE,MAAM,CAAC;iBAClB,CAAC;gBACF,eAAe,EAAE,MAAM,CAAC;gBACxB,WAAW,EAAE,MAAM,CAAC;gBACpB,cAAc,EAAE;oBACd,OAAO,EAAE,MAAM,CAAC;iBACjB,CAAC;gBACF,aAAa,EAAE,MAAM,CAAC;gBACtB,iBAAiB,EAAE,MAAM,CAAC;aAC3B,CAAC;SACH,EAAE,CAAC;QACJ,gBAAgB,EAAE,MAAM,CAAC;QACzB,iBAAiB,EAAE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b,gBAAgB,EAAE,MAAM,CAAC;YACzB,eAAe,EAAE,MAAM,CAAC;YACxB,GAAG,EAAE,MAAM,CAAC;SACb,CAAC;QACF,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC;CACH,GAAG,cAAc,CAAC;AAEnB,MAAM,MAAM,iBAAiB,GAAG;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,aAAa,EAAE,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,cAAc,CAAC;AAEnB,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE;QACN,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;QACnB,gBAAgB,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,CAAC;QACvB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,MAAM,EAAE,OAAO,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;CACpB,GAAG,cAAc,CAAC"}
|
package/lib/api/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
2
|
+
import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
|
|
3
|
+
import { XrpConfig } from "../config";
|
|
4
|
+
import type { Transaction } from "../types";
|
|
5
|
+
import { XrpSigner } from "../signer";
|
|
6
|
+
export declare function createBridges(signerContext: SignerContext<XrpSigner>, coinConfig: () => XrpConfig): {
|
|
7
|
+
currencyBridge: CurrencyBridge;
|
|
8
|
+
accountBridge: AccountBridge<Transaction>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=js.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js.d.ts","sourceRoot":"","sources":["../../src/bridge/js.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAO1E,OAAO,EAAE,SAAS,EAAiB,MAAM,WAAW,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,wBAAgB,aAAa,CAC3B,aAAa,EAAE,aAAa,CAAC,SAAS,CAAC,EACvC,UAAU,EAAE,MAAM,SAAS;;;EAgC5B"}
|
package/lib/bridge/js.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.createBridges = void 0;
|
|
7
|
+
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
8
|
+
const getAddressWrapper_1 = __importDefault(require("@ledgerhq/coin-framework/bridge/getAddressWrapper"));
|
|
9
|
+
const getTransactionStatus_1 = require("../getTransactionStatus");
|
|
10
|
+
const estimateMaxSpendable_1 = require("../estimateMaxSpendable");
|
|
11
|
+
const prepareTransaction_1 = require("../prepareTransaction");
|
|
12
|
+
const createTransaction_1 = require("../createTransaction");
|
|
13
|
+
const synchronization_1 = require("../synchronization");
|
|
14
|
+
const signOperation_1 = require("../signOperation");
|
|
15
|
+
const config_1 = require("../config");
|
|
16
|
+
const broadcast_1 = require("../broadcast");
|
|
17
|
+
const hw_getAddress_1 = __importDefault(require("../hw-getAddress"));
|
|
18
|
+
function createBridges(signerContext, coinConfig) {
|
|
19
|
+
(0, config_1.setCoinConfig)(coinConfig);
|
|
20
|
+
const getAddress = (0, hw_getAddress_1.default)(signerContext);
|
|
21
|
+
const scanAccounts = (0, jsHelpers_1.makeScanAccounts)({ getAccountShape: synchronization_1.getAccountShape, getAddressFn: getAddress });
|
|
22
|
+
const currencyBridge = {
|
|
23
|
+
preload: () => Promise.resolve({}),
|
|
24
|
+
hydrate: () => { },
|
|
25
|
+
scanAccounts,
|
|
26
|
+
};
|
|
27
|
+
const receive = (0, jsHelpers_1.makeAccountBridgeReceive)((0, getAddressWrapper_1.default)(getAddress));
|
|
28
|
+
const signOperation = (0, signOperation_1.buildSignOperation)(signerContext);
|
|
29
|
+
const sync = (0, jsHelpers_1.makeSync)({ getAccountShape: synchronization_1.getAccountShape });
|
|
30
|
+
const accountBridge = {
|
|
31
|
+
createTransaction: createTransaction_1.createTransaction,
|
|
32
|
+
updateTransaction: (jsHelpers_1.defaultUpdateTransaction),
|
|
33
|
+
prepareTransaction: prepareTransaction_1.prepareTransaction,
|
|
34
|
+
getTransactionStatus: getTransactionStatus_1.getTransactionStatus,
|
|
35
|
+
estimateMaxSpendable: estimateMaxSpendable_1.estimateMaxSpendable,
|
|
36
|
+
sync,
|
|
37
|
+
receive,
|
|
38
|
+
signOperation,
|
|
39
|
+
broadcast: broadcast_1.broadcast,
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
currencyBridge,
|
|
43
|
+
accountBridge,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
exports.createBridges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AC;IAEF,OAAO;QACL,cAAc;QACd,aAAa;KACd,CAAC;AACJ,CAAC;AAlCD,sCAkCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAGtC,eAAO,MAAM,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,WAAW,CAc7D,CAAC"}
|
package/lib/broadcast.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.broadcast = void 0;
|
|
13
|
+
const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
14
|
+
const api_1 = require("./api");
|
|
15
|
+
const broadcast = (_a) => __awaiter(void 0, [_a], void 0, function* ({ signedOperation: { signature, operation }, }) {
|
|
16
|
+
const submittedPayment = yield (0, api_1.submit)(signature);
|
|
17
|
+
if (submittedPayment.engine_result !== "tesSUCCESS" &&
|
|
18
|
+
submittedPayment.engine_result !== "terQUEUED") {
|
|
19
|
+
throw new Error(submittedPayment.engine_result_message);
|
|
20
|
+
}
|
|
21
|
+
const { hash } = submittedPayment.tx_json;
|
|
22
|
+
return (0, operation_1.patchOperationWithHash)(operation, hash);
|
|
23
|
+
});
|
|
24
|
+
exports.broadcast = broadcast;
|
|
25
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kEAA4E;AAE5E,+BAA+B;AAExB,MAAM,SAAS,GAA4C,KAE/D,EAAE,4CAFoE,EACvE,eAAe,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,GAC1C;IACC,MAAM,gBAAgB,GAAG,MAAM,IAAA,YAAM,EAAC,SAAS,CAAC,CAAC;IAEjD,IACE,gBAAgB,CAAC,aAAa,KAAK,YAAY;QAC/C,gBAAgB,CAAC,aAAa,KAAK,WAAW,EAC9C,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,qBAAqB,CAAC,CAAC;IAC1D,CAAC;IAED,MAAM,EAAE,IAAI,EAAE,GAAG,gBAAgB,CAAC,OAAO,CAAC;IAC1C,OAAO,IAAA,kCAAsB,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACjD,CAAC,CAAA,CAAC;AAdW,QAAA,SAAS,aAcpB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction } from "./types";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
declare function inferTransactions(transactions: Array<{
|
|
5
|
+
account: AccountLike;
|
|
6
|
+
transaction: Transaction;
|
|
7
|
+
}>, opts: {
|
|
8
|
+
tag?: number | null | undefined;
|
|
9
|
+
fee?: string;
|
|
10
|
+
}, { inferAmount, }: {
|
|
11
|
+
inferAmount: (account: AccountLike, fee?: string) => BigNumber | null | undefined;
|
|
12
|
+
}): Transaction[];
|
|
13
|
+
export default function makeCliTools(): {
|
|
14
|
+
options: ({
|
|
15
|
+
name: string;
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
desc: string;
|
|
18
|
+
} | {
|
|
19
|
+
name: string;
|
|
20
|
+
type: NumberConstructor;
|
|
21
|
+
desc: string;
|
|
22
|
+
})[];
|
|
23
|
+
inferTransactions: typeof inferTransactions;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=cli-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.d.ts","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,SAAS,MAAM,cAAc,CAAC;AAerC,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,IAAI,EAAE;IAAE,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,EACvD,EACE,WAAW,GACZ,EAAE;IAAE,WAAW,EAAE,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,SAAS,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE,GACvF,WAAW,EAAE,CASf;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;;;;;EAKnC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
7
|
+
const options = [
|
|
8
|
+
{
|
|
9
|
+
name: "fee",
|
|
10
|
+
type: String,
|
|
11
|
+
desc: "how much fee",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "tag",
|
|
15
|
+
type: Number,
|
|
16
|
+
desc: "ripple tag",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
function inferTransactions(transactions, opts, { inferAmount, }) {
|
|
20
|
+
return transactions.flatMap(({ transaction, account }) => {
|
|
21
|
+
(0, invariant_1.default)(transaction.family === "xrp", "XRP family");
|
|
22
|
+
return Object.assign(Object.assign({}, transaction), { fee: inferAmount(account, opts.fee || "0.001xrp"), tag: opts.tag });
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function makeCliTools() {
|
|
26
|
+
return {
|
|
27
|
+
options,
|
|
28
|
+
inferTransactions,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
exports.default = makeCliTools;
|
|
32
|
+
//# sourceMappingURL=cli-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.js","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAKlC,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,cAAc;KACrB;IACD;QACE,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,YAAY;KACnB;CACF,CAAC;AAEF,SAAS,iBAAiB,CACxB,YAGE,EACF,IAAuD,EACvD,EACE,WAAW,GAC2E;IAExF,OAAO,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACvD,IAAA,mBAAS,EAAC,WAAW,CAAC,MAAM,KAAK,KAAK,EAAE,YAAY,CAAC,CAAC;QACtD,uCACK,WAAW,KACd,GAAG,EAAE,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,GAAG,IAAI,UAAU,CAAC,EACjD,GAAG,EAAE,IAAI,CAAC,GAAG,IACb;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAwB,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC;AALD,+BAKC"}
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { CurrencyConfig } from "@ledgerhq/coin-framework/config";
|
|
2
|
+
export type XrpConfig = CurrencyConfig & {
|
|
3
|
+
node: string;
|
|
4
|
+
};
|
|
5
|
+
declare let coinConfig: () => XrpConfig | undefined;
|
|
6
|
+
export declare const setCoinConfig: (config: typeof coinConfig) => void;
|
|
7
|
+
export declare const getCoinConfig: () => XrpConfig;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAEjE,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,QAAA,IAAI,UAAU,EAAE,MAAM,SAAS,GAAG,SAAS,CAAC;AAE5C,eAAO,MAAM,aAAa,WAAY,iBAAiB,KAAG,IAEzD,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,SAMhC,CAAC"}
|