@ledgerhq/coin-near 0.3.8
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 +14 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +6 -0
- package/lib/account.d.ts +7 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +31 -0
- package/lib/account.js.map +1 -0
- package/lib/api/archive-node-sdk.d.ts +21 -0
- package/lib/api/archive-node-sdk.d.ts.map +1 -0
- package/lib/api/archive-node-sdk.js +276 -0
- package/lib/api/archive-node-sdk.js.map +1 -0
- package/lib/api/datahub-indexer-sdk.d.ts +3 -0
- package/lib/api/datahub-indexer-sdk.d.ts.map +1 -0
- package/lib/api/datahub-indexer-sdk.js +80 -0
- package/lib/api/datahub-indexer-sdk.js.map +1 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +18 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/near-staking-positions-sdk.d.ts +3 -0
- package/lib/api/near-staking-positions-sdk.d.ts.map +1 -0
- package/lib/api/near-staking-positions-sdk.js +27 -0
- package/lib/api/near-staking-positions-sdk.js.map +1 -0
- package/lib/api/sdk.types.d.ts +81 -0
- package/lib/api/sdk.types.d.ts.map +1 -0
- package/lib/api/sdk.types.js +3 -0
- package/lib/api/sdk.types.js.map +1 -0
- package/lib/bridge/js.d.ts +11 -0
- package/lib/bridge/js.d.ts.map +1 -0
- package/lib/bridge/js.js +58 -0
- package/lib/bridge/js.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +14 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +226 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/cli-transaction.d.ts +16 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +28 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/constants.d.ts +8 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +11 -0
- package/lib/constants.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +7 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +54 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +28 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +41 -0
- package/lib/errors.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 +23 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/js-broadcast.d.ts +6 -0
- package/lib/js-broadcast.d.ts.map +1 -0
- package/lib/js-broadcast.js +19 -0
- package/lib/js-broadcast.js.map +1 -0
- package/lib/js-buildTransaction.d.ts +5 -0
- package/lib/js-buildTransaction.d.ts.map +1 -0
- package/lib/js-buildTransaction.js +79 -0
- package/lib/js-buildTransaction.js.map +1 -0
- package/lib/js-estimateMaxSpendable.d.ts +11 -0
- package/lib/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib/js-estimateMaxSpendable.js +31 -0
- package/lib/js-estimateMaxSpendable.js.map +1 -0
- package/lib/js-getFeesForTransaction.d.ts +5 -0
- package/lib/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib/js-getFeesForTransaction.js +33 -0
- package/lib/js-getFeesForTransaction.js.map +1 -0
- package/lib/js-getTransactionStatus.d.ts +4 -0
- package/lib/js-getTransactionStatus.d.ts.map +1 -0
- package/lib/js-getTransactionStatus.js +142 -0
- package/lib/js-getTransactionStatus.js.map +1 -0
- package/lib/js-signOperation.d.ts +10 -0
- package/lib/js-signOperation.d.ts.map +1 -0
- package/lib/js-signOperation.js +112 -0
- package/lib/js-signOperation.js.map +1 -0
- package/lib/js-synchronisation.d.ts +5 -0
- package/lib/js-synchronisation.d.ts.map +1 -0
- package/lib/js-synchronisation.js +50 -0
- package/lib/js-synchronisation.js.map +1 -0
- package/lib/js-transaction.d.ts +5 -0
- package/lib/js-transaction.d.ts.map +1 -0
- package/lib/js-transaction.js +41 -0
- package/lib/js-transaction.js.map +1 -0
- package/lib/logic.d.ts +15 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +141 -0
- package/lib/logic.js.map +1 -0
- package/lib/preload.d.ts +11 -0
- package/lib/preload.d.ts.map +1 -0
- package/lib/preload.js +133 -0
- package/lib/preload.js.map +1 -0
- package/lib/serialization.d.ts +7 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +52 -0
- package/lib/serialization.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 +133 -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 +94 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +38 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +74 -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/account.d.ts +7 -0
- package/lib-es/account.d.ts.map +1 -0
- package/lib-es/account.js +29 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/api/archive-node-sdk.d.ts +21 -0
- package/lib-es/api/archive-node-sdk.d.ts.map +1 -0
- package/lib-es/api/archive-node-sdk.js +240 -0
- package/lib-es/api/archive-node-sdk.js.map +1 -0
- package/lib-es/api/datahub-indexer-sdk.d.ts +3 -0
- package/lib-es/api/datahub-indexer-sdk.d.ts.map +1 -0
- package/lib-es/api/datahub-indexer-sdk.js +73 -0
- package/lib-es/api/datahub-indexer-sdk.js.map +1 -0
- package/lib-es/api/index.d.ts +4 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +4 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/near-staking-positions-sdk.d.ts +3 -0
- package/lib-es/api/near-staking-positions-sdk.d.ts.map +1 -0
- package/lib-es/api/near-staking-positions-sdk.js +20 -0
- package/lib-es/api/near-staking-positions-sdk.js.map +1 -0
- package/lib-es/api/sdk.types.d.ts +81 -0
- package/lib-es/api/sdk.types.d.ts.map +1 -0
- package/lib-es/api/sdk.types.js +2 -0
- package/lib-es/api/sdk.types.js.map +1 -0
- package/lib-es/bridge/js.d.ts +11 -0
- package/lib-es/bridge/js.d.ts.map +1 -0
- package/lib-es/bridge/js.js +49 -0
- package/lib-es/bridge/js.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +14 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +223 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +16 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +22 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/constants.d.ts +8 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +8 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +7 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +52 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +28 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +38 -0
- package/lib-es/errors.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 +21 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/js-broadcast.d.ts +6 -0
- package/lib-es/js-broadcast.d.ts.map +1 -0
- package/lib-es/js-broadcast.js +17 -0
- package/lib-es/js-broadcast.js.map +1 -0
- package/lib-es/js-buildTransaction.d.ts +5 -0
- package/lib-es/js-buildTransaction.d.ts.map +1 -0
- package/lib-es/js-buildTransaction.js +52 -0
- package/lib-es/js-buildTransaction.js.map +1 -0
- package/lib-es/js-estimateMaxSpendable.d.ts +11 -0
- package/lib-es/js-estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/js-estimateMaxSpendable.js +26 -0
- package/lib-es/js-estimateMaxSpendable.js.map +1 -0
- package/lib-es/js-getFeesForTransaction.d.ts +5 -0
- package/lib-es/js-getFeesForTransaction.d.ts.map +1 -0
- package/lib-es/js-getFeesForTransaction.js +31 -0
- package/lib-es/js-getFeesForTransaction.js.map +1 -0
- package/lib-es/js-getTransactionStatus.d.ts +4 -0
- package/lib-es/js-getTransactionStatus.d.ts.map +1 -0
- package/lib-es/js-getTransactionStatus.js +140 -0
- package/lib-es/js-getTransactionStatus.js.map +1 -0
- package/lib-es/js-signOperation.d.ts +10 -0
- package/lib-es/js-signOperation.d.ts.map +1 -0
- package/lib-es/js-signOperation.js +85 -0
- package/lib-es/js-signOperation.js.map +1 -0
- package/lib-es/js-synchronisation.d.ts +5 -0
- package/lib-es/js-synchronisation.d.ts.map +1 -0
- package/lib-es/js-synchronisation.js +46 -0
- package/lib-es/js-synchronisation.js.map +1 -0
- package/lib-es/js-transaction.d.ts +5 -0
- package/lib-es/js-transaction.d.ts.map +1 -0
- package/lib-es/js-transaction.js +33 -0
- package/lib-es/js-transaction.js.map +1 -0
- package/lib-es/logic.d.ts +15 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +127 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/preload.d.ts +11 -0
- package/lib-es/preload.d.ts.map +1 -0
- package/lib-es/preload.js +124 -0
- package/lib-es/preload.js.map +1 -0
- package/lib-es/serialization.d.ts +7 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +45 -0
- package/lib-es/serialization.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 +128 -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 +68 -0
- package/lib-es/speculos-deviceActions.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 +32 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types.d.ts +74 -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/account.ts +38 -0
- package/src/api/archive-node-sdk.ts +302 -0
- package/src/api/datahub-indexer-sdk.ts +84 -0
- package/src/api/index.ts +13 -0
- package/src/api/near-staking-positions-sdk.ts +15 -0
- package/src/api/sdk.types.ts +88 -0
- package/src/bridge/js.ts +69 -0
- package/src/bridge.integration.test.ts +241 -0
- package/src/cli-transaction.ts +38 -0
- package/src/constants.ts +7 -0
- package/src/deviceTransactionConfig.ts +81 -0
- package/src/errors.ts +46 -0
- package/src/hw-getAddress.ts +21 -0
- package/src/js-broadcast.ts +15 -0
- package/src/js-buildTransaction.ts +89 -0
- package/src/js-estimateMaxSpendable.ts +38 -0
- package/src/js-getFeesForTransaction.ts +39 -0
- package/src/js-getTransactionStatus.ts +186 -0
- package/src/js-signOperation.ts +125 -0
- package/src/js-synchronisation.ts +52 -0
- package/src/js-transaction.ts +29 -0
- package/src/logic.ts +176 -0
- package/src/preload.ts +143 -0
- package/src/serialization.ts +61 -0
- package/src/signer.ts +9 -0
- package/src/specs.ts +177 -0
- package/src/speculos-deviceActions.ts +75 -0
- package/src/transaction.ts +57 -0
- package/src/types.ts +91 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BigNumber } from "bignumber.js";
|
|
11
|
+
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
12
|
+
import { getMaxAmount } from "./logic";
|
|
13
|
+
import { createTransaction } from "./js-transaction";
|
|
14
|
+
import getEstimatedFees from "./js-getFeesForTransaction";
|
|
15
|
+
const estimateMaxSpendable = ({ account, parentAccount, transaction, calculatedFees, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
16
|
+
const a = getMainAccount(account, parentAccount);
|
|
17
|
+
const t = Object.assign(Object.assign(Object.assign({}, createTransaction()), transaction), { amount: a.spendableBalance });
|
|
18
|
+
const fees = calculatedFees !== null && calculatedFees !== void 0 ? calculatedFees : (yield getEstimatedFees(t));
|
|
19
|
+
const maxSpendable = getMaxAmount(a, t, fees);
|
|
20
|
+
if (maxSpendable.lt(0)) {
|
|
21
|
+
return new BigNumber(0);
|
|
22
|
+
}
|
|
23
|
+
return maxSpendable;
|
|
24
|
+
});
|
|
25
|
+
export default estimateMaxSpendable;
|
|
26
|
+
//# sourceMappingURL=js-estimateMaxSpendable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-estimateMaxSpendable.js","sourceRoot":"","sources":["../src/js-estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAE1D,MAAM,oBAAoB,GAAG,CAAO,EAClC,OAAO,EACP,aAAa,EACb,WAAW,EACX,cAAc,GAMf,EAAsB,EAAE;IACvB,MAAM,CAAC,GAAG,cAAc,CAAC,OAAO,EAAE,aAAa,CAAgB,CAAC;IAChE,MAAM,CAAC,iDACF,iBAAiB,EAAE,GACnB,WAAW,KACd,MAAM,EAAE,CAAC,CAAC,gBAAgB,GAC3B,CAAC;IAEF,MAAM,IAAI,GAAG,cAAc,aAAd,cAAc,cAAd,cAAc,GAAI,CAAC,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAE3D,MAAM,YAAY,GAAG,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC;IAE9C,IAAI,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;QACtB,OAAO,IAAI,SAAS,CAAC,CAAC,CAAC,CAAC;KACzB;IAED,OAAO,YAAY,CAAC;AACtB,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-getFeesForTransaction.d.ts","sourceRoot":"","sources":["../src/js-getFeesForTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,QAAA,MAAM,gBAAgB,gBAAuB,WAAW,KAAG,QAAQ,SAAS,CA8B3E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BigNumber } from "bignumber.js";
|
|
11
|
+
import { getCurrentNearPreloadData } from "./preload";
|
|
12
|
+
import { getGasPrice } from "./api";
|
|
13
|
+
import { isImplicitAccount, getStakingFees } from "./logic";
|
|
14
|
+
const getEstimatedFees = (transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
|
+
const rawGasPrice = yield getGasPrice();
|
|
16
|
+
const gasPrice = new BigNumber(rawGasPrice);
|
|
17
|
+
if (["stake", "unstake", "withdraw"].includes(transaction.mode)) {
|
|
18
|
+
return getStakingFees(transaction, gasPrice);
|
|
19
|
+
}
|
|
20
|
+
const { createAccountCostSend, createAccountCostExecution, transferCostSend, transferCostExecution, addKeyCostSend, addKeyCostExecution, receiptCreationSend, receiptCreationExecution, } = getCurrentNearPreloadData();
|
|
21
|
+
let sendFee = transferCostSend.plus(receiptCreationSend);
|
|
22
|
+
let executionFee = transferCostExecution.plus(receiptCreationExecution);
|
|
23
|
+
if (isImplicitAccount(transaction.recipient)) {
|
|
24
|
+
sendFee = sendFee.plus(createAccountCostSend).plus(addKeyCostSend);
|
|
25
|
+
executionFee = executionFee.plus(createAccountCostExecution).plus(addKeyCostExecution);
|
|
26
|
+
}
|
|
27
|
+
const fees = sendFee.multipliedBy(gasPrice).plus(executionFee.multipliedBy(gasPrice));
|
|
28
|
+
return fees;
|
|
29
|
+
});
|
|
30
|
+
export default getEstimatedFees;
|
|
31
|
+
//# sourceMappingURL=js-getFeesForTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-getFeesForTransaction.js","sourceRoot":"","sources":["../src/js-getFeesForTransaction.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAG5D,MAAM,gBAAgB,GAAG,CAAO,WAAwB,EAAsB,EAAE;IAC9E,MAAM,WAAW,GAAG,MAAM,WAAW,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,CAAC;IAE5C,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE;QAC/D,OAAO,cAAc,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;KAC9C;IAED,MAAM,EACJ,qBAAqB,EACrB,0BAA0B,EAC1B,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,GACzB,GAAG,yBAAyB,EAAE,CAAC;IAEhC,IAAI,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACzD,IAAI,YAAY,GAAG,qBAAqB,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;IAExE,IAAI,iBAAiB,CAAC,WAAW,CAAC,SAAS,CAAC,EAAE;QAC5C,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACnE,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;KACxF;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtF,OAAO,IAAI,CAAC;AACd,CAAC,CAAA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-getTransactionStatus.d.ts","sourceRoot":"","sources":["../src/js-getTransactionStatus.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAkB,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAsB3F,QAAA,MAAM,oBAAoB,MAAa,WAAW,KAAK,WAAW,KAAG,QAAQ,iBAAiB,CA8D7F,CAAC;AAwFF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BigNumber } from "bignumber.js";
|
|
11
|
+
import { NotEnoughBalance, RecipientRequired, InvalidAddress, FeeNotLoaded, AmountRequired, InvalidAddressBecauseDestinationIsAlsoSource, } from "@ledgerhq/errors";
|
|
12
|
+
import { formatCurrencyUnit, getCryptoCurrencyById, } from "@ledgerhq/coin-framework/currencies/index";
|
|
13
|
+
import { isValidAddress, isImplicitAccount, getMaxAmount, getTotalSpent, getYoctoThreshold, } from "./logic";
|
|
14
|
+
import { fetchAccountDetails } from "./api";
|
|
15
|
+
import { getCurrentNearPreloadData } from "./preload";
|
|
16
|
+
import { NearNewAccountWarning, NearActivationFeeNotCovered, NearNewNamedAccountError, NearUseAllAmountStakeWarning, NearNotEnoughStaked, NearNotEnoughAvailable, NearRecommendUnstake, NearStakingThresholdNotMet, } from "./errors";
|
|
17
|
+
import { NEW_ACCOUNT_SIZE, YOCTO_THRESHOLD_VARIATION } from "./constants";
|
|
18
|
+
const getTransactionStatus = (a, t) => __awaiter(void 0, void 0, void 0, function* () {
|
|
19
|
+
if (t.mode === "send") {
|
|
20
|
+
return yield getSendTransactionStatus(a, t);
|
|
21
|
+
}
|
|
22
|
+
const errors = {};
|
|
23
|
+
const warnings = {};
|
|
24
|
+
const useAllAmount = !!t.useAllAmount;
|
|
25
|
+
if (!t.fees) {
|
|
26
|
+
errors.fees = new FeeNotLoaded();
|
|
27
|
+
}
|
|
28
|
+
const estimatedFees = t.fees || new BigNumber(0);
|
|
29
|
+
const maxAmount = getMaxAmount(a, t, estimatedFees);
|
|
30
|
+
const maxAmountWithFees = getMaxAmount(a, t);
|
|
31
|
+
const spendableBalanceWithFees = getMaxAmount(a, Object.assign(Object.assign({}, t), { mode: "stake" }));
|
|
32
|
+
const stakingThreshold = getYoctoThreshold();
|
|
33
|
+
const totalSpent = getTotalSpent(a, t, estimatedFees);
|
|
34
|
+
const amount = useAllAmount ? maxAmount : new BigNumber(t.amount);
|
|
35
|
+
const isStakeAndNotEnoughBalance = t.mode === "stake" && (totalSpent.gt(maxAmountWithFees) || maxAmountWithFees.lt(estimatedFees));
|
|
36
|
+
const isUnstakeOrWithdrawAndNotEnoughBalance = ["unstake", "withdraw"].includes(t.mode) &&
|
|
37
|
+
(totalSpent.gt(spendableBalanceWithFees) || spendableBalanceWithFees.lt(estimatedFees));
|
|
38
|
+
if (isStakeAndNotEnoughBalance || isUnstakeOrWithdrawAndNotEnoughBalance) {
|
|
39
|
+
errors.amount = new NotEnoughBalance();
|
|
40
|
+
}
|
|
41
|
+
else if (["stake", "unstake", "withdraw"].includes(t.mode) && amount.lt(stakingThreshold)) {
|
|
42
|
+
const currency = getCryptoCurrencyById("near");
|
|
43
|
+
const formattedStakingThreshold = formatCurrencyUnit(currency.units[0], stakingThreshold.plus(YOCTO_THRESHOLD_VARIATION), {
|
|
44
|
+
showCode: true,
|
|
45
|
+
});
|
|
46
|
+
errors.amount = new NearStakingThresholdNotMet(undefined, {
|
|
47
|
+
threshold: formattedStakingThreshold,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else if (t.mode === "unstake" && amount.gt(maxAmount)) {
|
|
51
|
+
errors.amount = new NearNotEnoughStaked();
|
|
52
|
+
}
|
|
53
|
+
else if (t.mode === "withdraw" && amount.gt(maxAmount)) {
|
|
54
|
+
errors.amount = new NearNotEnoughAvailable();
|
|
55
|
+
}
|
|
56
|
+
else if (amount.lte(0) && !t.useAllAmount) {
|
|
57
|
+
errors.amount = new AmountRequired();
|
|
58
|
+
}
|
|
59
|
+
if (t.mode === "stake" && !errors.amount && t.useAllAmount) {
|
|
60
|
+
warnings.amount = new NearUseAllAmountStakeWarning();
|
|
61
|
+
}
|
|
62
|
+
return Promise.resolve({
|
|
63
|
+
errors,
|
|
64
|
+
warnings,
|
|
65
|
+
estimatedFees,
|
|
66
|
+
amount,
|
|
67
|
+
totalSpent,
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
const getSendTransactionStatus = (a, t) => __awaiter(void 0, void 0, void 0, function* () {
|
|
71
|
+
var _a;
|
|
72
|
+
const errors = {};
|
|
73
|
+
const warnings = {};
|
|
74
|
+
const useAllAmount = !!t.useAllAmount;
|
|
75
|
+
const { storageCost } = getCurrentNearPreloadData();
|
|
76
|
+
const newAccountStorageCost = storageCost.multipliedBy(NEW_ACCOUNT_SIZE);
|
|
77
|
+
const currency = getCryptoCurrencyById("near");
|
|
78
|
+
const formattedNewAccountStorageCost = formatCurrencyUnit(currency.units[0], newAccountStorageCost, {
|
|
79
|
+
showCode: true,
|
|
80
|
+
});
|
|
81
|
+
let recipientIsNewAccount;
|
|
82
|
+
if (!t.recipient) {
|
|
83
|
+
errors.recipient = new RecipientRequired();
|
|
84
|
+
}
|
|
85
|
+
else if (!isValidAddress(t.recipient)) {
|
|
86
|
+
errors.recipient = new InvalidAddress("", {
|
|
87
|
+
currencyName: a.currency.name,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const accountDetails = yield fetchAccountDetails(t.recipient);
|
|
92
|
+
if (!accountDetails) {
|
|
93
|
+
recipientIsNewAccount = true;
|
|
94
|
+
if (isImplicitAccount(t.recipient)) {
|
|
95
|
+
warnings.recipient = new NearNewAccountWarning(undefined, {
|
|
96
|
+
formattedNewAccountStorageCost,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
errors.recipient = new NearNewNamedAccountError();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (a.freshAddress === t.recipient) {
|
|
105
|
+
warnings.recipient = new InvalidAddressBecauseDestinationIsAlsoSource();
|
|
106
|
+
}
|
|
107
|
+
if (!t.fees) {
|
|
108
|
+
errors.fees = new FeeNotLoaded();
|
|
109
|
+
}
|
|
110
|
+
const estimatedFees = t.fees || new BigNumber(0);
|
|
111
|
+
const totalSpent = getTotalSpent(a, t, estimatedFees);
|
|
112
|
+
const maxAmount = getMaxAmount(a, t, estimatedFees);
|
|
113
|
+
const maxAmountWithFees = getMaxAmount(a, t);
|
|
114
|
+
const amount = useAllAmount ? maxAmount : new BigNumber(t.amount);
|
|
115
|
+
if (totalSpent.gt(maxAmountWithFees) || maxAmountWithFees.lt(estimatedFees)) {
|
|
116
|
+
errors.amount = new NotEnoughBalance();
|
|
117
|
+
}
|
|
118
|
+
else if (amount.lte(0) && !t.useAllAmount) {
|
|
119
|
+
errors.amount = new AmountRequired();
|
|
120
|
+
}
|
|
121
|
+
else if (recipientIsNewAccount && amount.lt(newAccountStorageCost)) {
|
|
122
|
+
errors.amount = new NearActivationFeeNotCovered(undefined, {
|
|
123
|
+
formattedNewAccountStorageCost,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
if (((_a = a.nearResources) === null || _a === void 0 ? void 0 : _a.stakingPositions) &&
|
|
127
|
+
a.nearResources.stakingPositions.length > 0 &&
|
|
128
|
+
useAllAmount) {
|
|
129
|
+
warnings.amount = new NearRecommendUnstake();
|
|
130
|
+
}
|
|
131
|
+
return Promise.resolve({
|
|
132
|
+
errors,
|
|
133
|
+
warnings,
|
|
134
|
+
estimatedFees,
|
|
135
|
+
amount,
|
|
136
|
+
totalSpent,
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
export default getTransactionStatus;
|
|
140
|
+
//# sourceMappingURL=js-getTransactionStatus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-getTransactionStatus.js","sourceRoot":"","sources":["../src/js-getTransactionStatus.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,cAAc,EACd,4CAA4C,GAC7C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,2CAA2C,CAAC;AAEnD,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,iBAAiB,GAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,mBA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AAC,EAAE,CAAC,iBAAiB,CAAC,IAAI,iBAAiB,CAAC,EAAE,CAAC,aAAa,CAAC,EAAE;QAC3E,MAAM,CAAC,MAAM,GAAG,IAAI,gBAAgB,EAAE,CAAC;KACxC;SAAM,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,YAAY,EAAE;QAC3C,MAAM,CAAC,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;KACtC;SAAM,IAAI,qBAAqB,IAAI,MAAM,CAAC,EAAE,CAAC,qBAAqB,CAAC,EAAE;QACpE,MAAM,CAAC,MAAM,GAAG,IAAI,2BAA2B,CAAC,SAAS,EAAE;YACzD,8BAA8B;SAC/B,CAAC,CAAC;KACJ;IAED,IACE,CAAA,MAAA,CAAC,CAAC,aAAa,0CAAE,gBAAgB;QACjC,CAAC,CAAC,aAAa,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC;QAC3C,YAAY,EACZ;QACA,QAAQ,CAAC,MAAM,GAAG,IAAI,oBAAoB,EAAE,CAAC;KAC9C;IAED,OAAO,OAAO,CAAC,OAAO,CAAC;QACrB,MAAM;QACN,QAAQ;QACR,aAAa;QACb,MAAM;QACN,UAAU;KACX,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Transaction } from "./types";
|
|
2
|
+
import type { SignOperationFnSignature } from "@ledgerhq/types-live";
|
|
3
|
+
import { NearAddress, NearSignature, NearSigner } from "./signer";
|
|
4
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
5
|
+
/**
|
|
6
|
+
* Sign Transaction with Ledger hardware
|
|
7
|
+
*/
|
|
8
|
+
export declare const buildSignOperation: (signerContext: SignerContext<NearSigner, NearAddress | NearSignature>) => SignOperationFnSignature<Transaction>;
|
|
9
|
+
export default buildSignOperation;
|
|
10
|
+
//# sourceMappingURL=js-signOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-signOperation.d.ts","sourceRoot":"","sources":["../src/js-signOperation.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,KAAK,EAGV,wBAAwB,EAIzB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AA2ChE;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAEZ,cAAc,UAAU,EAAE,WAAW,GAAG,aAAa,CAAC,KACpE,yBAAyB,WAAW,CAyDnC,CAAC;AAEP,eAAe,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import * as nearAPI from "near-api-js";
|
|
11
|
+
import { BigNumber } from "bignumber.js";
|
|
12
|
+
import { Observable } from "rxjs";
|
|
13
|
+
import { FeeNotLoaded } from "@ledgerhq/errors";
|
|
14
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
15
|
+
import { buildTransaction } from "./js-buildTransaction";
|
|
16
|
+
const buildOptimisticOperation = (account, transaction, fee) => {
|
|
17
|
+
let type;
|
|
18
|
+
let value = new BigNumber(transaction.amount);
|
|
19
|
+
switch (transaction.mode) {
|
|
20
|
+
case "stake":
|
|
21
|
+
type = "STAKE";
|
|
22
|
+
break;
|
|
23
|
+
case "unstake":
|
|
24
|
+
type = "UNSTAKE";
|
|
25
|
+
break;
|
|
26
|
+
case "withdraw":
|
|
27
|
+
type = "WITHDRAW_UNSTAKED";
|
|
28
|
+
break;
|
|
29
|
+
default:
|
|
30
|
+
value = value.plus(fee);
|
|
31
|
+
type = "OUT";
|
|
32
|
+
}
|
|
33
|
+
const operation = {
|
|
34
|
+
id: encodeOperationId(account.id, "", type),
|
|
35
|
+
hash: "",
|
|
36
|
+
type,
|
|
37
|
+
value,
|
|
38
|
+
fee,
|
|
39
|
+
blockHash: null,
|
|
40
|
+
blockHeight: null,
|
|
41
|
+
senders: [account.freshAddress],
|
|
42
|
+
recipients: [transaction.recipient].filter(Boolean),
|
|
43
|
+
accountId: account.id,
|
|
44
|
+
date: new Date(),
|
|
45
|
+
extra: {},
|
|
46
|
+
};
|
|
47
|
+
return operation;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Sign Transaction with Ledger hardware
|
|
51
|
+
*/
|
|
52
|
+
export const buildSignOperation = (signerContext) => ({ account, transaction, deviceId, }) => new Observable(o => {
|
|
53
|
+
function main() {
|
|
54
|
+
var _a;
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
o.next({ type: "device-signature-requested" });
|
|
57
|
+
if (!transaction.fees) {
|
|
58
|
+
throw new FeeNotLoaded();
|
|
59
|
+
}
|
|
60
|
+
const { publicKey } = (yield signerContext(deviceId, signer => signer.getAddress(account.freshAddressPath)));
|
|
61
|
+
const unsigned = yield buildTransaction(account, transaction, publicKey);
|
|
62
|
+
const response = (yield signerContext(deviceId, signer => signer.signTransaction(unsigned.encode(), account.freshAddressPath)));
|
|
63
|
+
const signedTransaction = new nearAPI.transactions.SignedTransaction({
|
|
64
|
+
transaction: unsigned,
|
|
65
|
+
signature: new nearAPI.transactions.Signature({
|
|
66
|
+
keyType: unsigned.publicKey.keyType,
|
|
67
|
+
data: response,
|
|
68
|
+
}),
|
|
69
|
+
});
|
|
70
|
+
o.next({ type: "device-signature-granted" });
|
|
71
|
+
const operation = buildOptimisticOperation(account, transaction, (_a = transaction.fees) !== null && _a !== void 0 ? _a : new BigNumber(0));
|
|
72
|
+
const signedSerializedTx = signedTransaction.encode();
|
|
73
|
+
o.next({
|
|
74
|
+
type: "signed",
|
|
75
|
+
signedOperation: {
|
|
76
|
+
operation,
|
|
77
|
+
signature: Buffer.from(signedSerializedTx).toString("base64"),
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
main().then(() => o.complete(), e => o.error(e));
|
|
83
|
+
});
|
|
84
|
+
export default buildSignOperation;
|
|
85
|
+
//# sourceMappingURL=js-signOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-signOperation.js","sourceRoot":"","sources":["../src/js-signOperation.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,OAAO,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAUhD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,MAAM,wBAAwB,GAAG,CAC/B,OAAgB,EAChB,WAAwB,EACxB,GAAc,EACH,EAAE;IACb,IAAI,IAAmB,CAAC;IACxB,IAAI,KAAK,GAAG,IAAI,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAE9C,QAAQ,WAAW,CAAC,IAAI,EAAE;QACxB,KAAK,OAAO;YACV,IAAI,GAAG,OAAO,CAAC;YACf,M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B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import type { GetAccountShape } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
3
|
+
export declare const getAccountShape: GetAccountShape;
|
|
4
|
+
export declare const sync: (initialAccount: Account, syncConfig: import("@ledgerhq/types-live").SyncConfig) => import("rxjs").Observable<(arg0: Account) => Account>;
|
|
5
|
+
//# sourceMappingURL=js-synchronisation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-synchronisation.d.ts","sourceRoot":"","sources":["../src/js-synchronisation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAIjF,eAAO,MAAM,eAAe,EAAE,eA2B7B,CAAC;AAkBF,eAAO,MAAM,IAAI,2IAA0C,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { encodeAccountId } from "@ledgerhq/coin-framework/account/accountId";
|
|
11
|
+
import { makeSync, mergeOps } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
12
|
+
import { getAccount, getOperations } from "./api";
|
|
13
|
+
export const getAccountShape = (info) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
const { address, initialAccount, currency, derivationMode } = info;
|
|
15
|
+
const oldOperations = (initialAccount === null || initialAccount === void 0 ? void 0 : initialAccount.operations) || [];
|
|
16
|
+
const accountId = encodeAccountId({
|
|
17
|
+
type: "js",
|
|
18
|
+
version: "2",
|
|
19
|
+
currencyId: currency.id,
|
|
20
|
+
xpubOrAddress: address,
|
|
21
|
+
derivationMode,
|
|
22
|
+
});
|
|
23
|
+
const { blockHeight, balance, spendableBalance, nearResources } = yield getAccount(address);
|
|
24
|
+
const newOperations = yield getOperations(accountId, address);
|
|
25
|
+
const operations = mergeOps(oldOperations, newOperations);
|
|
26
|
+
const shape = {
|
|
27
|
+
id: accountId,
|
|
28
|
+
balance,
|
|
29
|
+
spendableBalance,
|
|
30
|
+
operationsCount: operations.length,
|
|
31
|
+
blockHeight,
|
|
32
|
+
nearResources,
|
|
33
|
+
};
|
|
34
|
+
return Object.assign(Object.assign({}, shape), { operations });
|
|
35
|
+
});
|
|
36
|
+
const postSync = (initial, synced) => {
|
|
37
|
+
const pendingOperations = initial.pendingOperations || [];
|
|
38
|
+
if (pendingOperations.length === 0) {
|
|
39
|
+
return synced;
|
|
40
|
+
}
|
|
41
|
+
const { operations } = synced;
|
|
42
|
+
synced.pendingOperations = pendingOperations.filter(po => !operations.some(o => o.hash === po.hash));
|
|
43
|
+
return synced;
|
|
44
|
+
};
|
|
45
|
+
export const sync = makeSync({ getAccountShape, postSync });
|
|
46
|
+
//# sourceMappingURL=js-synchronisation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-synchronisation.js","sourceRoot":"","sources":["../src/js-synchronisation.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAE7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,M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C,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,IAAI,CAAC,CAChD,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import type { Transaction } from "./types";
|
|
3
|
+
export declare const createTransaction: () => Transaction;
|
|
4
|
+
export declare const prepareTransaction: (a: Account, t: Transaction) => Promise<Transaction>;
|
|
5
|
+
//# sourceMappingURL=js-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-transaction.d.ts","sourceRoot":"","sources":["../src/js-transaction.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3C,eAAO,MAAM,iBAAiB,QAAO,WAOnC,CAAC;AAEH,eAAO,MAAM,kBAAkB,MAAa,OAAO,KAAK,WAAW,KAAG,QAAQ,WAAW,CAYxF,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { BigNumber } from "bignumber.js";
|
|
11
|
+
import { defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
12
|
+
import getEstimatedFees from "./js-getFeesForTransaction";
|
|
13
|
+
import estimateMaxSpendable from "./js-estimateMaxSpendable";
|
|
14
|
+
export const createTransaction = () => ({
|
|
15
|
+
family: "near",
|
|
16
|
+
mode: "send",
|
|
17
|
+
amount: new BigNumber(0),
|
|
18
|
+
recipient: "",
|
|
19
|
+
useAllAmount: false,
|
|
20
|
+
fees: new BigNumber(0),
|
|
21
|
+
});
|
|
22
|
+
export const prepareTransaction = (a, t) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
const fees = yield getEstimatedFees(t);
|
|
24
|
+
const amount = t.useAllAmount
|
|
25
|
+
? yield estimateMaxSpendable({
|
|
26
|
+
account: a,
|
|
27
|
+
transaction: t,
|
|
28
|
+
calculatedFees: fees,
|
|
29
|
+
})
|
|
30
|
+
: t.amount;
|
|
31
|
+
return defaultUpdateTransaction(t, { fees, amount });
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=js-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js-transaction.js","sourceRoot":"","sources":["../src/js-transaction.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAErF,OAAO,gBAAgB,MAAM,4BAA4B,CAAC;AAC1D,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAE7D,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAgB,EAAE,CAAC,CAAC;IACnD,MAAM,EAAE,MAAM;IACd,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;IACxB,SAAS,EAAE,EAAE;IACb,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAO,CAAU,EAAE,CAAc,EAAwB,EAAE;IAC3F,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAG,CAAC,CAAC,YAAY;QAC3B,CAAC,CAAC,MAAM,oBAAoB,CAAC;YACzB,OAAO,EAAE,CAAC;YACV,WAAW,EAAE,CAAC;YACd,cAAc,EAAE,IAAI;SACrB,CAAC;QACJ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;IAEb,OAAO,wBAAwB,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AACvD,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { Unit } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
import { NearMappedStakingPosition, Transaction, NearStakingPosition, NearValidatorItem, NearAccount } from "./types";
|
|
4
|
+
export declare const isValidAddress: (address: string) => boolean;
|
|
5
|
+
export declare const isImplicitAccount: (address: string) => boolean;
|
|
6
|
+
export declare const getStakingGas: (t?: Transaction, multiplier?: number) => BigNumber;
|
|
7
|
+
export declare const getMaxAmount: (a: NearAccount, t: Transaction, fees?: BigNumber) => BigNumber;
|
|
8
|
+
export declare const getTotalSpent: (a: NearAccount, t: Transaction, fees: BigNumber) => BigNumber;
|
|
9
|
+
export declare const mapStakingPositions: (stakingPositions: NearStakingPosition[], validators: NearValidatorItem[], unit: Unit) => NearMappedStakingPosition[];
|
|
10
|
+
export declare const canStake: (a: NearAccount) => boolean;
|
|
11
|
+
export declare const canUnstake: (stakingPosition: NearMappedStakingPosition | NearStakingPosition) => boolean;
|
|
12
|
+
export declare const canWithdraw: (stakingPosition: NearMappedStakingPosition | NearStakingPosition) => boolean;
|
|
13
|
+
export declare const getYoctoThreshold: () => BigNumber;
|
|
14
|
+
export declare const getStakingFees: (t: Transaction, gasPrice: BigNumber) => BigNumber;
|
|
15
|
+
//# sourceMappingURL=logic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.d.ts","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EACL,yBAAyB,EACzB,WAAW,EACX,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACZ,MAAM,SAAS,CAAC;AAMjB,eAAO,MAAM,cAAc,YAAa,MAAM,KAAG,OAShD,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAa,MAAM,KAAG,OAEnD,CAAC;AAEF,eAAO,MAAM,aAAa,OAAQ,WAAW,0BAAmB,SAQ/D,CAAC;AAKF,eAAO,MAAM,YAAY,MAAO,WAAW,KAAK,WAAW,SAAS,SAAS,KAAG,SA0C/E,CAAC;AAEF,eAAO,MAAM,aAAa,MAAO,WAAW,KAAK,WAAW,QAAQ,SAAS,KAAG,SAU/E,CAAC;AAEF,eAAO,MAAM,mBAAmB,qBACZ,mBAAmB,EAAE,cAC3B,iBAAiB,EAAE,QACzB,IAAI,KACT,yBAAyB,EAoB3B,CAAC;AAKF,eAAO,MAAM,QAAQ,MAAO,WAAW,KAAG,OAWzC,CAAC;AAEF,eAAO,MAAM,UAAU,oBACJ,yBAAyB,GAAG,mBAAmB,KAC/D,OAEF,CAAC;AAEF,eAAO,MAAM,WAAW,oBACL,yBAAyB,GAAG,mBAAmB,KAC/D,OAEF,CAAC;AAMF,eAAO,MAAM,iBAAiB,QAAO,SAIpC,CAAC;AAMF,eAAO,MAAM,cAAc,MAAO,WAAW,YAAY,SAAS,KAAG,SAOpE,CAAC"}
|
package/lib-es/logic.js
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import { utils } from "near-api-js";
|
|
3
|
+
import { formatCurrencyUnit } from "@ledgerhq/coin-framework/currencies/index";
|
|
4
|
+
import { createTransaction } from "./js-transaction";
|
|
5
|
+
import { defaultUpdateTransaction as updateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
6
|
+
import { getCurrentNearPreloadData } from "./preload";
|
|
7
|
+
import { FRACTIONAL_DIGITS, STAKING_GAS_BASE, YOCTO_THRESHOLD_VARIATION } from "./constants";
|
|
8
|
+
export const isValidAddress = (address) => {
|
|
9
|
+
const readableAddressRegex = /^(([a-z\d]+[-_])*[a-z\d]+\.)*([a-z\d]+[-_])*[a-z\d]+$/;
|
|
10
|
+
const hexAddressRegex = /^[a-f0-9]{64}$/;
|
|
11
|
+
if (isImplicitAccount(address)) {
|
|
12
|
+
return hexAddressRegex.test(address);
|
|
13
|
+
}
|
|
14
|
+
return readableAddressRegex.test(address);
|
|
15
|
+
};
|
|
16
|
+
export const isImplicitAccount = (address) => {
|
|
17
|
+
return !address.includes(".");
|
|
18
|
+
};
|
|
19
|
+
export const getStakingGas = (t, multiplier = 5) => {
|
|
20
|
+
const stakingGasBase = new BigNumber(STAKING_GAS_BASE);
|
|
21
|
+
if ((t === null || t === void 0 ? void 0 : t.mode) === "withdraw" && (t === null || t === void 0 ? void 0 : t.useAllAmount)) {
|
|
22
|
+
multiplier = 7;
|
|
23
|
+
}
|
|
24
|
+
return stakingGasBase.multipliedBy(multiplier);
|
|
25
|
+
};
|
|
26
|
+
/*
|
|
27
|
+
* Get the max amount that can be spent, taking into account tx type and pending operations.
|
|
28
|
+
*/
|
|
29
|
+
export const getMaxAmount = (a, t, fees) => {
|
|
30
|
+
var _a;
|
|
31
|
+
let maxAmount;
|
|
32
|
+
const selectedValidator = (_a = a.nearResources) === null || _a === void 0 ? void 0 : _a.stakingPositions.find(({ validatorId }) => validatorId === t.recipient);
|
|
33
|
+
let pendingUnstakingAmount = new BigNumber(0);
|
|
34
|
+
let pendingWithdrawingAmount = new BigNumber(0);
|
|
35
|
+
let pendingDefaultAmount = new BigNumber(0);
|
|
36
|
+
a.pendingOperations.forEach(({ type, value, recipients }) => {
|
|
37
|
+
const recipient = recipients[0];
|
|
38
|
+
if (type === "UNSTAKE" && recipient === (selectedValidator === null || selectedValidator === void 0 ? void 0 : selectedValidator.validatorId)) {
|
|
39
|
+
pendingUnstakingAmount = pendingUnstakingAmount.plus(value);
|
|
40
|
+
}
|
|
41
|
+
else if (type === "WITHDRAW_UNSTAKED" && recipient === (selectedValidator === null || selectedValidator === void 0 ? void 0 : selectedValidator.validatorId)) {
|
|
42
|
+
pendingWithdrawingAmount = pendingWithdrawingAmount.plus(value);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
pendingDefaultAmount = pendingDefaultAmount.plus(value);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
switch (t.mode) {
|
|
49
|
+
case "unstake":
|
|
50
|
+
maxAmount = selectedValidator === null || selectedValidator === void 0 ? void 0 : selectedValidator.staked.minus(pendingUnstakingAmount);
|
|
51
|
+
break;
|
|
52
|
+
case "withdraw":
|
|
53
|
+
maxAmount = selectedValidator === null || selectedValidator === void 0 ? void 0 : selectedValidator.available.minus(pendingWithdrawingAmount);
|
|
54
|
+
break;
|
|
55
|
+
default:
|
|
56
|
+
maxAmount = a.spendableBalance.minus(pendingDefaultAmount);
|
|
57
|
+
if (fees) {
|
|
58
|
+
maxAmount = maxAmount.minus(fees);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (maxAmount === undefined || maxAmount.lt(0)) {
|
|
62
|
+
return new BigNumber(0);
|
|
63
|
+
}
|
|
64
|
+
return maxAmount;
|
|
65
|
+
};
|
|
66
|
+
export const getTotalSpent = (a, t, fees) => {
|
|
67
|
+
if (["unstake", "withdraw"].includes(t.mode)) {
|
|
68
|
+
return fees;
|
|
69
|
+
}
|
|
70
|
+
if (t.useAllAmount) {
|
|
71
|
+
return a.spendableBalance;
|
|
72
|
+
}
|
|
73
|
+
return new BigNumber(t.amount).plus(fees);
|
|
74
|
+
};
|
|
75
|
+
export const mapStakingPositions = (stakingPositions, validators, unit) => {
|
|
76
|
+
return stakingPositions.map(sp => {
|
|
77
|
+
var _a;
|
|
78
|
+
const rank = validators.findIndex(v => v.validatorAddress === sp.validatorId);
|
|
79
|
+
const validator = (_a = validators[rank]) !== null && _a !== void 0 ? _a : sp;
|
|
80
|
+
const formatConfig = {
|
|
81
|
+
disableRounding: false,
|
|
82
|
+
alwaysShowSign: false,
|
|
83
|
+
showCode: true,
|
|
84
|
+
};
|
|
85
|
+
return Object.assign(Object.assign({}, sp), { formattedAmount: formatCurrencyUnit(unit, sp.staked, formatConfig), formattedRewards: formatCurrencyUnit(unit, sp.rewards, formatConfig), formattedPending: formatCurrencyUnit(unit, sp.pending, formatConfig), formattedAvailable: formatCurrencyUnit(unit, sp.available, formatConfig), rank,
|
|
86
|
+
validator });
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
/*
|
|
90
|
+
* Make sure that an account has enough funds to stake, unstake, AND withdraw before staking.
|
|
91
|
+
*/
|
|
92
|
+
export const canStake = (a) => {
|
|
93
|
+
let transaction = createTransaction();
|
|
94
|
+
transaction = updateTransaction(transaction, {
|
|
95
|
+
mode: "stake",
|
|
96
|
+
});
|
|
97
|
+
const { gasPrice } = getCurrentNearPreloadData();
|
|
98
|
+
const fees = getStakingFees(transaction, gasPrice).multipliedBy(3);
|
|
99
|
+
return getMaxAmount(a, transaction, fees).gt(0);
|
|
100
|
+
};
|
|
101
|
+
export const canUnstake = (stakingPosition) => {
|
|
102
|
+
return stakingPosition.staked.gte(getYoctoThreshold());
|
|
103
|
+
};
|
|
104
|
+
export const canWithdraw = (stakingPosition) => {
|
|
105
|
+
return stakingPosition.available.gte(getYoctoThreshold());
|
|
106
|
+
};
|
|
107
|
+
/*
|
|
108
|
+
* The threshold that the NEAR wallet uses for staking, unstaking, and withdrawing.
|
|
109
|
+
* A "1" is subtracted due to the value from the node being 1 yoctoNEAR less than what was staked.
|
|
110
|
+
*/
|
|
111
|
+
export const getYoctoThreshold = () => {
|
|
112
|
+
return new BigNumber(10)
|
|
113
|
+
.pow(new BigNumber(utils.format.NEAR_NOMINATION_EXP - FRACTIONAL_DIGITS))
|
|
114
|
+
.minus(YOCTO_THRESHOLD_VARIATION);
|
|
115
|
+
};
|
|
116
|
+
/*
|
|
117
|
+
* An estimation for the fee by using the staking gas and scaling accordingly.
|
|
118
|
+
* Buffer added so that the transaction never fails - we'll always overestimate.
|
|
119
|
+
*/
|
|
120
|
+
export const getStakingFees = (t, gasPrice) => {
|
|
121
|
+
const stakingGas = getStakingGas(t);
|
|
122
|
+
return stakingGas
|
|
123
|
+
.plus(STAKING_GAS_BASE) // Buffer
|
|
124
|
+
.multipliedBy(gasPrice)
|
|
125
|
+
.dividedBy(10);
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=logic.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logic.js","sourceRoot":"","sources":["../src/logic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAS/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,wBAAwB,IAAI,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAC1G,OAAO,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE7F,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAe,EAAW,EAAE;IACzD,MAAM,oBAAoB,GAAG,uDAAuD,CAAC;I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