@ledgerhq/coin-module-framework 2.0.2 → 2.1.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 +6 -18
- package/CHANGELOG.md +12 -0
- package/lib/api/getBalance/rejectBalanceOptions.d.ts +11 -0
- package/lib/api/getBalance/rejectBalanceOptions.d.ts.map +1 -0
- package/lib/api/getBalance/rejectBalanceOptions.js +19 -0
- package/lib/api/getBalance/rejectBalanceOptions.js.map +1 -0
- package/lib-es/api/getBalance/rejectBalanceOptions.d.ts +11 -0
- package/lib-es/api/getBalance/rejectBalanceOptions.d.ts.map +1 -0
- package/lib-es/api/getBalance/rejectBalanceOptions.js +16 -0
- package/lib-es/api/getBalance/rejectBalanceOptions.js.map +1 -0
- package/package.json +1 -1
- package/src/api/getBalance/rejectBalanceOptions.test.ts +19 -0
- package/src/api/getBalance/rejectBalanceOptions.ts +21 -0
package/.unimportedrc.json
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"entry": [
|
|
3
|
-
"src/api/index.ts",
|
|
4
|
-
"src/currencies/index.ts",
|
|
5
|
-
"src/index.ts",
|
|
6
|
-
"src/utils.ts"
|
|
7
|
-
],
|
|
2
|
+
"entry": ["src/api/index.ts", "src/currencies/index.ts", "src/index.ts", "src/utils.ts"],
|
|
8
3
|
"ignoreUnimported": [
|
|
9
4
|
"src/api/errors.ts",
|
|
10
5
|
"src/api/index.ts",
|
|
@@ -17,16 +12,9 @@
|
|
|
17
12
|
"src/features/types.ts",
|
|
18
13
|
"src/setup.ts",
|
|
19
14
|
"src/test/utils.ts",
|
|
20
|
-
"src/utils.ts"
|
|
21
|
-
|
|
22
|
-
"ignoreUnresolved": [
|
|
23
|
-
"src/features/types.ts",
|
|
24
|
-
"src/setup.ts",
|
|
25
|
-
"src/utils.ts"
|
|
15
|
+
"src/utils.ts",
|
|
16
|
+
"src/api/getBalance/rejectBalanceOptions.ts"
|
|
26
17
|
],
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"expect"
|
|
31
|
-
]
|
|
32
|
-
}
|
|
18
|
+
"ignoreUnresolved": ["src/features/types.ts", "src/setup.ts", "src/utils.ts"],
|
|
19
|
+
"ignoreUnused": ["@ledgerhq/errors", "@ledgerhq/live-env", "expect"]
|
|
20
|
+
}
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ledgerhq/coin-module-framework
|
|
2
2
|
|
|
3
|
+
## 2.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#488](https://github.com/LedgerHQ/alpaca-coin-module/pull/488) [`5b1c71a`](https://github.com/LedgerHQ/alpaca-coin-module/commit/5b1c71a1675b4cc9f491403a97fdef46a71f10ea) Thanks [@Moustafa-Koterba](https://github.com/Moustafa-Koterba)! - Add a common function to reject BalanceOptions on getBalance
|
|
8
|
+
|
|
9
|
+
## 2.0.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#500](https://github.com/LedgerHQ/alpaca-coin-module/pull/500) [`9b2ea00`](https://github.com/LedgerHQ/alpaca-coin-module/commit/9b2ea0026a384ade9e63d6378de8a3a69efd1e3a) Thanks [@francois-guerin-ledger](https://github.com/francois-guerin-ledger)! - chore(coin-module-framework): blank changeset
|
|
14
|
+
|
|
3
15
|
## 2.0.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Balance, BalanceOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a balance fetcher that does not support {@link BalanceOptions}
|
|
4
|
+
*
|
|
5
|
+
* @param getBalance function that returns {@link Balance}[] without applying options
|
|
6
|
+
* @param options must be undefined; any defined value is rejected
|
|
7
|
+
* @returns the promise returned by {@link getBalance}
|
|
8
|
+
* @throws an {@link InvalidParameterError} when {@link options} is provided
|
|
9
|
+
*/
|
|
10
|
+
export declare function rejectBalanceOptions(getBalance: () => Promise<Balance[]>, options?: BalanceOptions): Promise<Balance[]>;
|
|
11
|
+
//# sourceMappingURL=rejectBalanceOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejectBalanceOptions.d.ts","sourceRoot":"","sources":["../../../src/api/getBalance/rejectBalanceOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,EAAE,CAAC,CAMpB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rejectBalanceOptions = rejectBalanceOptions;
|
|
4
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
5
|
+
/**
|
|
6
|
+
* Wraps a balance fetcher that does not support {@link BalanceOptions}
|
|
7
|
+
*
|
|
8
|
+
* @param getBalance function that returns {@link Balance}[] without applying options
|
|
9
|
+
* @param options must be undefined; any defined value is rejected
|
|
10
|
+
* @returns the promise returned by {@link getBalance}
|
|
11
|
+
* @throws an {@link InvalidParameterError} when {@link options} is provided
|
|
12
|
+
*/
|
|
13
|
+
async function rejectBalanceOptions(getBalance, options) {
|
|
14
|
+
if (options) {
|
|
15
|
+
throw new errors_1.InvalidParameterError('getBalance does not support the options parameter');
|
|
16
|
+
}
|
|
17
|
+
return getBalance();
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=rejectBalanceOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejectBalanceOptions.js","sourceRoot":"","sources":["../../../src/api/getBalance/rejectBalanceOptions.ts"],"names":[],"mappings":";;AAWA,oDASC;AApBD,6CAAwD;AAGxD;;;;;;;GAOG;AACI,KAAK,UAAU,oBAAoB,CACxC,UAAoC,EACpC,OAAwB;IAExB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAI,8BAAqB,CAAC,mDAAmD,CAAC,CAAA;IACtF,CAAC;IAED,OAAO,UAAU,EAAE,CAAA;AACrB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Balance, BalanceOptions } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a balance fetcher that does not support {@link BalanceOptions}
|
|
4
|
+
*
|
|
5
|
+
* @param getBalance function that returns {@link Balance}[] without applying options
|
|
6
|
+
* @param options must be undefined; any defined value is rejected
|
|
7
|
+
* @returns the promise returned by {@link getBalance}
|
|
8
|
+
* @throws an {@link InvalidParameterError} when {@link options} is provided
|
|
9
|
+
*/
|
|
10
|
+
export declare function rejectBalanceOptions(getBalance: () => Promise<Balance[]>, options?: BalanceOptions): Promise<Balance[]>;
|
|
11
|
+
//# sourceMappingURL=rejectBalanceOptions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejectBalanceOptions.d.ts","sourceRoot":"","sources":["../../../src/api/getBalance/rejectBalanceOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAElD;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,EACpC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,OAAO,EAAE,CAAC,CAMpB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { InvalidParameterError } from '@ledgerhq/errors';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a balance fetcher that does not support {@link BalanceOptions}
|
|
4
|
+
*
|
|
5
|
+
* @param getBalance function that returns {@link Balance}[] without applying options
|
|
6
|
+
* @param options must be undefined; any defined value is rejected
|
|
7
|
+
* @returns the promise returned by {@link getBalance}
|
|
8
|
+
* @throws an {@link InvalidParameterError} when {@link options} is provided
|
|
9
|
+
*/
|
|
10
|
+
export async function rejectBalanceOptions(getBalance, options) {
|
|
11
|
+
if (options) {
|
|
12
|
+
throw new InvalidParameterError('getBalance does not support the options parameter');
|
|
13
|
+
}
|
|
14
|
+
return getBalance();
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=rejectBalanceOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rejectBalanceOptions.js","sourceRoot":"","sources":["../../../src/api/getBalance/rejectBalanceOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAGxD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,UAAoC,EACpC,OAAwB;IAExB,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,IAAI,qBAAqB,CAAC,mDAAmD,CAAC,CAAA;IACtF,CAAC;IAED,OAAO,UAAU,EAAE,CAAA;AACrB,CAAC"}
|
package/package.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { InvalidParameterError } from '@ledgerhq/errors'
|
|
2
|
+
import { BalanceOptions } from '../types'
|
|
3
|
+
import { rejectBalanceOptions } from './rejectBalanceOptions'
|
|
4
|
+
|
|
5
|
+
describe('rejectBalanceOptions', () => {
|
|
6
|
+
it('should throw an exception when options is provided', async () => {
|
|
7
|
+
const getBalance = jest.fn().mockResolvedValueOnce([])
|
|
8
|
+
await expect(rejectBalanceOptions(getBalance, {} as unknown as BalanceOptions)).rejects.toThrow(
|
|
9
|
+
InvalidParameterError
|
|
10
|
+
)
|
|
11
|
+
expect(getBalance).not.toHaveBeenCalled()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('should call getBalance when options is not provided', async () => {
|
|
15
|
+
const getBalance = jest.fn().mockResolvedValueOnce([])
|
|
16
|
+
await expect(rejectBalanceOptions(getBalance)).resolves.toEqual([])
|
|
17
|
+
expect(getBalance).toHaveBeenCalledTimes(1)
|
|
18
|
+
})
|
|
19
|
+
})
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InvalidParameterError } from '@ledgerhq/errors'
|
|
2
|
+
import { Balance, BalanceOptions } from '../types'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wraps a balance fetcher that does not support {@link BalanceOptions}
|
|
6
|
+
*
|
|
7
|
+
* @param getBalance function that returns {@link Balance}[] without applying options
|
|
8
|
+
* @param options must be undefined; any defined value is rejected
|
|
9
|
+
* @returns the promise returned by {@link getBalance}
|
|
10
|
+
* @throws an {@link InvalidParameterError} when {@link options} is provided
|
|
11
|
+
*/
|
|
12
|
+
export async function rejectBalanceOptions(
|
|
13
|
+
getBalance: () => Promise<Balance[]>,
|
|
14
|
+
options?: BalanceOptions
|
|
15
|
+
): Promise<Balance[]> {
|
|
16
|
+
if (options) {
|
|
17
|
+
throw new InvalidParameterError('getBalance does not support the options parameter')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return getBalance()
|
|
21
|
+
}
|