@ledgerhq/coin-icon 0.6.2 → 0.6.3
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +14 -0
- package/lib/__test__/api/index.unit.test.js +6 -15
- package/lib/__test__/api/index.unit.test.js.map +1 -1
- package/lib/__test__/unit/buildTransaction.test.js +10 -16
- package/lib/__test__/unit/buildTransaction.test.js.map +1 -1
- package/lib/__test__/unit/getFeesForTransaction.unit.test.js +6 -15
- package/lib/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -1
- package/lib/__test__/unit/getTransactionStatus.unit.test.js +36 -45
- package/lib/__test__/unit/getTransactionStatus.unit.test.js.map +1 -1
- package/lib/api/index.js +27 -38
- package/lib/api/index.js.map +1 -1
- package/lib/api/node.js +15 -24
- package/lib/api/node.js.map +1 -1
- package/lib/bridge/index.js +1 -10
- package/lib/bridge/index.js.map +1 -1
- package/lib/broadcast.js +3 -14
- package/lib/broadcast.js.map +1 -1
- package/lib/buildTransaction.js +2 -11
- package/lib/buildTransaction.js.map +1 -1
- package/lib/cli-transaction.js +5 -1
- package/lib/cli-transaction.js.map +1 -1
- package/lib/estimateMaxSpendable.js +5 -14
- package/lib/estimateMaxSpendable.js.map +1 -1
- package/lib/getFeesForTransaction.js +14 -17
- package/lib/getFeesForTransaction.js.map +1 -1
- package/lib/getTransactionStatus.js +7 -17
- package/lib/getTransactionStatus.js.map +1 -1
- package/lib/hw-getAddress.js +3 -12
- package/lib/hw-getAddress.js.map +1 -1
- package/lib/logic.js +1 -2
- package/lib/logic.js.map +1 -1
- package/lib/prepareTransaction.js +4 -13
- package/lib/prepareTransaction.js.map +1 -1
- package/lib/signOperation.js +33 -39
- package/lib/signOperation.js.map +1 -1
- package/lib/specs.js +3 -1
- package/lib/specs.js.map +1 -1
- package/lib/synchronization.js +9 -18
- package/lib/synchronization.js.map +1 -1
- package/lib/transaction.js +14 -3
- package/lib/transaction.js.map +1 -1
- package/lib/types/bridge.fixture.js +22 -22
- package/lib/types/bridge.fixture.js.map +1 -1
- package/lib-es/__test__/api/index.unit.test.js +6 -15
- package/lib-es/__test__/api/index.unit.test.js.map +1 -1
- package/lib-es/__test__/unit/buildTransaction.test.js +10 -16
- package/lib-es/__test__/unit/buildTransaction.test.js.map +1 -1
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js +6 -15
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -1
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.js +36 -45
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.js.map +1 -1
- package/lib-es/api/index.js +27 -38
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/node.js +15 -24
- package/lib-es/api/node.js.map +1 -1
- package/lib-es/bridge/index.js +1 -10
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/broadcast.js +3 -14
- package/lib-es/broadcast.js.map +1 -1
- package/lib-es/buildTransaction.js +2 -11
- package/lib-es/buildTransaction.js.map +1 -1
- package/lib-es/cli-transaction.js +5 -1
- package/lib-es/cli-transaction.js.map +1 -1
- package/lib-es/estimateMaxSpendable.js +5 -14
- package/lib-es/estimateMaxSpendable.js.map +1 -1
- package/lib-es/getFeesForTransaction.js +14 -17
- package/lib-es/getFeesForTransaction.js.map +1 -1
- package/lib-es/getTransactionStatus.js +7 -17
- package/lib-es/getTransactionStatus.js.map +1 -1
- package/lib-es/hw-getAddress.js +3 -12
- package/lib-es/hw-getAddress.js.map +1 -1
- package/lib-es/logic.js +1 -2
- package/lib-es/logic.js.map +1 -1
- package/lib-es/prepareTransaction.js +4 -13
- package/lib-es/prepareTransaction.js.map +1 -1
- package/lib-es/signOperation.js +33 -39
- package/lib-es/signOperation.js.map +1 -1
- package/lib-es/specs.js +3 -1
- package/lib-es/specs.js.map +1 -1
- package/lib-es/synchronization.js +9 -18
- package/lib-es/synchronization.js.map +1 -1
- package/lib-es/transaction.js +14 -3
- package/lib-es/transaction.js.map +1 -1
- package/lib-es/types/bridge.fixture.js +22 -22
- package/lib-es/types/bridge.fixture.js.map +1 -1
- package/package.json +4 -4
- package/tsconfig.json +0 -1
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { BigNumber } from "bignumber.js";
|
|
11
2
|
import { NotEnoughBalance, RecipientRequired, InvalidAddress, FeeNotLoaded, InvalidAddressBecauseDestinationIsAlsoSource, AmountRequired, } from "@ledgerhq/errors";
|
|
12
3
|
import * as logic from "../../logic";
|
|
@@ -52,50 +43,50 @@ describe("getSendTransactionStatus", () => {
|
|
|
52
43
|
mockedLogic.isValidAddress.mockReturnValue(true);
|
|
53
44
|
mockedFormatCurrencyUnit.mockReturnValue("1 ICX");
|
|
54
45
|
});
|
|
55
|
-
it("should return FeeNotLoaded error if fees are not loaded", () =>
|
|
46
|
+
it("should return FeeNotLoaded error if fees are not loaded", async () => {
|
|
56
47
|
transaction.fees = null;
|
|
57
|
-
const result =
|
|
48
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
58
49
|
expect(result.errors.fees).toBeInstanceOf(FeeNotLoaded);
|
|
59
|
-
})
|
|
60
|
-
it("should return RecipientRequired error if recipient is missing", () =>
|
|
50
|
+
});
|
|
51
|
+
it("should return RecipientRequired error if recipient is missing", async () => {
|
|
61
52
|
transaction.recipient = "";
|
|
62
|
-
const result =
|
|
53
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
63
54
|
expect(result.errors.recipient).toBeInstanceOf(RecipientRequired);
|
|
64
|
-
})
|
|
65
|
-
it("should return InvalidAddressBecauseDestinationIsAlsoSource error if recipient is the same as source", () =>
|
|
55
|
+
});
|
|
56
|
+
it("should return InvalidAddressBecauseDestinationIsAlsoSource error if recipient is the same as source", async () => {
|
|
66
57
|
mockedLogic.isSelfTransaction.mockReturnValue(true);
|
|
67
|
-
const result =
|
|
58
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
68
59
|
expect(result.errors.recipient).toBeInstanceOf(InvalidAddressBecauseDestinationIsAlsoSource);
|
|
69
|
-
})
|
|
70
|
-
it("should return InvalidAddress error if recipient is invalid", () =>
|
|
60
|
+
});
|
|
61
|
+
it("should return InvalidAddress error if recipient is invalid", async () => {
|
|
71
62
|
mockedLogic.isValidAddress.mockReturnValue(false);
|
|
72
|
-
const result =
|
|
63
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
73
64
|
expect(result.errors.recipient).toBeInstanceOf(InvalidAddress);
|
|
74
|
-
})
|
|
75
|
-
it("should return AmountRequired error if amount is less than or equal to zero", () =>
|
|
65
|
+
});
|
|
66
|
+
it("should return AmountRequired error if amount is less than or equal to zero", async () => {
|
|
76
67
|
mockedLogic.calculateAmount.mockReturnValue(new BigNumber(0));
|
|
77
|
-
const result =
|
|
68
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
78
69
|
expect(result.errors.amount).toBeInstanceOf(AmountRequired);
|
|
79
|
-
})
|
|
80
|
-
it("should return NotEnoughBalance error if total spent exceeds spendable balance", () =>
|
|
70
|
+
});
|
|
71
|
+
it("should return NotEnoughBalance error if total spent exceeds spendable balance", async () => {
|
|
81
72
|
account.spendableBalance = new BigNumber(50);
|
|
82
|
-
const result =
|
|
73
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
83
74
|
expect(result.errors.amount).toBeInstanceOf(NotEnoughBalance);
|
|
84
|
-
})
|
|
85
|
-
it("should return proper TransactionStatus when everything is valid", () =>
|
|
86
|
-
const result =
|
|
75
|
+
});
|
|
76
|
+
it("should return proper TransactionStatus when everything is valid", async () => {
|
|
77
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
87
78
|
expect(result.errors).toEqual({});
|
|
88
79
|
expect(result.warnings).toEqual({});
|
|
89
80
|
expect(result.estimatedFees).toEqual(transaction.fees);
|
|
90
81
|
expect(result.amount).toEqual(new BigNumber(100));
|
|
91
82
|
expect(result.totalSpent).toEqual(new BigNumber(110));
|
|
92
|
-
})
|
|
93
|
-
it("should return IconDoMaxSendInstead error if leftover balance is less than minimumBalanceExistential but greater than zero", () =>
|
|
83
|
+
});
|
|
84
|
+
it("should return IconDoMaxSendInstead error if leftover balance is less than minimumBalanceExistential but greater than zero", async () => {
|
|
94
85
|
account.spendableBalance = new BigNumber(120);
|
|
95
|
-
const result =
|
|
86
|
+
const result = await getSendTransactionStatus(account, transaction);
|
|
96
87
|
expect(result.errors.amount).toBeInstanceOf(IconDoMaxSendInstead);
|
|
97
88
|
expect(result.errors.amount.message).toBe("Balance cannot be below {{minimumBalance}}. Send max to empty account.");
|
|
98
|
-
})
|
|
89
|
+
});
|
|
99
90
|
});
|
|
100
91
|
describe("getTransactionStatus", () => {
|
|
101
92
|
let account;
|
|
@@ -112,7 +103,7 @@ describe("getTransactionStatus", () => {
|
|
|
112
103
|
};
|
|
113
104
|
mockedLogic.calculateAmount.mockReturnValue(new BigNumber(100));
|
|
114
105
|
});
|
|
115
|
-
it("should delegate to getSendTransactionStatus for send mode", () =>
|
|
106
|
+
it("should delegate to getSendTransactionStatus for send mode", async () => {
|
|
116
107
|
const sendTransactionStatus = {
|
|
117
108
|
errors: {},
|
|
118
109
|
warnings: {},
|
|
@@ -123,31 +114,31 @@ describe("getTransactionStatus", () => {
|
|
|
123
114
|
jest
|
|
124
115
|
.spyOn(TransactionStatus, "getSendTransactionStatus")
|
|
125
116
|
.mockResolvedValue(sendTransactionStatus);
|
|
126
|
-
const result =
|
|
117
|
+
const result = await getTransactionStatus(account, transaction);
|
|
127
118
|
expect(result).toEqual(sendTransactionStatus);
|
|
128
|
-
})
|
|
129
|
-
it("should handle default case correctly", () =>
|
|
119
|
+
});
|
|
120
|
+
it("should handle default case correctly", async () => {
|
|
130
121
|
transaction.mode = "other";
|
|
131
|
-
const result =
|
|
122
|
+
const result = await getTransactionStatus(account, transaction);
|
|
132
123
|
expect(result.errors).toEqual({});
|
|
133
124
|
expect(result.warnings).toEqual({});
|
|
134
125
|
expect(result.estimatedFees).toEqual(transaction.fees);
|
|
135
126
|
expect(result.amount).toEqual(new BigNumber(100));
|
|
136
127
|
expect(result.totalSpent).toEqual(new BigNumber(110));
|
|
137
|
-
})
|
|
138
|
-
it("should return NotEnoughBalance error if totalSpent is greater than spendableBalance", () =>
|
|
128
|
+
});
|
|
129
|
+
it("should return NotEnoughBalance error if totalSpent is greater than spendableBalance", async () => {
|
|
139
130
|
transaction.mode = "";
|
|
140
131
|
mockedLogic.calculateAmount.mockReturnValue(new BigNumber(1000));
|
|
141
132
|
transaction.fees = new BigNumber(100);
|
|
142
|
-
const result =
|
|
133
|
+
const result = await getTransactionStatus(account, transaction);
|
|
143
134
|
expect(result.errors.amount).toBeInstanceOf(NotEnoughBalance);
|
|
144
|
-
})
|
|
145
|
-
it("should return AmountRequired error if amount is less than or equal to zero and useAllAmount is false", () =>
|
|
135
|
+
});
|
|
136
|
+
it("should return AmountRequired error if amount is less than or equal to zero and useAllAmount is false", async () => {
|
|
146
137
|
transaction.mode = "";
|
|
147
138
|
mockedLogic.calculateAmount.mockReturnValue(new BigNumber(0));
|
|
148
139
|
transaction.useAllAmount = false;
|
|
149
|
-
const result =
|
|
140
|
+
const result = await getTransactionStatus(account, transaction);
|
|
150
141
|
expect(result.errors.amount).toBeInstanceOf(AmountRequired);
|
|
151
|
-
})
|
|
142
|
+
});
|
|
152
143
|
});
|
|
153
144
|
//# sourceMappingURL=getTransactionStatus.unit.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getTransactionStatus.unit.test.js","sourceRoot":"","sources":["../../../src/__test__/unit/getTransactionStatus.unit.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getTransactionStatus.unit.test.js","sourceRoot":"","sources":["../../../src/__test__/unit/getTransactionStatus.unit.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,YAAY,EACZ,4CAA4C,EAC5C,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,KAAK,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAE/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AACzB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvB,IAAI,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;AAEvD,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACvC,MAAM,wBAAwB,GAAG,IAAI,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAEjE,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAI,OAAoB,CAAC;IACzB,IAAI,WAAwB,CAAC;IAE7B,UAAU,CAAC,GAAG,EAAE;QACd,OAAO,GAAG;YACR,gBAAgB,EAAE,IAAI,SAAS,CAAC,IAAI,CAAC;YACrC,QAAQ,EAAE;gBACR,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE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CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/api/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import network from "@ledgerhq/live-network/network";
|
|
11
2
|
import { BigNumber } from "bignumber.js";
|
|
12
3
|
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
@@ -28,29 +19,27 @@ function getApiUrl(network) {
|
|
|
28
19
|
}
|
|
29
20
|
return apiUrl;
|
|
30
21
|
}
|
|
31
|
-
function fetch(url) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
async function fetch(url) {
|
|
23
|
+
const { data } = await network({
|
|
24
|
+
method: "GET",
|
|
25
|
+
url,
|
|
26
|
+
});
|
|
27
|
+
if (data.Error) {
|
|
28
|
+
log("icon-error", data.Error, {
|
|
35
29
|
url,
|
|
36
30
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
41
|
-
throw new Error(data.Error);
|
|
42
|
-
}
|
|
43
|
-
return data;
|
|
44
|
-
});
|
|
31
|
+
throw new Error(data.Error);
|
|
32
|
+
}
|
|
33
|
+
return data;
|
|
45
34
|
}
|
|
46
|
-
export const getAccount = (addr, network) =>
|
|
47
|
-
const data =
|
|
35
|
+
export const getAccount = async (addr, network) => {
|
|
36
|
+
const data = await fetch(`${getApiUrl(network)}/addresses/details/${addr}`);
|
|
48
37
|
return data;
|
|
49
|
-
}
|
|
50
|
-
export const getCurrentBlockHeight = (network) =>
|
|
51
|
-
const data =
|
|
52
|
-
return data
|
|
53
|
-
}
|
|
38
|
+
};
|
|
39
|
+
export const getCurrentBlockHeight = async (network) => {
|
|
40
|
+
const data = await fetch(`${getApiUrl(network)}/blocks`);
|
|
41
|
+
return data?.[0].number;
|
|
42
|
+
};
|
|
54
43
|
/**
|
|
55
44
|
* Returns true if account is the signer
|
|
56
45
|
*/
|
|
@@ -100,24 +89,24 @@ function txToOperation(accountId, addr, transaction) {
|
|
|
100
89
|
/**
|
|
101
90
|
* Fetch operation list
|
|
102
91
|
*/
|
|
103
|
-
export const getOperations = (accountId, addr, skip, network, maxLength) =>
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
export const fetchOperationList =
|
|
107
|
-
const data =
|
|
92
|
+
export const getOperations = async (accountId, addr, skip, network, maxLength) => {
|
|
93
|
+
return await fetchOperationList(accountId, addr, skip, network, maxLength);
|
|
94
|
+
};
|
|
95
|
+
export const fetchOperationList = async (accountId, addr, skip, network, maxLength, prevOperations = []) => {
|
|
96
|
+
const data = await getTxHistory(addr, skip, network);
|
|
108
97
|
const operations = data.map((transaction) => txToOperation(accountId, addr, transaction));
|
|
109
98
|
const mergedOp = [...prevOperations, ...operations];
|
|
110
99
|
if (operations.length < LIMIT || operations.length >= maxLength) {
|
|
111
100
|
return mergedOp;
|
|
112
101
|
}
|
|
113
|
-
return
|
|
114
|
-
}
|
|
115
|
-
export const getTxHistory =
|
|
102
|
+
return await fetchOperationList(accountId, addr, skip + LIMIT, network, maxLength, mergedOp);
|
|
103
|
+
};
|
|
104
|
+
export const getTxHistory = async (addr, skip, network, limit = LIMIT) => {
|
|
116
105
|
const query = querystring.stringify({
|
|
117
106
|
skip: skip,
|
|
118
107
|
limit: limit,
|
|
119
108
|
});
|
|
120
|
-
const data =
|
|
109
|
+
const data = await fetch(`${getApiUrl(network)}/transactions/address/${addr}?${query}`);
|
|
121
110
|
return data;
|
|
122
|
-
}
|
|
111
|
+
};
|
|
123
112
|
//# sourceMappingURL=index.js.map
|
package/lib-es/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,WAAW,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C;;;;GAIG;AACH,SAAS,SAAS,CAAC,OAAuB;IACxC,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;IACvC,IAAI,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC;IAC1C,IAAI,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,eAAe,CAAC;IAChD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,KAAK,UAAU,KAAK,CAAC,GAAW;IAC9B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,OAAO,CAAC;QAC7B,MAAM,EAAE,KAAK;QACb,GAAG;KACJ,CAAC,CAAC;IAEH,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,GAAG,CAAC,YAAY,EAAE,IAAI,CAAC,K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OAAuB,EACvB,SAAiB,EACjB,iBAAkC,EAAE,EACV,EAAE;IAC5B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,WAAgC,EAAE,EAAE,CAC/D,aAAa,CAAC,SAAS,EAAE,IAAI,EAAE,WAAW,CAAC,CAC5C,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,GAAG,cAAc,EAAE,GAAG,UAAU,CAAC,CAAC;IACpD,IAAI,UAAU,CAAC,MAAM,GAAG,KAAK,IAAI,UAAU,CAAC,MAAM,IAAI,SAAS,EAAE,CAAC;QAChE,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,MAAM,kBAAkB,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAC/F,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAC/B,IAAY,EACZ,IAAY,EACZ,OAAuB,EACvB,QAAgB,KAAK,EACW,EAAE;IAClC,MAAM,KAAK,GAAG,WAAW,CAAC,SAAS,CAAC;QAClC,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,KAAK;KACb,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,yBAAyB,IAAI,IAAI,KAAK,EAAE,CAAC,CAAC;IACxF,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/lib-es/api/node.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { BigNumber } from "bignumber.js";
|
|
11
2
|
import IconService from "icon-sdk-js";
|
|
12
3
|
import { isTestnet } from "../logic";
|
|
@@ -37,11 +28,11 @@ export function getDebugRpcUrl(currency) {
|
|
|
37
28
|
/**
|
|
38
29
|
* Broadcast blob to blockchain
|
|
39
30
|
*/
|
|
40
|
-
export const broadcastTransaction = (signedOperation, currency) =>
|
|
41
|
-
const { hash } =
|
|
31
|
+
export const broadcastTransaction = async (signedOperation, currency) => {
|
|
32
|
+
const { hash } = await submit(signedOperation, currency);
|
|
42
33
|
return { hash };
|
|
43
|
-
}
|
|
44
|
-
export const submit = (signedOperation, currency) =>
|
|
34
|
+
};
|
|
35
|
+
export const submit = async (signedOperation, currency) => {
|
|
45
36
|
const rpcURL = getRpcUrl(currency);
|
|
46
37
|
const httpProvider = new HttpProvider(rpcURL);
|
|
47
38
|
const iconService = new IconService(httpProvider);
|
|
@@ -49,36 +40,36 @@ export const submit = (signedOperation, currency) => __awaiter(void 0, void 0, v
|
|
|
49
40
|
getProperties: () => signedOperation.rawData,
|
|
50
41
|
getSignature: () => signedOperation.signature,
|
|
51
42
|
};
|
|
52
|
-
const response =
|
|
43
|
+
const response = await iconService
|
|
53
44
|
.sendTransaction(signedTransaction)
|
|
54
45
|
.execute();
|
|
55
46
|
return {
|
|
56
47
|
hash: response,
|
|
57
48
|
};
|
|
58
|
-
}
|
|
49
|
+
};
|
|
59
50
|
/**
|
|
60
51
|
* Obtain fees from blockchain
|
|
61
52
|
*/
|
|
62
|
-
export const getFees = (unsigned, account) =>
|
|
53
|
+
export const getFees = async (unsigned, account) => {
|
|
63
54
|
const debugRpcUrl = getDebugRpcUrl(account.currency);
|
|
64
55
|
const httpProvider = new HttpProvider(debugRpcUrl);
|
|
65
56
|
const iconService = new IconService(httpProvider);
|
|
66
|
-
const res =
|
|
57
|
+
const res = await iconService.estimateStep(unsigned).execute();
|
|
67
58
|
return new BigNumber(res);
|
|
68
|
-
}
|
|
59
|
+
};
|
|
69
60
|
/**
|
|
70
61
|
* Get step price from governance contract
|
|
71
62
|
*/
|
|
72
|
-
export const getStepPrice = (account) =>
|
|
63
|
+
export const getStepPrice = async (account) => {
|
|
73
64
|
const rpcURL = getRpcUrl(account.currency);
|
|
74
65
|
const httpProvider = new HttpProvider(rpcURL);
|
|
75
66
|
const iconService = new IconService(httpProvider);
|
|
76
67
|
const txBuilder = new IconBuilder.CallBuilder();
|
|
77
68
|
const stepPriceTx = txBuilder.to(GOVERNANCE_SCORE_ADDRESS).method("getStepPrice").build();
|
|
78
|
-
const res =
|
|
69
|
+
const res = await iconService.call(stepPriceTx).execute();
|
|
79
70
|
return new BigNumber(res);
|
|
80
|
-
}
|
|
81
|
-
export const getDelegation = (address, currency) =>
|
|
71
|
+
};
|
|
72
|
+
export const getDelegation = async (address, currency) => {
|
|
82
73
|
const rpcURL = getRpcUrl(currency);
|
|
83
74
|
const httpProvider = new HttpProvider(rpcURL);
|
|
84
75
|
const iconService = new IconService(httpProvider);
|
|
@@ -89,11 +80,11 @@ export const getDelegation = (address, currency) => __awaiter(void 0, void 0, vo
|
|
|
89
80
|
address,
|
|
90
81
|
})
|
|
91
82
|
.build();
|
|
92
|
-
const res =
|
|
83
|
+
const res = await iconService.call(delegationTx).execute();
|
|
93
84
|
return {
|
|
94
85
|
delegations: res.delegations,
|
|
95
86
|
totalDelegated: new BigNumber(res.totalDelegated),
|
|
96
87
|
votingPower: new BigNumber(res.votingPower),
|
|
97
88
|
};
|
|
98
|
-
}
|
|
89
|
+
};
|
|
99
90
|
//# sourceMappingURL=node.js.map
|
package/lib-es/api/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/api/node.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/api/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,WAAW,MAAM,aAAa,CAAC;AAGtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAI5E,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,EAAE,YAAY,EAAE,GAAG,WAAW,CAAC;AACrC,MAAM,EAAE,WAAW,EAAE,GAAG,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAC,QAAwB;IAChD,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;IACvC,IAAI,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,aAAa,CAAC;IAChD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,qBAAqB,CAAC;IACtD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,QAAwB;IACrD,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;IACvC,IAAI,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC;IACjD,IAAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACxB,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,sBAAsB,CAAC;IACvD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,eAAgC,EAChC,QAAwB,EACxB,EAAE;IACF,MAAM,EAAE,IAAI,EAAE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es/bridge/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import getAddressWrapper from "@ledgerhq/coin-framework/bridge/getAddressWrapper";
|
|
11
2
|
import { getSerializedAddressParameters, updateTransaction, makeAccountBridgeReceive, makeScanAccounts, makeSync, } from "@ledgerhq/coin-framework/bridge/jsHelpers";
|
|
12
3
|
import resolver from "../hw-getAddress";
|
|
@@ -27,7 +18,7 @@ export function buildCurrencyBridge(signerContext) {
|
|
|
27
18
|
getAddressFn: getAddress,
|
|
28
19
|
});
|
|
29
20
|
return {
|
|
30
|
-
preload: () =>
|
|
21
|
+
preload: async () => Promise.resolve({}),
|
|
31
22
|
hydrate: () => { },
|
|
32
23
|
scanAccounts,
|
|
33
24
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,mDAAmD,CAAC;AAClF,OAAO,EACL,8BAA8B,EAC9B,iBAAiB,EACjB,wBAAwB,EACxB,gBAAgB,EAChB,QAAQ,GACT,MAAM,2CAA2C,CAAC;AAKnD,OAAO,QAAQ,MAAM,kBAAkB,CAAC;AACx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kBAAkB;QAClB,oBAAoB;QACpB,IAAI;QACJ,OAAO;QACP,kBAAkB;QAClB,oBAAoB;QACpB,WAAW;QACX,aAAa;QACb,SAAS;QACT,oBAAoB;QACpB,8BAA8B;KAC/B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,aAAa,CAC3B,aAAwC,EACxC,UAAsC;IAEtC,aAAa,CAAC,UAAU,CAAC,CAAC;IAE1B,OAAO;QACL,cAAc,EAAE,mBAAmB,CAAC,aAAa,CAAC;QAClD,aAAa,EAAE,kBAAkB,CAAC,aAAa,CAAC;KACjD,CAAC;AACJ,CAAC"}
|
package/lib-es/broadcast.js
CHANGED
|
@@ -1,21 +1,10 @@
|
|
|
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
1
|
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
11
2
|
import { broadcastTransaction } from "./api/node";
|
|
12
3
|
/**
|
|
13
4
|
* Broadcast the signed transaction
|
|
14
5
|
*/
|
|
15
|
-
export function broadcast(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return patchOperationWithHash(signedOperation.operation, hash);
|
|
19
|
-
});
|
|
6
|
+
export async function broadcast({ account, signedOperation, }) {
|
|
7
|
+
const { hash } = await broadcastTransaction(signedOperation, account.currency);
|
|
8
|
+
return patchOperationWithHash(signedOperation.operation, hash);
|
|
20
9
|
}
|
|
21
10
|
//# sourceMappingURL=broadcast.js.map
|
package/lib-es/broadcast.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAElD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,EAC9B,OAAO,EACP,eAAe,GAIhB;IACC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,oBAAoB,CAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/E,OAAO,sBAAsB,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import IconService from "icon-sdk-js";
|
|
11
2
|
import { getNid, getNonce } from "./logic";
|
|
12
3
|
import { RPC_VERSION } from "./constants";
|
|
@@ -32,7 +23,7 @@ const buildTransferTransaction = (account, transaction, stepLimit) => {
|
|
|
32
23
|
* @param {Account} account
|
|
33
24
|
* @param {Transaction} transaction
|
|
34
25
|
*/
|
|
35
|
-
export const buildTransaction = (account, transaction, stepLimit) =>
|
|
26
|
+
export const buildTransaction = async (account, transaction, stepLimit) => {
|
|
36
27
|
let unsigned;
|
|
37
28
|
switch (transaction.mode) {
|
|
38
29
|
case "send":
|
|
@@ -44,5 +35,5 @@ export const buildTransaction = (account, transaction, stepLimit) => __awaiter(v
|
|
|
44
35
|
return {
|
|
45
36
|
unsigned,
|
|
46
37
|
};
|
|
47
|
-
}
|
|
38
|
+
};
|
|
48
39
|
//# sourceMappingURL=buildTransaction.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildTransaction.js","sourceRoot":"","sources":["../src/buildTransaction.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildTransaction.js","sourceRoot":"","sources":["../src/buildTransaction.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,WAAW,CAAC;AAEnD,MAAM,wBAAwB,GAAG,CAC/B,OAAoB,EACpB,WAAwB,EACxB,SAAiC,EACjB,EAAE;IAClB,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IACrC,MAAM,qBAAqB,GAAG,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;IACtE,MAAM,eAAe,GAAG,qBAAqB;SAC1C,IAAI,CAAC,OAAO,CAAC;SACb,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;SACzB,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;SACpD,GAAG,CAAC,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;SACxD,KAAK,CAAC,aAAa,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC;SACnD,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SACjE,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IACnD,IAAI,SAAS,EAAE,CAAC;QACd,eAAe,CAAC,SAAS,CAAC,aAAa,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,eAAe,CAAC,KAAK,EAAE,CAAC;AACjC,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EACnC,OAAoB,EACpB,WAAwB,EACxB,SAAiC,EACjC,EAAE;IACF,IAAI,QAAoC,CAAC;IACzC,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC;QACzB,KAAK,MAAM;YACT,QAAQ,GAAG,wBAAwB,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;YACrE,MAAM;QACR;YACE,MAAM,IAAI,KAAK,CAAC,iCAAiC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO;QACL,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -17,7 +17,11 @@ function inferTransactions(transactions, opts) {
|
|
|
17
17
|
const isDelisted = account.token.delisted === true;
|
|
18
18
|
invariant(!isDelisted, "token is delisted");
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return {
|
|
21
|
+
...transaction,
|
|
22
|
+
family: "icon",
|
|
23
|
+
mode: opts.mode || "send",
|
|
24
|
+
};
|
|
21
25
|
});
|
|
22
26
|
}
|
|
23
27
|
export default function makeCliTools() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-transaction.js","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":"AACA,OA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C,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,SAAS,CAAE,OAAuB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC;YACnD,SAAS,CAAC,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO;YACL,GAAG,WAAW;YACd,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,MAAM;SACX,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { getMainAccount } from "@ledgerhq/coin-framework/account/index";
|
|
11
2
|
import { createTransaction } from "./createTransaction";
|
|
12
3
|
import getEstimatedFees from "./getFeesForTransaction";
|
|
@@ -16,16 +7,16 @@ import { calculateAmount } from "./logic";
|
|
|
16
7
|
*
|
|
17
8
|
* @param {Object} param - the account, parentAccount and transaction
|
|
18
9
|
*/
|
|
19
|
-
export const estimateMaxSpendable =
|
|
10
|
+
export const estimateMaxSpendable = async ({ account, parentAccount, transaction, }) => {
|
|
20
11
|
const acc = getMainAccount(account, parentAccount);
|
|
21
|
-
const tx =
|
|
22
|
-
const fees =
|
|
12
|
+
const tx = { ...createTransaction(), ...transaction, useAllAmount: true };
|
|
13
|
+
const fees = await getEstimatedFees({
|
|
23
14
|
account: acc,
|
|
24
15
|
transaction: tx,
|
|
25
16
|
});
|
|
26
17
|
return calculateAmount({
|
|
27
18
|
account: acc,
|
|
28
|
-
transaction:
|
|
19
|
+
transaction: { ...tx, fees },
|
|
29
20
|
});
|
|
30
|
-
}
|
|
21
|
+
};
|
|
31
22
|
//# sourceMappingURL=estimateMaxSpendable.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../src/estimateMaxSpendable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,gBAAgB,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EAAE,EACzC,OAAO,EACP,aAAa,EACb,WAAW,GAKZ,EAAsB,EAAE;IACvB,MAAM,GAAG,GAAG,cAAc,CAAC,OAAO,EAAE,aAAa,CAAgB,CAAC;IAClE,MAAM,EAAE,GAAG,EAAE,GAAG,iBAAiB,EAAE,EAAE,GAAG,WAAW,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC;IAC1E,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC;QAClC,OAAO,EAAE,GAAG;QACZ,WAAW,EAAE,EAAE;KAChB,CAAC,CAAC;IAEH,OAAO,eAAe,CAAC;QACrB,OAAO,EAAE,GAAG;QACZ,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE;KAC7B,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -1,12 +1,3 @@
|
|
|
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
1
|
import { BigNumber } from "bignumber.js";
|
|
11
2
|
import { getFees } from "./api/node";
|
|
12
3
|
import { buildTransaction } from "./buildTransaction";
|
|
@@ -19,24 +10,30 @@ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets";
|
|
|
19
10
|
* @param {IconAccount} account
|
|
20
11
|
* @param {Transaction} transaction
|
|
21
12
|
*/
|
|
22
|
-
const getEstimatedFees =
|
|
23
|
-
const tx =
|
|
13
|
+
const getEstimatedFees = async ({ account, transaction, }) => {
|
|
14
|
+
const tx = {
|
|
15
|
+
...transaction,
|
|
16
|
+
recipient: getAbandonSeedAddress(account.currency.id),
|
|
24
17
|
// Always use a fake recipient to estimate fees
|
|
25
18
|
amount: calculateAmount({
|
|
26
19
|
account,
|
|
27
|
-
transaction:
|
|
28
|
-
|
|
20
|
+
transaction: {
|
|
21
|
+
...transaction,
|
|
22
|
+
fees: new BigNumber(0),
|
|
23
|
+
},
|
|
24
|
+
}), // Remove fees if present since we are fetching fees
|
|
25
|
+
};
|
|
29
26
|
try {
|
|
30
|
-
const { unsigned } =
|
|
31
|
-
const stepLimit =
|
|
27
|
+
const { unsigned } = await buildTransaction(account, tx);
|
|
28
|
+
const stepLimit = await getFees(unsigned, account);
|
|
32
29
|
transaction.stepLimit = stepLimit;
|
|
33
|
-
const stepPrice =
|
|
30
|
+
const stepPrice = await getStepPrice(account);
|
|
34
31
|
return stepLimit.multipliedBy(stepPrice);
|
|
35
32
|
}
|
|
36
33
|
catch (_error) {
|
|
37
34
|
// Fix ME, the API of Icon throws an error when getting the fee with maximum balance
|
|
38
35
|
return FEES_SAFETY_BUFFER;
|
|
39
36
|
}
|
|
40
|
-
}
|
|
37
|
+
};
|
|
41
38
|
export default getEstimatedFees;
|
|
42
39
|
//# sourceMappingURL=getFeesForTransaction.js.map
|