@ledgerhq/coin-framework 2.3.0 → 2.4.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.unimportedrc.json +5 -10
- package/CHANGELOG.md +15 -0
- package/lib/api/types.d.ts +21 -12
- package/lib/api/types.d.ts.map +1 -1
- package/lib/utils.d.ts +3 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +11 -0
- package/lib/utils.js.map +1 -0
- package/lib/utils.test.d.ts +2 -0
- package/lib/utils.test.d.ts.map +1 -0
- package/lib/utils.test.js +21 -0
- package/lib/utils.test.js.map +1 -0
- package/lib-es/api/types.d.ts +21 -12
- package/lib-es/api/types.d.ts.map +1 -1
- package/lib-es/utils.d.ts +3 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +7 -0
- package/lib-es/utils.js.map +1 -0
- package/lib-es/utils.test.d.ts +2 -0
- package/lib-es/utils.test.d.ts.map +1 -0
- package/lib-es/utils.test.js +16 -0
- package/lib-es/utils.test.js.map +1 -0
- package/package.json +2 -2
- package/src/api/types.ts +33 -12
- package/src/utils.test.ts +17 -0
- package/src/utils.ts +11 -0
package/.unimportedrc.json
CHANGED
|
@@ -18,19 +18,14 @@
|
|
|
18
18
|
"src/index.ts",
|
|
19
19
|
"src/operation.ts",
|
|
20
20
|
"src/signer.ts",
|
|
21
|
-
"src/transaction/common.ts"
|
|
21
|
+
"src/transaction/common.ts",
|
|
22
|
+
"src/utils.ts"
|
|
22
23
|
],
|
|
23
24
|
"ignoreUnimported": [
|
|
24
25
|
"src/config.ts",
|
|
25
26
|
"src/test-helpers/bridge-integration-suite.ts",
|
|
26
27
|
"src/test-helpers/staticTime.ts"
|
|
27
28
|
],
|
|
28
|
-
"ignoreUnresolved": [
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"proxy-from-env"
|
|
32
|
-
],
|
|
33
|
-
"ignoreUnused": [
|
|
34
|
-
"lru-cache"
|
|
35
|
-
]
|
|
36
|
-
}
|
|
29
|
+
"ignoreUnresolved": ["follow-redirects", "form-data", "proxy-from-env"],
|
|
30
|
+
"ignoreUnused": ["lru-cache"]
|
|
31
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @ledgerhq/coin-framework
|
|
2
2
|
|
|
3
|
+
## 2.4.0-next.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9440](https://github.com/LedgerHQ/ledger-live/pull/9440) [`5f27549`](https://github.com/LedgerHQ/ledger-live/commit/5f275498e80060f98238a54e8ae3e2c94bfd7c91) Thanks [@qperrot](https://github.com/qperrot)! - feat estimateFees for alpacha
|
|
8
|
+
|
|
9
|
+
- [#9466](https://github.com/LedgerHQ/ledger-live/pull/9466) [`e2630cb`](https://github.com/LedgerHQ/ledger-live/commit/e2630cbec8d94ae037b2bf85cfa200a277ae739f) Thanks [@qperrot](https://github.com/qperrot)! - Tron craftTransaction alpaca implementation
|
|
10
|
+
|
|
11
|
+
- [#9275](https://github.com/LedgerHQ/ledger-live/pull/9275) [`b8fca38`](https://github.com/LedgerHQ/ledger-live/commit/b8fca386fa07cf393109a1928e92dfc790f9c286) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Update Alpaca api to include generic token type and update list operations
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [[`fa8b10c`](https://github.com/LedgerHQ/ledger-live/commit/fa8b10cac5603eedd7c2309d2bb544a7d2d1a1a8), [`c15d7ea`](https://github.com/LedgerHQ/ledger-live/commit/c15d7ea48e41168726a90a17809175aee5bfa940)]:
|
|
16
|
+
- @ledgerhq/types-live@6.64.0-next.0
|
|
17
|
+
|
|
3
18
|
## 2.3.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/lib/api/types.d.ts
CHANGED
|
@@ -3,18 +3,20 @@ export type BlockInfo = {
|
|
|
3
3
|
hash?: string;
|
|
4
4
|
time?: Date;
|
|
5
5
|
};
|
|
6
|
-
export type Operation = {
|
|
7
|
-
hash: string;
|
|
8
|
-
address: string;
|
|
6
|
+
export type Operation<AssetInfo> = {
|
|
9
7
|
type: string;
|
|
10
|
-
|
|
11
|
-
fee: bigint;
|
|
12
|
-
block: BlockInfo;
|
|
8
|
+
operationIndex: number;
|
|
13
9
|
senders: string[];
|
|
14
10
|
recipients: string[];
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
value: bigint;
|
|
12
|
+
asset?: AssetInfo;
|
|
17
13
|
details?: Record<string, unknown>;
|
|
14
|
+
tx: {
|
|
15
|
+
hash: string;
|
|
16
|
+
block: BlockInfo;
|
|
17
|
+
fees: bigint;
|
|
18
|
+
date: Date;
|
|
19
|
+
};
|
|
18
20
|
};
|
|
19
21
|
export type Transaction = {
|
|
20
22
|
type: string;
|
|
@@ -25,16 +27,23 @@ export type Transaction = {
|
|
|
25
27
|
export type Asset = {
|
|
26
28
|
native: bigint;
|
|
27
29
|
};
|
|
30
|
+
export type TransactionIntent<AssetInfo> = {
|
|
31
|
+
type: string;
|
|
32
|
+
sender: string;
|
|
33
|
+
recipient: string;
|
|
34
|
+
amount: bigint;
|
|
35
|
+
asset?: AssetInfo;
|
|
36
|
+
};
|
|
28
37
|
export type Pagination = {
|
|
29
38
|
minHeight: number;
|
|
30
39
|
};
|
|
31
|
-
export type Api = {
|
|
40
|
+
export type Api<TokenIdentifier> = {
|
|
32
41
|
broadcast: (tx: string) => Promise<string>;
|
|
33
42
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
estimateFees: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<bigint>;
|
|
44
|
+
craftTransaction: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<string>;
|
|
36
45
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
37
46
|
lastBlock: () => Promise<BlockInfo>;
|
|
38
|
-
listOperations: (address: string, pagination: Pagination) => Promise<[Operation[], string]>;
|
|
47
|
+
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
39
48
|
};
|
|
40
49
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/api/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,SAAS,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,EAAE;QAEF,IAAI,EAAE,MAAM,CAAC;QAEb,KAAK,EAAE,SAAS,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QAEb,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,MAA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","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,CAAC,GACf,MAAM,GAAG,CAAC,CAKZ"}
|
package/lib/utils.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fromBigNumberToBigInt = void 0;
|
|
4
|
+
function fromBigNumberToBigInt(bigNumber, defaultValue) {
|
|
5
|
+
if (bigNumber != null) {
|
|
6
|
+
return BigInt(bigNumber.toString());
|
|
7
|
+
}
|
|
8
|
+
return defaultValue;
|
|
9
|
+
}
|
|
10
|
+
exports.fromBigNumberToBigInt = fromBigNumberToBigInt;
|
|
11
|
+
//# sourceMappingURL=utils.js.map
|
package/lib/utils.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,qBAAqB,CACnC,SAAgC,EAChC,YAAgB;IAEhB,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,YAAiB,CAAC;AAC3B,CAAC;AARD,sDAQC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../src/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
const utils_1 = require("./utils");
|
|
8
|
+
describe("bigNumberToBigInt", () => {
|
|
9
|
+
it("should convert BigNumber to BigInt", () => {
|
|
10
|
+
const bigNumber = new bignumber_js_1.default("42");
|
|
11
|
+
const result = (0, utils_1.fromBigNumberToBigInt)(bigNumber);
|
|
12
|
+
expect(result).toEqual(BigInt("42"));
|
|
13
|
+
});
|
|
14
|
+
it("should return the default value if input is undefined", () => {
|
|
15
|
+
const value = undefined;
|
|
16
|
+
const defaultValue = BigInt(12);
|
|
17
|
+
const result = (0, utils_1.fromBigNumberToBigInt)(value, defaultValue);
|
|
18
|
+
expect(result).toEqual(defaultValue);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../src/utils.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AACrC,mCAAgD;AAEhD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,SAAS,GAAG,IAAI,sBAAS,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,IAAA,6BAAqB,EAAC,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,KAAK,GAAG,SAAS,CAAC;QACxB,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,IAAA,6BAAqB,EAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib-es/api/types.d.ts
CHANGED
|
@@ -3,18 +3,20 @@ export type BlockInfo = {
|
|
|
3
3
|
hash?: string;
|
|
4
4
|
time?: Date;
|
|
5
5
|
};
|
|
6
|
-
export type Operation = {
|
|
7
|
-
hash: string;
|
|
8
|
-
address: string;
|
|
6
|
+
export type Operation<AssetInfo> = {
|
|
9
7
|
type: string;
|
|
10
|
-
|
|
11
|
-
fee: bigint;
|
|
12
|
-
block: BlockInfo;
|
|
8
|
+
operationIndex: number;
|
|
13
9
|
senders: string[];
|
|
14
10
|
recipients: string[];
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
value: bigint;
|
|
12
|
+
asset?: AssetInfo;
|
|
17
13
|
details?: Record<string, unknown>;
|
|
14
|
+
tx: {
|
|
15
|
+
hash: string;
|
|
16
|
+
block: BlockInfo;
|
|
17
|
+
fees: bigint;
|
|
18
|
+
date: Date;
|
|
19
|
+
};
|
|
18
20
|
};
|
|
19
21
|
export type Transaction = {
|
|
20
22
|
type: string;
|
|
@@ -25,16 +27,23 @@ export type Transaction = {
|
|
|
25
27
|
export type Asset = {
|
|
26
28
|
native: bigint;
|
|
27
29
|
};
|
|
30
|
+
export type TransactionIntent<AssetInfo> = {
|
|
31
|
+
type: string;
|
|
32
|
+
sender: string;
|
|
33
|
+
recipient: string;
|
|
34
|
+
amount: bigint;
|
|
35
|
+
asset?: AssetInfo;
|
|
36
|
+
};
|
|
28
37
|
export type Pagination = {
|
|
29
38
|
minHeight: number;
|
|
30
39
|
};
|
|
31
|
-
export type Api = {
|
|
40
|
+
export type Api<TokenIdentifier> = {
|
|
32
41
|
broadcast: (tx: string) => Promise<string>;
|
|
33
42
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
estimateFees: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<bigint>;
|
|
44
|
+
craftTransaction: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<string>;
|
|
36
45
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
37
46
|
lastBlock: () => Promise<BlockInfo>;
|
|
38
|
-
listOperations: (address: string, pagination: Pagination) => Promise<[Operation[], string]>;
|
|
47
|
+
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
39
48
|
};
|
|
40
49
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/api/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IAId,IAAI,CAAC,EAAE,IAAI,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,SAAS,CAAC,SAAS,IAAI;IACjC,IAAI,EAAE,MAAM,CAAC;IAEb,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IAEd,KAAK,CAAC,EAAE,SAAS,CAAC;IAElB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,EAAE,EAAE;QAEF,IAAI,EAAE,MAAM,CAAC;QAEb,KAAK,EAAE,SAAS,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;QAEb,IAAI,EAAE,IAAI,CAAC;KACZ,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,E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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,wBAAgB,qBAAqB,CAAC,CAAC,EACrC,SAAS,EAAE,SAAS,GAAG,SAAS,EAChC,YAAY,CAAC,EAAE,CAAC,GACf,MAAM,GAAG,CAAC,CAKZ"}
|
package/lib-es/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB,CACnC,SAAgC,EAChC,YAAgB;IAEhB,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,YAAiB,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../src/utils.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { fromBigNumberToBigInt } from "./utils";
|
|
3
|
+
describe("bigNumberToBigInt", () => {
|
|
4
|
+
it("should convert BigNumber to BigInt", () => {
|
|
5
|
+
const bigNumber = new BigNumber("42");
|
|
6
|
+
const result = fromBigNumberToBigInt(bigNumber);
|
|
7
|
+
expect(result).toEqual(BigInt("42"));
|
|
8
|
+
});
|
|
9
|
+
it("should return the default value if input is undefined", () => {
|
|
10
|
+
const value = undefined;
|
|
11
|
+
const defaultValue = BigInt(12);
|
|
12
|
+
const result = fromBigNumberToBigInt(value, defaultValue);
|
|
13
|
+
expect(result).toEqual(defaultValue);
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=utils.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.test.js","sourceRoot":"","sources":["../src/utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,MAAM,GAAG,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,KAAK,GAAG,SAAS,CAAC;QACxB,MAAM,YAAY,GAAG,MAAM,CAAC,EAAE,CAAC,CAAC;QAChC,MAAM,MAAM,GAAG,qBAAqB,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-framework",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-next.0",
|
|
4
4
|
"description": "Ledger framework for Coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"@ledgerhq/live-network": "^2.0.5",
|
|
99
99
|
"@ledgerhq/logs": "^6.12.0",
|
|
100
100
|
"@ledgerhq/types-cryptoassets": "^7.20.0",
|
|
101
|
-
"@ledgerhq/types-live": "^6.
|
|
101
|
+
"@ledgerhq/types-live": "^6.64.0-next.0"
|
|
102
102
|
},
|
|
103
103
|
"devDependencies": {
|
|
104
104
|
"@types/invariant": "^2.2.2",
|
package/src/api/types.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
export type BlockInfo = {
|
|
2
2
|
height: number;
|
|
3
3
|
hash?: string;
|
|
4
|
+
// can be different from tx date
|
|
5
|
+
// transaction could be created at a particular moment, but depending on network conditions
|
|
6
|
+
// mining time, and block intervals, it might not get included in the blockchain until later
|
|
4
7
|
time?: Date;
|
|
5
8
|
};
|
|
6
9
|
|
|
7
|
-
export type Operation = {
|
|
8
|
-
hash: string;
|
|
9
|
-
address: string;
|
|
10
|
+
export type Operation<AssetInfo> = {
|
|
10
11
|
type: string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
block: BlockInfo;
|
|
12
|
+
// This operation corresponds to the index-th event triggered bu the original transaction
|
|
13
|
+
operationIndex: number;
|
|
14
14
|
senders: string[];
|
|
15
15
|
recipients: string[];
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
value: bigint;
|
|
17
|
+
// Asset is not defined when dealing with native currency
|
|
18
|
+
asset?: AssetInfo;
|
|
18
19
|
// Field containing dedicated value for each blockchain
|
|
19
20
|
details?: Record<string, unknown>;
|
|
21
|
+
tx: {
|
|
22
|
+
// One tx can trigger multiple operations, hence multiple operations with the same hash
|
|
23
|
+
hash: string;
|
|
24
|
+
// In which block this operation's related tx was included
|
|
25
|
+
block: BlockInfo;
|
|
26
|
+
fees: bigint;
|
|
27
|
+
// see BlockInfo.time comment
|
|
28
|
+
date: Date;
|
|
29
|
+
};
|
|
20
30
|
};
|
|
21
31
|
|
|
22
32
|
export type Transaction = {
|
|
@@ -31,6 +41,14 @@ export type Asset = {
|
|
|
31
41
|
native: bigint;
|
|
32
42
|
};
|
|
33
43
|
|
|
44
|
+
export type TransactionIntent<AssetInfo> = {
|
|
45
|
+
type: string;
|
|
46
|
+
sender: string;
|
|
47
|
+
recipient: string;
|
|
48
|
+
amount: bigint;
|
|
49
|
+
asset?: AssetInfo;
|
|
50
|
+
};
|
|
51
|
+
|
|
34
52
|
// TODO rename start to minHeight
|
|
35
53
|
// and add a `token: string` field to the pagination if we really need to support pagination
|
|
36
54
|
// (which is not the case for now)
|
|
@@ -38,12 +56,15 @@ export type Asset = {
|
|
|
38
56
|
// limit is unused for now
|
|
39
57
|
// see design document at https://ledgerhq.atlassian.net/wiki/spaces/BE/pages/5446205788/coin-modules+lama-adapter+APIs+refinements
|
|
40
58
|
export type Pagination = { minHeight: number };
|
|
41
|
-
export type Api = {
|
|
59
|
+
export type Api<TokenIdentifier> = {
|
|
42
60
|
broadcast: (tx: string) => Promise<string>;
|
|
43
61
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
44
|
-
|
|
45
|
-
|
|
62
|
+
estimateFees: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<bigint>;
|
|
63
|
+
craftTransaction: (transactionIntent: TransactionIntent<TokenIdentifier>) => Promise<string>;
|
|
46
64
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
47
65
|
lastBlock: () => Promise<BlockInfo>;
|
|
48
|
-
listOperations: (
|
|
66
|
+
listOperations: (
|
|
67
|
+
address: string,
|
|
68
|
+
pagination: Pagination,
|
|
69
|
+
) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
49
70
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { fromBigNumberToBigInt } from "./utils";
|
|
3
|
+
|
|
4
|
+
describe("bigNumberToBigInt", () => {
|
|
5
|
+
it("should convert BigNumber to BigInt", () => {
|
|
6
|
+
const bigNumber = new BigNumber("42");
|
|
7
|
+
const result = fromBigNumberToBigInt(bigNumber);
|
|
8
|
+
expect(result).toEqual(BigInt("42"));
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it("should return the default value if input is undefined", () => {
|
|
12
|
+
const value = undefined;
|
|
13
|
+
const defaultValue = BigInt(12);
|
|
14
|
+
const result = fromBigNumberToBigInt(value, defaultValue);
|
|
15
|
+
expect(result).toEqual(defaultValue);
|
|
16
|
+
});
|
|
17
|
+
});
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
|
|
3
|
+
export function fromBigNumberToBigInt<T>(
|
|
4
|
+
bigNumber: BigNumber | undefined,
|
|
5
|
+
defaultValue?: T,
|
|
6
|
+
): bigint | T {
|
|
7
|
+
if (bigNumber != null) {
|
|
8
|
+
return BigInt(bigNumber.toString());
|
|
9
|
+
}
|
|
10
|
+
return defaultValue as T;
|
|
11
|
+
}
|