@ledgerhq/coin-framework 2.2.0 → 2.3.0-nightly.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +5 -10
- package/CHANGELOG.md +33 -9
- package/lib/api/types.d.ts +12 -10
- package/lib/api/types.d.ts.map +1 -1
- package/lib/config.d.ts +7 -1
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.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 +12 -10
- package/lib-es/api/types.d.ts.map +1 -1
- package/lib-es/config.d.ts +7 -1
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.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 +23 -10
- package/src/config.ts +8 -1
- package/src/utils.test.ts +17 -0
- package/src/utils.ts +11 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/coin-framework@2.
|
|
2
|
+
> @ledgerhq/coin-framework@2.2.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-framework
|
|
3
3
|
> tsc && tsc -m esnext --moduleResolution bundler --outDir lib-es
|
|
4
4
|
|
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,18 @@
|
|
|
1
1
|
# @ledgerhq/coin-framework
|
|
2
2
|
|
|
3
|
+
## 2.3.0-nightly.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#9344](https://github.com/LedgerHQ/ledger-live/pull/9344) [`cc00249`](https://github.com/LedgerHQ/ledger-live/commit/cc002495f3e107aba283a3aa4abca90954de6d76) Thanks [@Canestin](https://github.com/Canestin)! - add banner to warn users about the migration
|
|
8
|
+
|
|
9
|
+
- [#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
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies [[`fa8b10c`](https://github.com/LedgerHQ/ledger-live/commit/fa8b10cac5603eedd7c2309d2bb544a7d2d1a1a8), [`5abde51`](https://github.com/LedgerHQ/ledger-live/commit/5abde5192d32f493ece2f99aec0e2de0c411f9e5), [`c15d7ea`](https://github.com/LedgerHQ/ledger-live/commit/c15d7ea48e41168726a90a17809175aee5bfa940)]:
|
|
14
|
+
- @ledgerhq/types-live@6.63.0-nightly.0
|
|
15
|
+
|
|
3
16
|
## 2.2.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -8,23 +21,34 @@
|
|
|
8
21
|
|
|
9
22
|
### Patch Changes
|
|
10
23
|
|
|
11
|
-
- Updated dependencies [[`
|
|
12
|
-
- @ledgerhq/types-live@6.
|
|
24
|
+
- Updated dependencies [[`8675df1`](https://github.com/LedgerHQ/ledger-live/commit/8675df12c24067877358f27e1e7c66f739ff0c78), [`0a59343`](https://github.com/LedgerHQ/ledger-live/commit/0a59343b591dab4e886c21cb47f7339231997331), [`ede6db0`](https://github.com/LedgerHQ/ledger-live/commit/ede6db0b94193cc9072aeb87e90f4098f0434af0), [`1461449`](https://github.com/LedgerHQ/ledger-live/commit/146144941c13e60182da8d79592f706d12a6f00e), [`bdfa413`](https://github.com/LedgerHQ/ledger-live/commit/bdfa4139fcbceabfd05a57e69b05e9ccf10efbe1)]:
|
|
25
|
+
- @ledgerhq/types-live@6.62.0
|
|
13
26
|
- @ledgerhq/types-cryptoassets@7.20.0
|
|
14
27
|
- @ledgerhq/cryptoassets@13.13.0
|
|
15
28
|
- @ledgerhq/live-env@2.6.0
|
|
16
29
|
- @ledgerhq/live-network@2.0.5
|
|
17
30
|
|
|
18
|
-
## 2.
|
|
31
|
+
## 2.2.0-next.0
|
|
32
|
+
|
|
33
|
+
### Minor Changes
|
|
34
|
+
|
|
35
|
+
- [#9362](https://github.com/LedgerHQ/ledger-live/pull/9362) [`8675df1`](https://github.com/LedgerHQ/ledger-live/commit/8675df12c24067877358f27e1e7c66f739ff0c78) Thanks [@hedi-edelbloute](https://github.com/hedi-edelbloute)! - Fix Aptos derivation path account metadata
|
|
19
36
|
|
|
20
37
|
### Patch Changes
|
|
21
38
|
|
|
22
|
-
- Updated dependencies [[`0a59343`](https://github.com/LedgerHQ/ledger-live/commit/0a59343b591dab4e886c21cb47f7339231997331), [`ede6db0`](https://github.com/LedgerHQ/ledger-live/commit/ede6db0b94193cc9072aeb87e90f4098f0434af0), [`1461449`](https://github.com/LedgerHQ/ledger-live/commit/146144941c13e60182da8d79592f706d12a6f00e), [`bdfa413`](https://github.com/LedgerHQ/ledger-live/commit/bdfa4139fcbceabfd05a57e69b05e9ccf10efbe1)]:
|
|
23
|
-
- @ledgerhq/types-
|
|
24
|
-
- @ledgerhq/cryptoassets@
|
|
25
|
-
- @ledgerhq/
|
|
26
|
-
- @ledgerhq/live-env@2.6.0-next.
|
|
27
|
-
- @ledgerhq/live-network@2.0.5-next.
|
|
39
|
+
- Updated dependencies [[`8675df1`](https://github.com/LedgerHQ/ledger-live/commit/8675df12c24067877358f27e1e7c66f739ff0c78), [`0a59343`](https://github.com/LedgerHQ/ledger-live/commit/0a59343b591dab4e886c21cb47f7339231997331), [`ede6db0`](https://github.com/LedgerHQ/ledger-live/commit/ede6db0b94193cc9072aeb87e90f4098f0434af0), [`1461449`](https://github.com/LedgerHQ/ledger-live/commit/146144941c13e60182da8d79592f706d12a6f00e), [`bdfa413`](https://github.com/LedgerHQ/ledger-live/commit/bdfa4139fcbceabfd05a57e69b05e9ccf10efbe1)]:
|
|
40
|
+
- @ledgerhq/types-live@6.62.0-next.0
|
|
41
|
+
- @ledgerhq/types-cryptoassets@7.20.0-next.0
|
|
42
|
+
- @ledgerhq/cryptoassets@13.13.0-next.0
|
|
43
|
+
- @ledgerhq/live-env@2.6.0-next.0
|
|
44
|
+
- @ledgerhq/live-network@2.0.5-next.0
|
|
45
|
+
|
|
46
|
+
## 2.1.1
|
|
47
|
+
|
|
48
|
+
### Patch Changes
|
|
49
|
+
|
|
50
|
+
- Updated dependencies [[`e4d9a5c`](https://github.com/LedgerHQ/ledger-live/commit/e4d9a5ce6c3e8f2b3829f8f5772e7ba712a4a50c)]:
|
|
51
|
+
- @ledgerhq/types-live@6.61.0
|
|
28
52
|
|
|
29
53
|
## 2.1.1-next.0
|
|
30
54
|
|
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;
|
|
@@ -28,13 +30,13 @@ export type Asset = {
|
|
|
28
30
|
export type Pagination = {
|
|
29
31
|
minHeight: number;
|
|
30
32
|
};
|
|
31
|
-
export type Api = {
|
|
33
|
+
export type Api<TokenIdentifier> = {
|
|
32
34
|
broadcast: (tx: string) => Promise<string>;
|
|
33
35
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
34
36
|
craftTransaction: (address: string, transaction: Transaction, pubkey?: string) => Promise<string>;
|
|
35
37
|
estimateFees: (addr: string, amount: bigint) => Promise<bigint>;
|
|
36
38
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
37
39
|
lastBlock: () => Promise<BlockInfo>;
|
|
38
|
-
listOperations: (address: string, pagination: Pagination) => Promise<[Operation[], string]>;
|
|
40
|
+
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
39
41
|
};
|
|
40
42
|
//# 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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAG5B,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAQF,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,GAAG,CAAC,eAAe,IAAI;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpE,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClG,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IACzD,SAAS,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD,CAAC"}
|
package/lib/config.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
1
|
+
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
type ConfigStatus = {
|
|
3
3
|
type: "active";
|
|
4
4
|
} | {
|
|
5
5
|
type: "under_maintenance";
|
|
6
6
|
message?: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "migration";
|
|
9
|
+
chain: CryptoCurrencyId;
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
link: string;
|
|
7
13
|
} | {
|
|
8
14
|
type: "feature_unavailable";
|
|
9
15
|
link: string;
|
package/lib/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhF,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAC;CAChC,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAC;AAEpF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,WAAW,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAC"}
|
package/lib/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AACA,qCAA6C;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AACA,qCAA6C;AA+C7C,SAAS,eAAe;IACtB,IAAI,UAAqC,CAAC;IAE1C,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACpD,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAK,EAAE;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,0BAAiB,EAAE,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC;AAED,kBAAe,eAAe,CAAC"}
|
package/lib/utils.d.ts
ADDED
|
@@ -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/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;
|
|
@@ -28,13 +30,13 @@ export type Asset = {
|
|
|
28
30
|
export type Pagination = {
|
|
29
31
|
minHeight: number;
|
|
30
32
|
};
|
|
31
|
-
export type Api = {
|
|
33
|
+
export type Api<TokenIdentifier> = {
|
|
32
34
|
broadcast: (tx: string) => Promise<string>;
|
|
33
35
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
34
36
|
craftTransaction: (address: string, transaction: Transaction, pubkey?: string) => Promise<string>;
|
|
35
37
|
estimateFees: (addr: string, amount: bigint) => Promise<bigint>;
|
|
36
38
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
37
39
|
lastBlock: () => Promise<BlockInfo>;
|
|
38
|
-
listOperations: (address: string, pagination: Pagination) => Promise<[Operation[], string]>;
|
|
40
|
+
listOperations: (address: string, pagination: Pagination) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
39
41
|
};
|
|
40
42
|
//# 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,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;CACb,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAG5B,MAAM,MAAM,KAAK,GAAG;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAQF,MAAM,MAAM,UAAU,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,GAAG,CAAC,eAAe,IAAI;IACjC,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC3C,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IACpE,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAClG,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAChE,UAAU,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;IACzD,SAAS,EAAE,MAAM,OAAO,CAAC,SAAS,CAAC,CAAC;IACpC,cAAc,EAAE,CACd,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,UAAU,KACnB,OAAO,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;CACtD,CAAC"}
|
package/lib-es/config.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
1
|
+
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
type ConfigStatus = {
|
|
3
3
|
type: "active";
|
|
4
4
|
} | {
|
|
5
5
|
type: "under_maintenance";
|
|
6
6
|
message?: string;
|
|
7
|
+
} | {
|
|
8
|
+
type: "migration";
|
|
9
|
+
chain: CryptoCurrencyId;
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
link: string;
|
|
7
13
|
} | {
|
|
8
14
|
type: "feature_unavailable";
|
|
9
15
|
link: string;
|
package/lib-es/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAGhF,KAAK,YAAY,GACb;IACE,IAAI,EAAE,QAAQ,CAAC;CAChB,GACD;IACE,IAAI,EAAE,mBAAmB,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,GACD;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,KAAK,EAAE,gBAAgB,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,GACD;IACE,IAAI,EAAE,qBAAqB,CAAC;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EACH,SAAS,GACT,MAAM,GACN,eAAe,GACf,kBAAkB,GAClB,MAAM,GACN,SAAS,GACT,gBAAgB,GAChB,kBAAkB,GAClB,SAAS,GACT,0BAA0B,CAAC;CAChC,GACD;IACE,IAAI,EAAE,oBAAoB,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;CACzB,GACD;IACE,IAAI,EAAE,YAAY,CAAC;CACpB,CAAC;AAEN,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,YAAY,CAAC;IACrB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,QAAQ,CAAC,EAAE,cAAc,KAAK,CAAC,CAAC;AAEpF,iBAAS,eAAe,CAAC,CAAC,SAAS,cAAc;4BAGhB,WAAW,CAAC,CAAC,KAAG,IAAI;+BAIjB,cAAc,KAAG,CAAC;EAYrD;AAED,eAAe,eAAe,CAAC"}
|
package/lib-es/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AA+C7C,SAAS,eAAe;IACtB,IAAI,UAAqC,CAAC;IAE1C,MAAM,aAAa,GAAG,CAAC,MAAqB,EAAQ,EAAE;QACpD,UAAU,GAAG,MAAM,CAAC;IACtB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,QAAyB,EAAK,EAAE;QACrD,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,iBAAiB,EAAE,CAAC;QAChC,CAAC;QAED,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ,CAAC;AAED,eAAe,eAAe,CAAC"}
|
|
@@ -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.3.0-nightly.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.63.0-nightly.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 = {
|
|
@@ -38,12 +48,15 @@ export type Asset = {
|
|
|
38
48
|
// limit is unused for now
|
|
39
49
|
// see design document at https://ledgerhq.atlassian.net/wiki/spaces/BE/pages/5446205788/coin-modules+lama-adapter+APIs+refinements
|
|
40
50
|
export type Pagination = { minHeight: number };
|
|
41
|
-
export type Api = {
|
|
51
|
+
export type Api<TokenIdentifier> = {
|
|
42
52
|
broadcast: (tx: string) => Promise<string>;
|
|
43
53
|
combine: (tx: string, signature: string, pubkey?: string) => string;
|
|
44
54
|
craftTransaction: (address: string, transaction: Transaction, pubkey?: string) => Promise<string>;
|
|
45
55
|
estimateFees: (addr: string, amount: bigint) => Promise<bigint>;
|
|
46
56
|
getBalance: (address: string) => Promise<Asset | bigint>;
|
|
47
57
|
lastBlock: () => Promise<BlockInfo>;
|
|
48
|
-
listOperations: (
|
|
58
|
+
listOperations: (
|
|
59
|
+
address: string,
|
|
60
|
+
pagination: Pagination,
|
|
61
|
+
) => Promise<[Operation<TokenIdentifier>[], string]>;
|
|
49
62
|
};
|
package/src/config.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
1
|
+
import { CryptoCurrency, CryptoCurrencyId } from "@ledgerhq/types-cryptoassets";
|
|
2
2
|
import { MissingCoinConfig } from "./errors";
|
|
3
3
|
|
|
4
4
|
type ConfigStatus =
|
|
@@ -9,6 +9,13 @@ type ConfigStatus =
|
|
|
9
9
|
type: "under_maintenance";
|
|
10
10
|
message?: string;
|
|
11
11
|
}
|
|
12
|
+
| {
|
|
13
|
+
type: "migration";
|
|
14
|
+
chain: CryptoCurrencyId;
|
|
15
|
+
from: string;
|
|
16
|
+
to: string;
|
|
17
|
+
link: string;
|
|
18
|
+
}
|
|
12
19
|
| {
|
|
13
20
|
type: "feature_unavailable";
|
|
14
21
|
link: string;
|
|
@@ -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
|
+
}
|