@ledgerhq/coin-tezos 4.0.0 → 4.0.1-nightly.1
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 +1 -1
- package/CHANGELOG.md +18 -0
- package/lib/api/index.d.ts +2 -3
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integ.test.js +8 -5
- package/lib/api/index.integ.test.js.map +1 -1
- package/lib/api/index.js +32 -11
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +18 -6
- package/lib/api/index.test.js.map +1 -1
- package/lib/api/types.d.ts +14 -0
- package/lib/api/types.d.ts.map +1 -0
- package/lib/{types/assets.js → api/types.js} +1 -1
- package/lib/api/types.js.map +1 -0
- package/lib/logic/craftTransaction.d.ts +1 -2
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -3
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js +1 -6
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBalance.test.js +2 -6
- package/lib/logic/getBalance.test.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -1
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +0 -1
- package/lib/types/index.js.map +1 -1
- package/lib-es/api/index.d.ts +2 -3
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integ.test.js +8 -5
- package/lib-es/api/index.integ.test.js.map +1 -1
- package/lib-es/api/index.js +32 -11
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +18 -6
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/api/types.d.ts +14 -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/logic/craftTransaction.d.ts +1 -2
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -3
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js +1 -6
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBalance.test.js +2 -6
- package/lib-es/logic/getBalance.test.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -1
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/types/index.d.ts +0 -1
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +0 -1
- package/lib-es/types/index.js.map +1 -1
- package/package.json +7 -7
- package/src/api/index.integ.test.ts +10 -8
- package/src/api/index.test.ts +30 -13
- package/src/api/index.ts +47 -19
- package/src/api/types.ts +15 -0
- package/src/logic/craftTransaction.ts +1 -1
- package/src/logic/getBalance.test.ts +2 -6
- package/src/logic/getBalance.ts +2 -9
- package/src/logic/listOperations.ts +1 -1
- package/src/types/index.ts +0 -1
- package/lib/types/assets.d.ts +0 -3
- package/lib/types/assets.d.ts.map +0 -1
- package/lib/types/assets.js.map +0 -1
- package/lib-es/types/assets.d.ts +0 -3
- package/lib-es/types/assets.d.ts.map +0 -1
- package/lib-es/types/assets.js +0 -2
- package/lib-es/types/assets.js.map +0 -1
- package/src/types/assets.ts +0 -3
package/lib-es/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,GAGnB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,UAAgC,MAAM,WAAW,CAAC;AACzD,OAAO,EACL,SAAS,EACT,OAAO,EACP,gBAAgB,EAChB,YAAY,EACZ,UAAU,EAC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,WAAW,EAAE,EAAE;KAChB,CAAC;IAEF,IAAI,KAAK,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;IACrD,OAAO,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAChC,KAAK,GAAG,MAAM,aAAa,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,OAAe,EACf,EAAE,SAAS,EAAc;IAEzB,OAAO,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAClD,CAAC"}
|
package/lib-es/api/index.test.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import networkApi from "../network/tzkt";
|
|
2
2
|
import { createApi } from "./index";
|
|
3
3
|
const DEFAULT_ESTIMATED_FEES = 300n;
|
|
4
|
+
const DEFAUTL_GAS_LIMIT = 30n;
|
|
5
|
+
const DEFAUTL_STORAGE_LIMIT = 40n;
|
|
4
6
|
const logicGetTransactions = jest.fn();
|
|
5
7
|
const logicEstimateFees = jest.fn();
|
|
6
8
|
const logicCraftTransactionMock = jest.fn((_account, _transaction) => {
|
|
@@ -74,13 +76,13 @@ describe("Testing craftTransaction function", () => {
|
|
|
74
76
|
beforeEach(() => jest.clearAllMocks());
|
|
75
77
|
it("should use estimated fees when user does not provide them for crafting a transaction ", async () => {
|
|
76
78
|
logicEstimateFees.mockResolvedValue({ estimatedFees: DEFAULT_ESTIMATED_FEES });
|
|
77
|
-
await api.craftTransaction({ type: "send" });
|
|
79
|
+
await api.craftTransaction({ type: "send", sender: {} });
|
|
78
80
|
expect(logicEstimateFees).toHaveBeenCalledTimes(1);
|
|
79
81
|
expect(logicCraftTransactionMock).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({ fee: { fees: DEFAULT_ESTIMATED_FEES.toString() } }));
|
|
80
82
|
});
|
|
81
83
|
it.each([[1n], [50n], [99n]])("should use custom user fees when user provides it for crafting a transaction", async (customFees) => {
|
|
82
84
|
logicEstimateFees.mockResolvedValue({ estimatedFees: DEFAULT_ESTIMATED_FEES });
|
|
83
|
-
await api.craftTransaction({ type: "send" }, customFees);
|
|
85
|
+
await api.craftTransaction({ type: "send", sender: {} }, customFees);
|
|
84
86
|
expect(logicEstimateFees).toHaveBeenCalledTimes(0);
|
|
85
87
|
expect(logicCraftTransactionMock).toHaveBeenCalledWith(expect.any(Object), expect.objectContaining({ fee: { fees: customFees.toString() } }));
|
|
86
88
|
});
|
|
@@ -88,13 +90,23 @@ describe("Testing craftTransaction function", () => {
|
|
|
88
90
|
describe("Testing estimateFees function", () => {
|
|
89
91
|
beforeEach(() => jest.clearAllMocks());
|
|
90
92
|
it("should return estimation from logic module", async () => {
|
|
91
|
-
logicEstimateFees.mockResolvedValue({
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
logicEstimateFees.mockResolvedValue({
|
|
94
|
+
estimatedFees: DEFAULT_ESTIMATED_FEES,
|
|
95
|
+
gasLimit: DEFAUTL_GAS_LIMIT,
|
|
96
|
+
storageLimit: DEFAUTL_STORAGE_LIMIT,
|
|
97
|
+
});
|
|
98
|
+
const result = await api.estimateFees({ type: "send", sender: {} });
|
|
99
|
+
expect(result).toEqual({
|
|
100
|
+
value: DEFAULT_ESTIMATED_FEES,
|
|
101
|
+
parameters: {
|
|
102
|
+
gasLimit: DEFAUTL_GAS_LIMIT,
|
|
103
|
+
storageLimit: DEFAUTL_STORAGE_LIMIT,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
94
106
|
});
|
|
95
107
|
it("should throw taquito errors", async () => {
|
|
96
108
|
logicEstimateFees.mockResolvedValue({ taquitoError: "test" });
|
|
97
|
-
await expect(api.estimateFees({ type: "send" })).rejects.toThrow("Fees estimation failed: test");
|
|
109
|
+
await expect(api.estimateFees({ type: "send", sender: {} })).rejects.toThrow("Fees estimation failed: test");
|
|
98
110
|
});
|
|
99
111
|
});
|
|
100
112
|
//# sourceMappingURL=index.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,MAAM,sBAAsB,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":"AAEA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAGpC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AACpC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAElC,MAAM,oBAAoB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACvC,MAAM,iBAAiB,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;AACpC,MAAM,yBAAyB,GAAG,IAAI,CAAC,EAAE,CACvC,CAAC,QAAiB,EAAE,YAAuC,EAAE,EAAE;IAC7D,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAClD,CAAC,CACF,CAAC;AAEF,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;IAC3B,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,oBAAoB,EAAE;IAClD,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,iBAAiB,EAAE;IAC7C,gBAAgB,EAAE,CAAC,OAAgB,EAAE,WAAsC,EAAE,EAAE,CAC7E,yBAAyB,CAAC,OAAO,EAAE,WAAW,CAAC;IACjD,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,sCAAsC,C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AAI,EAAE;QAC1D,iBAAiB,CAAC,iBAAiB,CAAC;YAClC,aAAa,EAAE,sBAAsB;YACrC,QAAQ,EAAE,iBAAiB;YAC3B,YAAY,EAAE,qBAAqB;SACpC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAA4B,CAAC,CAAC;QAC9F,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC;YACrB,KAAK,EAAE,sBAAsB;YAC7B,UAAU,EAAE;gBACV,QAAQ,EAAE,iBAAiB;gBAC3B,YAAY,EAAE,qBAAqB;aACpC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,KAAK,IAAI,EAAE;QAC3C,iBAAiB,CAAC,iBAAiB,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;QAC9D,MAAM,MAAM,CACV,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAA4B,CAAC,CACzE,CAAC,OAAO,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Api, Asset, FeeEstimation, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
export type TezosAsset = Asset;
|
|
3
|
+
export type TezosFeeParameters = {
|
|
4
|
+
gasLimit: bigint;
|
|
5
|
+
storageLimit: bigint;
|
|
6
|
+
};
|
|
7
|
+
export type TezosFeeEstimation = FeeEstimation<TezosFeeParameters>;
|
|
8
|
+
export type TezosSender = {
|
|
9
|
+
address: string;
|
|
10
|
+
xpub?: string;
|
|
11
|
+
};
|
|
12
|
+
export type TezosTransactionIntent = TransactionIntent<TezosAsset, Record<string, unknown>, TezosSender>;
|
|
13
|
+
export type TezosApi = Api<TezosAsset, Record<string, unknown>, TezosSender, TezosFeeParameters>;
|
|
14
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAElG,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC;AAE/B,MAAM,MAAM,kBAAkB,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAC;AAC5E,MAAM,MAAM,kBAAkB,GAAG,aAAa,CAAC,kBAAkB,CAAC,CAAC;AAEnE,MAAM,MAAM,WAAW,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7D,MAAM,MAAM,sBAAsB,GAAG,iBAAiB,CACpD,UAAU,EACV,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvB,WAAW,CACZ,CAAC;AAEF,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,kBAAkB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type OperationContents } from "@taquito/rpc";
|
|
2
|
-
type TransactionFee = {
|
|
2
|
+
export type TransactionFee = {
|
|
3
3
|
fees?: string;
|
|
4
4
|
gasLimit?: string;
|
|
5
5
|
storageLimit?: string;
|
|
@@ -24,5 +24,4 @@ export declare function craftTransaction(account: {
|
|
|
24
24
|
* Return transaction in raw encoded format (i.e. hexa)
|
|
25
25
|
*/
|
|
26
26
|
export declare function rawEncode(contents: OperationContents[]): Promise<string>;
|
|
27
|
-
export {};
|
|
28
27
|
//# sourceMappingURL=craftTransaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"craftTransaction.d.ts","sourceRoot":"","sources":["../../src/logic/craftTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAM9D,
|
|
1
|
+
{"version":3,"file":"craftTransaction.d.ts","sourceRoot":"","sources":["../../src/logic/craftTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAM9D,MAAM,MAAM,cAAc,GAAG;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,UAAU,GAAG,YAAY,CAAC;AAEhE,wBAAsB,gBAAgB,CACpC,OAAO,EAAE;IACP,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,EACD,WAAW,EAAE;IACX,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,CAAC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,cAAc,CAAC;CACrB,EACD,SAAS,CAAC,EAAE;IACV,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,QAAQ,EAAE,iBAAiB,EAAE,CAAA;CAAE,CAAC,CA2EnE;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAU9E"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
import { TezosAsset } from "../types";
|
|
3
1
|
/**
|
|
4
2
|
* Retunrs the balance of the given address.
|
|
5
3
|
* If the address is an empty account, returns -1.
|
|
6
4
|
*/
|
|
7
|
-
export declare function getBalance(address: string): Promise<
|
|
5
|
+
export declare function getBalance(address: string): Promise<bigint>;
|
|
8
6
|
//# sourceMappingURL=getBalance.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAGjE"}
|
|
@@ -5,11 +5,6 @@ import api from "../network/tzkt";
|
|
|
5
5
|
*/
|
|
6
6
|
export async function getBalance(address) {
|
|
7
7
|
const apiAccount = await api.getAccountByAddress(address);
|
|
8
|
-
return
|
|
9
|
-
{
|
|
10
|
-
value: apiAccount.type === "user" ? BigInt(apiAccount.balance) : BigInt(-1),
|
|
11
|
-
asset: { type: "native" },
|
|
12
|
-
},
|
|
13
|
-
];
|
|
8
|
+
return apiAccount.type === "user" ? BigInt(apiAccount.balance) : BigInt(-1);
|
|
14
9
|
}
|
|
15
10
|
//# sourceMappingURL=getBalance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getBalance.js","sourceRoot":"","sources":["../../src/logic/getBalance.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAe;IAC9C,MAAM,UAAU,GAAG,MAAM,GAAG,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC1D,OAAO,UAAU,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
|
@@ -11,12 +11,8 @@ describe("getBalance", () => {
|
|
|
11
11
|
it("gets the balance of a Tezos account", async () => {
|
|
12
12
|
mockServer.listen({ onUnhandledRequest: "error" });
|
|
13
13
|
mockServer.use(http.get("http://tezos.explorer.com/v1/accounts/tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq", () => HttpResponse.json({ type: "empty" })), http.get("http://tezos.explorer.com/v1/accounts/tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8", () => HttpResponse.json({ type: "user", balance: 25 })));
|
|
14
|
-
expect(await getBalance("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq")).toEqual(
|
|
15
|
-
|
|
16
|
-
]);
|
|
17
|
-
expect(await getBalance("tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8")).toEqual([
|
|
18
|
-
{ value: BigInt(25), asset: { type: "native" } },
|
|
19
|
-
]);
|
|
14
|
+
expect(await getBalance("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq")).toEqual(BigInt(-1));
|
|
15
|
+
expect(await getBalance("tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8")).toEqual(BigInt(25));
|
|
20
16
|
});
|
|
21
17
|
});
|
|
22
18
|
//# sourceMappingURL=getBalance.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBalance.test.js","sourceRoot":"","sources":["../../src/logic/getBalance.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,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AAG,EAAE;IAC1B,MAAM,UAAU,GAAG,WAAW,EAAE,CAAC;IACjC,UAAU,CAAC,aAAa,CACtB,GAAG,EAAE,CACH,CAAC;QACC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC1B,QAAQ,EAAE,EAAE,GAAG,EAAE,2BAA2B,EAAE;KAC/C,CAA+B,CACnC,CAAC;IACF,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,UAAU,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,CAAC;QACnD,UAAU,CAAC,GAAG,CACZ,IAAI,CAAC,GAAG,CAAC,4EAA4E,EAAE,GAAG,EAAE,CAC1F,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CACrC,EACD,IAAI,CAAC,GAAG,CAAC,4EAA4E,EAAE,GAAG,EAAE,CAC1F,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CACjD,CACF,CAAC;QAEF,MAAM,CAAC,MAAM,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACrF,MAAM,CAAC,MAAM,UAAU,CAAC,sCAAsC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IACvF,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
-
import { TezosAsset } from "../types";
|
|
2
|
+
import { TezosAsset } from "../api/types";
|
|
3
3
|
/**
|
|
4
4
|
* Returns list of "Transfer", "Delegate" and "Undelegate" Operations associated to an account.
|
|
5
5
|
* @param address Account address
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"listOperations.d.ts","sourceRoot":"","sources":["../../src/logic/listOperations.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;;;;;;;;GAWG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,MAAM,EACf,EACE,KAAK,EACL,KAAK,EACL,IAAI,EACJ,SAAS,GACV,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,WAAW,GAAG,YAAY,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GACzF,OAAO,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAkB5C"}
|
package/lib-es/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/lib-es/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-tezos",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-nightly.1",
|
|
4
4
|
"description": "Tezos Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -77,14 +77,14 @@
|
|
|
77
77
|
"invariant": "^2.2.4",
|
|
78
78
|
"lodash": "^4.17.21",
|
|
79
79
|
"rxjs": "^7.8.1",
|
|
80
|
-
"@ledgerhq/coin-framework": "^4.0.
|
|
81
|
-
"@ledgerhq/cryptoassets": "^13.
|
|
82
|
-
"@ledgerhq/devices": "8.4.
|
|
83
|
-
"@ledgerhq/errors": "^6.
|
|
80
|
+
"@ledgerhq/coin-framework": "^4.1.0-nightly.1",
|
|
81
|
+
"@ledgerhq/cryptoassets": "^13.16.0-nightly.0",
|
|
82
|
+
"@ledgerhq/devices": "8.4.5-nightly.0",
|
|
83
|
+
"@ledgerhq/errors": "^6.20.0-nightly.0",
|
|
84
84
|
"@ledgerhq/live-network": "^2.0.7",
|
|
85
85
|
"@ledgerhq/logs": "^6.12.0",
|
|
86
|
-
"@ledgerhq/types-cryptoassets": "^7.
|
|
87
|
-
"@ledgerhq/types-live": "^6.
|
|
86
|
+
"@ledgerhq/types-cryptoassets": "^7.23.0-nightly.0",
|
|
87
|
+
"@ledgerhq/types-live": "^6.69.0-nightly.1"
|
|
88
88
|
},
|
|
89
89
|
"devDependencies": {
|
|
90
90
|
"@faker-js/faker": "^8.4.1",
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import { type Api } from "@ledgerhq/coin-framework/api/index";
|
|
2
1
|
import { localForger } from "@taquito/local-forging";
|
|
3
2
|
import { createApi } from ".";
|
|
4
|
-
import {
|
|
3
|
+
import type { TezosApi } from "./types";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* https://teztnets.com/ghostnet-about
|
|
8
7
|
* https://api.tzkt.io/#section/Get-Started/Free-TzKT-API
|
|
9
8
|
*/
|
|
10
9
|
describe("Tezos Api", () => {
|
|
11
|
-
let module:
|
|
10
|
+
let module: TezosApi;
|
|
12
11
|
const address = "tz1heMGVHQnx7ALDcDKqez8fan64Eyicw4DJ";
|
|
13
12
|
|
|
14
13
|
beforeAll(() => {
|
|
@@ -42,13 +41,16 @@ describe("Tezos Api", () => {
|
|
|
42
41
|
const result = await module.estimateFees({
|
|
43
42
|
asset: { type: "native" },
|
|
44
43
|
type: "send",
|
|
45
|
-
sender: address,
|
|
44
|
+
sender: { address },
|
|
46
45
|
recipient: "tz1heMGVHQnx7ALDcDKqez8fan64Eyicw4DJ",
|
|
47
46
|
amount,
|
|
48
47
|
});
|
|
49
48
|
|
|
50
49
|
// Then
|
|
51
|
-
expect(result).toBeGreaterThanOrEqual(BigInt(0));
|
|
50
|
+
expect(result.value).toBeGreaterThanOrEqual(BigInt(0));
|
|
51
|
+
expect(result.parameters).toBeDefined();
|
|
52
|
+
expect(result.parameters?.gasLimit).toBeGreaterThanOrEqual(BigInt(0));
|
|
53
|
+
expect(result.parameters?.storageLimit).toBeGreaterThanOrEqual(BigInt(0));
|
|
52
54
|
});
|
|
53
55
|
});
|
|
54
56
|
|
|
@@ -113,7 +115,7 @@ describe("Tezos Api", () => {
|
|
|
113
115
|
const encodedTransaction = await module.craftTransaction({
|
|
114
116
|
asset: { type: "native" },
|
|
115
117
|
type,
|
|
116
|
-
sender: address,
|
|
118
|
+
sender: { address },
|
|
117
119
|
recipient: recipient,
|
|
118
120
|
amount: amount,
|
|
119
121
|
});
|
|
@@ -137,7 +139,7 @@ describe("Tezos Api", () => {
|
|
|
137
139
|
const encodedTransaction = await module.craftTransaction({
|
|
138
140
|
asset: { type: "native" },
|
|
139
141
|
type: "send",
|
|
140
|
-
sender: address,
|
|
142
|
+
sender: { address },
|
|
141
143
|
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
|
|
142
144
|
amount: BigInt(10),
|
|
143
145
|
});
|
|
@@ -154,7 +156,7 @@ describe("Tezos Api", () => {
|
|
|
154
156
|
{
|
|
155
157
|
asset: { type: "native" },
|
|
156
158
|
type: "send",
|
|
157
|
-
sender: address,
|
|
159
|
+
sender: { address },
|
|
158
160
|
recipient: "tz1aWXP237BLwNHJcCD4b3DutCevhqq2T1Z9",
|
|
159
161
|
amount: BigInt(10),
|
|
160
162
|
},
|
package/src/api/index.test.ts
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
import { Operation
|
|
2
|
-
import { APIAccount } from "../network/types";
|
|
1
|
+
import type { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
import type { APIAccount } from "../network/types";
|
|
3
3
|
import networkApi from "../network/tzkt";
|
|
4
4
|
import { createApi } from "./index";
|
|
5
|
-
import { TezosAsset } from "
|
|
5
|
+
import type { TezosAsset, TezosTransactionIntent } from "./types";
|
|
6
6
|
|
|
7
7
|
const DEFAULT_ESTIMATED_FEES = 300n;
|
|
8
|
+
const DEFAUTL_GAS_LIMIT = 30n;
|
|
9
|
+
const DEFAUTL_STORAGE_LIMIT = 40n;
|
|
8
10
|
|
|
9
11
|
const logicGetTransactions = jest.fn();
|
|
10
12
|
const logicEstimateFees = jest.fn();
|
|
11
|
-
const logicCraftTransactionMock = jest.fn(
|
|
12
|
-
|
|
13
|
-
}
|
|
13
|
+
const logicCraftTransactionMock = jest.fn(
|
|
14
|
+
(_account: unknown, _transaction: { fee: { fees: string } }) => {
|
|
15
|
+
return { type: undefined, contents: undefined };
|
|
16
|
+
},
|
|
17
|
+
);
|
|
14
18
|
|
|
15
19
|
jest.mock("../logic", () => ({
|
|
16
20
|
listOperations: async () => logicGetTransactions(),
|
|
17
21
|
estimateFees: async () => logicEstimateFees(),
|
|
18
|
-
craftTransaction: (account: unknown, transaction: { fee:
|
|
22
|
+
craftTransaction: (account: unknown, transaction: { fee: { fees: string } }) =>
|
|
19
23
|
logicCraftTransactionMock(account, transaction),
|
|
20
24
|
rawEncode: () => Promise.resolve("tz1heMGVHQnx7ALDcDKqez8fan64Eyicw4DJ"),
|
|
21
25
|
}));
|
|
@@ -91,7 +95,7 @@ describe("Testing craftTransaction function", () => {
|
|
|
91
95
|
|
|
92
96
|
it("should use estimated fees when user does not provide them for crafting a transaction ", async () => {
|
|
93
97
|
logicEstimateFees.mockResolvedValue({ estimatedFees: DEFAULT_ESTIMATED_FEES });
|
|
94
|
-
await api.craftTransaction({ type: "send" } as
|
|
98
|
+
await api.craftTransaction({ type: "send", sender: {} } as TezosTransactionIntent);
|
|
95
99
|
expect(logicEstimateFees).toHaveBeenCalledTimes(1);
|
|
96
100
|
expect(logicCraftTransactionMock).toHaveBeenCalledWith(
|
|
97
101
|
expect.any(Object),
|
|
@@ -103,7 +107,10 @@ describe("Testing craftTransaction function", () => {
|
|
|
103
107
|
"should use custom user fees when user provides it for crafting a transaction",
|
|
104
108
|
async (customFees: bigint) => {
|
|
105
109
|
logicEstimateFees.mockResolvedValue({ estimatedFees: DEFAULT_ESTIMATED_FEES });
|
|
106
|
-
await api.craftTransaction(
|
|
110
|
+
await api.craftTransaction(
|
|
111
|
+
{ type: "send", sender: {} } as TezosTransactionIntent,
|
|
112
|
+
customFees,
|
|
113
|
+
);
|
|
107
114
|
expect(logicEstimateFees).toHaveBeenCalledTimes(0);
|
|
108
115
|
expect(logicCraftTransactionMock).toHaveBeenCalledWith(
|
|
109
116
|
expect.any(Object),
|
|
@@ -117,15 +124,25 @@ describe("Testing estimateFees function", () => {
|
|
|
117
124
|
beforeEach(() => jest.clearAllMocks());
|
|
118
125
|
|
|
119
126
|
it("should return estimation from logic module", async () => {
|
|
120
|
-
logicEstimateFees.mockResolvedValue({
|
|
121
|
-
|
|
122
|
-
|
|
127
|
+
logicEstimateFees.mockResolvedValue({
|
|
128
|
+
estimatedFees: DEFAULT_ESTIMATED_FEES,
|
|
129
|
+
gasLimit: DEFAUTL_GAS_LIMIT,
|
|
130
|
+
storageLimit: DEFAUTL_STORAGE_LIMIT,
|
|
131
|
+
});
|
|
132
|
+
const result = await api.estimateFees({ type: "send", sender: {} } as TezosTransactionIntent);
|
|
133
|
+
expect(result).toEqual({
|
|
134
|
+
value: DEFAULT_ESTIMATED_FEES,
|
|
135
|
+
parameters: {
|
|
136
|
+
gasLimit: DEFAUTL_GAS_LIMIT,
|
|
137
|
+
storageLimit: DEFAUTL_STORAGE_LIMIT,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
123
140
|
});
|
|
124
141
|
|
|
125
142
|
it("should throw taquito errors", async () => {
|
|
126
143
|
logicEstimateFees.mockResolvedValue({ taquitoError: "test" });
|
|
127
144
|
await expect(
|
|
128
|
-
api.estimateFees({ type: "send" } as
|
|
145
|
+
api.estimateFees({ type: "send", sender: {} } as TezosTransactionIntent),
|
|
129
146
|
).rejects.toThrow("Fees estimation failed: test");
|
|
130
147
|
});
|
|
131
148
|
});
|
package/src/api/index.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
type Balance,
|
|
2
3
|
IncorrectTypeError,
|
|
3
|
-
Operation,
|
|
4
|
-
Pagination,
|
|
5
|
-
TransactionIntent,
|
|
6
|
-
type Api,
|
|
4
|
+
type Operation,
|
|
5
|
+
type Pagination,
|
|
7
6
|
} from "@ledgerhq/coin-framework/api/index";
|
|
8
7
|
import { log } from "@ledgerhq/logs";
|
|
9
8
|
import coinConfig, { type TezosConfig } from "../config";
|
|
@@ -18,9 +17,10 @@ import {
|
|
|
18
17
|
rawEncode,
|
|
19
18
|
} from "../logic";
|
|
20
19
|
import api from "../network/tzkt";
|
|
21
|
-
import {
|
|
20
|
+
import type { TezosOperationMode } from "../types";
|
|
21
|
+
import type { TezosApi, TezosAsset, TezosFeeEstimation, TezosTransactionIntent } from "./types";
|
|
22
22
|
|
|
23
|
-
export function createApi(config: TezosConfig):
|
|
23
|
+
export function createApi(config: TezosConfig): TezosApi {
|
|
24
24
|
coinConfig.setCoinConfig(() => ({ ...config, status: { type: "active" } }));
|
|
25
25
|
|
|
26
26
|
return {
|
|
@@ -28,7 +28,7 @@ export function createApi(config: TezosConfig): Api<TezosAsset> {
|
|
|
28
28
|
combine,
|
|
29
29
|
craftTransaction: craft,
|
|
30
30
|
estimateFees: estimate,
|
|
31
|
-
getBalance,
|
|
31
|
+
getBalance: balance,
|
|
32
32
|
lastBlock,
|
|
33
33
|
listOperations: operations,
|
|
34
34
|
};
|
|
@@ -38,36 +38,58 @@ function isTezosTransactionType(type: string): type is "send" | "delegate" | "un
|
|
|
38
38
|
return ["send", "delegate", "undelegate"].includes(type);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
async function balance(address: string): Promise<Balance<TezosAsset>[]> {
|
|
42
|
+
const value = await getBalance(address);
|
|
43
|
+
return [
|
|
44
|
+
{
|
|
45
|
+
value,
|
|
46
|
+
asset: { type: "native" },
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
}
|
|
50
|
+
|
|
41
51
|
async function craft(
|
|
42
|
-
transactionIntent:
|
|
52
|
+
transactionIntent: TezosTransactionIntent,
|
|
43
53
|
customFees?: bigint,
|
|
44
54
|
): Promise<string> {
|
|
45
55
|
if (!isTezosTransactionType(transactionIntent.type)) {
|
|
46
56
|
throw new IncorrectTypeError(transactionIntent.type);
|
|
47
57
|
}
|
|
48
|
-
const fee =
|
|
58
|
+
const fee =
|
|
59
|
+
customFees !== undefined
|
|
60
|
+
? { fees: customFees.toString() }
|
|
61
|
+
: await estimate(transactionIntent).then(fees => ({
|
|
62
|
+
fees: fees.value.toString(),
|
|
63
|
+
gasLimit: fees.parameters?.gasLimit?.toString(),
|
|
64
|
+
storageLimit: fees.parameters?.storageLimit?.toString(),
|
|
65
|
+
}));
|
|
49
66
|
const { contents } = await craftTransaction(
|
|
50
|
-
{ address: transactionIntent.sender },
|
|
67
|
+
{ address: transactionIntent.sender.address },
|
|
51
68
|
{
|
|
52
69
|
type: transactionIntent.type,
|
|
53
70
|
recipient: transactionIntent.recipient,
|
|
54
71
|
amount: transactionIntent.amount,
|
|
55
|
-
fee
|
|
72
|
+
fee,
|
|
56
73
|
},
|
|
57
74
|
);
|
|
58
75
|
return rawEncode(contents);
|
|
59
76
|
}
|
|
60
77
|
|
|
61
|
-
async function estimate(transactionIntent:
|
|
62
|
-
const senderAccountInfo = await api.getAccountByAddress(transactionIntent.sender);
|
|
78
|
+
async function estimate(transactionIntent: TezosTransactionIntent): Promise<TezosFeeEstimation> {
|
|
79
|
+
const senderAccountInfo = await api.getAccountByAddress(transactionIntent.sender.address);
|
|
63
80
|
if (senderAccountInfo.type !== "user") throw new Error("unexpected account type");
|
|
64
81
|
|
|
65
|
-
const
|
|
82
|
+
const {
|
|
83
|
+
estimatedFees: value,
|
|
84
|
+
gasLimit,
|
|
85
|
+
storageLimit,
|
|
86
|
+
taquitoError,
|
|
87
|
+
} = await estimateFees({
|
|
66
88
|
account: {
|
|
67
|
-
address: transactionIntent.sender,
|
|
89
|
+
address: transactionIntent.sender.address,
|
|
68
90
|
revealed: senderAccountInfo.revealed,
|
|
69
91
|
balance: BigInt(senderAccountInfo.balance),
|
|
70
|
-
xpub: senderAccountInfo.publicKey,
|
|
92
|
+
xpub: transactionIntent.sender.xpub ?? senderAccountInfo.publicKey,
|
|
71
93
|
},
|
|
72
94
|
transaction: {
|
|
73
95
|
mode: transactionIntent.type as TezosOperationMode,
|
|
@@ -76,11 +98,17 @@ async function estimate(transactionIntent: TransactionIntent<TezosAsset>): Promi
|
|
|
76
98
|
},
|
|
77
99
|
});
|
|
78
100
|
|
|
79
|
-
if (
|
|
80
|
-
throw new Error(`Fees estimation failed: ${
|
|
101
|
+
if (taquitoError !== undefined) {
|
|
102
|
+
throw new Error(`Fees estimation failed: ${taquitoError}`);
|
|
81
103
|
}
|
|
82
104
|
|
|
83
|
-
return
|
|
105
|
+
return {
|
|
106
|
+
value,
|
|
107
|
+
parameters: {
|
|
108
|
+
gasLimit,
|
|
109
|
+
storageLimit,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
84
112
|
}
|
|
85
113
|
|
|
86
114
|
type PaginationState = {
|
package/src/api/types.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Api, Asset, FeeEstimation, TransactionIntent } from "@ledgerhq/coin-framework/api/types";
|
|
2
|
+
|
|
3
|
+
export type TezosAsset = Asset;
|
|
4
|
+
|
|
5
|
+
export type TezosFeeParameters = { gasLimit: bigint; storageLimit: bigint };
|
|
6
|
+
export type TezosFeeEstimation = FeeEstimation<TezosFeeParameters>;
|
|
7
|
+
|
|
8
|
+
export type TezosSender = { address: string; xpub?: string };
|
|
9
|
+
export type TezosTransactionIntent = TransactionIntent<
|
|
10
|
+
TezosAsset,
|
|
11
|
+
Record<string, unknown>,
|
|
12
|
+
TezosSender
|
|
13
|
+
>;
|
|
14
|
+
|
|
15
|
+
export type TezosApi = Api<TezosAsset, Record<string, unknown>, TezosSender, TezosFeeParameters>;
|
|
@@ -4,7 +4,7 @@ import coinConfig from "../config";
|
|
|
4
4
|
import { UnsupportedTransactionMode } from "../types/errors";
|
|
5
5
|
import { getTezosToolkit } from "./tezosToolkit";
|
|
6
6
|
|
|
7
|
-
type TransactionFee = {
|
|
7
|
+
export type TransactionFee = {
|
|
8
8
|
fees?: string;
|
|
9
9
|
gasLimit?: string;
|
|
10
10
|
storageLimit?: string;
|
|
@@ -23,11 +23,7 @@ describe("getBalance", () => {
|
|
|
23
23
|
),
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
expect(await getBalance("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq")).toEqual(
|
|
27
|
-
|
|
28
|
-
]);
|
|
29
|
-
expect(await getBalance("tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8")).toEqual([
|
|
30
|
-
{ value: BigInt(25), asset: { type: "native" } },
|
|
31
|
-
]);
|
|
26
|
+
expect(await getBalance("tz1WvvbEGpBXGeTVbLiR6DYBe1izmgiYuZbq")).toEqual(BigInt(-1));
|
|
27
|
+
expect(await getBalance("tz1TzrmTBSuiVHV2VfMnGRMYvTEPCP42oSM8")).toEqual(BigInt(25));
|
|
32
28
|
});
|
|
33
29
|
});
|
package/src/logic/getBalance.ts
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import { Balance } from "@ledgerhq/coin-framework/api/types";
|
|
2
1
|
import api from "../network/tzkt";
|
|
3
|
-
import { TezosAsset } from "../types";
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
4
|
* Retunrs the balance of the given address.
|
|
7
5
|
* If the address is an empty account, returns -1.
|
|
8
6
|
*/
|
|
9
|
-
export async function getBalance(address: string): Promise<
|
|
7
|
+
export async function getBalance(address: string): Promise<bigint> {
|
|
10
8
|
const apiAccount = await api.getAccountByAddress(address);
|
|
11
|
-
return
|
|
12
|
-
{
|
|
13
|
-
value: apiAccount.type === "user" ? BigInt(apiAccount.balance) : BigInt(-1),
|
|
14
|
-
asset: { type: "native" },
|
|
15
|
-
},
|
|
16
|
-
];
|
|
9
|
+
return apiAccount.type === "user" ? BigInt(apiAccount.balance) : BigInt(-1);
|
|
17
10
|
}
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isAPITransactionType,
|
|
11
11
|
} from "../network/types";
|
|
12
12
|
import { Operation } from "@ledgerhq/coin-framework/api/types";
|
|
13
|
-
import { TezosAsset } from "../types";
|
|
13
|
+
import { TezosAsset } from "../api/types";
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Returns list of "Transfer", "Delegate" and "Undelegate" Operations associated to an account.
|
package/src/types/index.ts
CHANGED
package/lib/types/assets.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assets.d.ts","sourceRoot":"","sources":["../../src/types/assets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oCAAoC,CAAC;AAE3D,MAAM,MAAM,UAAU,GAAG,KAAK,CAAC"}
|