@otoplo/wallet-common 0.1.13 → 0.1.15
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/dist/index.js +315 -300
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/persistence/datastore/db.d.ts +39 -0
- package/dist/types/persistence/datastore/db.d.ts.map +1 -0
- package/dist/types/persistence/datastore/index.d.ts +3 -0
- package/dist/types/persistence/datastore/index.d.ts.map +1 -0
- package/dist/types/persistence/datastore/kv.d.ts +34 -0
- package/dist/types/persistence/datastore/kv.d.ts.map +1 -0
- package/dist/types/persistence/index.d.ts +3 -0
- package/dist/types/persistence/index.d.ts.map +1 -0
- package/dist/types/persistence/wallet-db.d.ts +61 -0
- package/dist/types/persistence/wallet-db.d.ts.map +1 -0
- package/dist/types/services/asset.d.ts +19 -0
- package/dist/types/services/asset.d.ts.map +1 -0
- package/dist/types/services/cache.d.ts +14 -0
- package/dist/types/services/cache.d.ts.map +1 -0
- package/dist/types/services/discovery.d.ts +14 -0
- package/dist/types/services/discovery.d.ts.map +1 -0
- package/dist/types/services/index.d.ts +9 -0
- package/dist/types/services/index.d.ts.map +1 -0
- package/dist/types/services/key.d.ts +13 -0
- package/dist/types/services/key.d.ts.map +1 -0
- package/dist/types/services/rostrum.d.ts +32 -0
- package/dist/types/services/rostrum.d.ts.map +1 -0
- package/dist/types/services/session.d.ts +48 -0
- package/dist/types/services/session.d.ts.map +1 -0
- package/dist/types/services/transaction.d.ts +41 -0
- package/dist/types/services/transaction.d.ts.map +1 -0
- package/dist/types/services/tx-transformer.d.ts +22 -0
- package/dist/types/services/tx-transformer.d.ts.map +1 -0
- package/dist/types/services/wallet.d.ts +101 -0
- package/dist/types/services/wallet.d.ts.map +1 -0
- package/dist/types/state/hooks.d.ts +16 -0
- package/dist/types/state/hooks.d.ts.map +1 -0
- package/dist/types/state/index.d.ts +4 -0
- package/dist/types/state/index.d.ts.map +1 -0
- package/dist/types/state/slices/auth.d.ts +17 -0
- package/dist/types/state/slices/auth.d.ts.map +1 -0
- package/dist/types/state/slices/dapp.d.ts +29 -0
- package/dist/types/state/slices/dapp.d.ts.map +1 -0
- package/dist/types/state/slices/index.d.ts +7 -0
- package/dist/types/state/slices/index.d.ts.map +1 -0
- package/dist/types/state/slices/loader.d.ts +15 -0
- package/dist/types/state/slices/loader.d.ts.map +1 -0
- package/dist/types/state/slices/notifications.d.ts +142 -0
- package/dist/types/state/slices/notifications.d.ts.map +1 -0
- package/dist/types/state/slices/status.d.ts +62 -0
- package/dist/types/state/slices/status.d.ts.map +1 -0
- package/dist/types/state/slices/wallet.d.ts +1032 -0
- package/dist/types/state/slices/wallet.d.ts.map +1 -0
- package/dist/types/state/store.d.ts +23 -0
- package/dist/types/state/store.d.ts.map +1 -0
- package/dist/types/types/dapp.types.d.ts +19 -0
- package/dist/types/types/dapp.types.d.ts.map +1 -0
- package/dist/types/types/db.types.d.ts +128 -0
- package/dist/types/types/db.types.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +6 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/notification.types.d.ts +21 -0
- package/dist/types/types/notification.types.d.ts.map +1 -0
- package/dist/types/types/rostrum.types.d.ts +145 -0
- package/dist/types/types/rostrum.types.d.ts.map +1 -0
- package/dist/types/types/wallet.types.d.ts +54 -0
- package/dist/types/types/wallet.types.d.ts.map +1 -0
- package/dist/types/utils/asset.d.ts +9 -0
- package/dist/types/utils/asset.d.ts.map +1 -0
- package/dist/types/utils/common.d.ts +27 -0
- package/dist/types/utils/common.d.ts.map +1 -0
- package/dist/types/utils/enums.d.ts +20 -0
- package/dist/types/utils/enums.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +8 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/keypath.d.ts +5 -0
- package/dist/types/utils/keypath.d.ts.map +1 -0
- package/dist/types/utils/price.d.ts +42 -0
- package/dist/types/utils/price.d.ts.map +1 -0
- package/dist/types/utils/seed.d.ts +5 -0
- package/dist/types/utils/seed.d.ts.map +1 -0
- package/dist/types/utils/vault.d.ts +8 -0
- package/dist/types/utils/vault.d.ts.map +1 -0
- package/package.json +7 -6
- package/src/index.ts +1 -1
- package/src/utils/common.ts +20 -1
- package/dist/index.d.ts +0 -2305
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@otoplo/wallet-common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.15",
|
|
4
4
|
"description": "Shared common library for internal use in Otoplo wallet",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "vgrunner",
|
|
7
7
|
"type": "module",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
8
|
+
"types": "dist/types/index.d.ts",
|
|
9
9
|
"main": "dist/index.js",
|
|
10
10
|
"module": "dist/index.js",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"types": "./dist/index.d.ts",
|
|
13
|
+
"types": "./dist/types/index.d.ts",
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
@@ -38,15 +38,16 @@
|
|
|
38
38
|
"del-cli": "^7.0.0",
|
|
39
39
|
"eslint": "^9.39.2",
|
|
40
40
|
"typescript": "^5.9.3",
|
|
41
|
-
"typescript-eslint": "^8.
|
|
41
|
+
"typescript-eslint": "^8.53.0",
|
|
42
42
|
"vite": "^7.3.1",
|
|
43
43
|
"vite-plugin-dts": "^4.5.4"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@otoplo/electrum-client": "^0.2.1",
|
|
47
|
-
"@reduxjs/toolkit": "^2.11.
|
|
47
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
48
|
+
"js-big-decimal": "^2.2.0",
|
|
48
49
|
"libnexa-ts": "^3.0.0",
|
|
49
|
-
"react": "
|
|
50
|
+
"react": ">=19.1.0",
|
|
50
51
|
"react-redux": "^9.2.0",
|
|
51
52
|
"wallet-comms-sdk": "^0.9.1"
|
|
52
53
|
},
|
package/src/index.ts
CHANGED
package/src/utils/common.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Address, AddressType, BufferUtils, CommonUtils, Networks } from "libnexa-ts";
|
|
2
2
|
import type { Balance } from "../types/wallet.types";
|
|
3
|
+
import bigDecimal from 'js-big-decimal';
|
|
3
4
|
|
|
4
5
|
export const MAIN_WALLET_ID = -1;
|
|
5
6
|
export const MAX_INT64 = 9223372036854775807n;
|
|
@@ -156,4 +157,22 @@ export function getFileMimeType(filename: string): string {
|
|
|
156
157
|
|
|
157
158
|
const extension = filename.slice(lastDotIndex).toLowerCase();
|
|
158
159
|
return FILE_EXTENSION_TO_TYPE[extension as keyof typeof FILE_EXTENSION_TO_TYPE]?.mime ?? 'application/octet-stream';
|
|
159
|
-
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export function sleep(ms: number): Promise<void> {
|
|
163
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export function prettifyAmount(amount: string | number): string {
|
|
167
|
+
let val = bigDecimal.getPrettyValue(amount);
|
|
168
|
+
if (val.match(/\./)) {
|
|
169
|
+
val = val.replace(/\.?0+$/, '');
|
|
170
|
+
}
|
|
171
|
+
return val;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export function calcAmountValue(amount: string | number, price: number, prettify = false): string {
|
|
175
|
+
const value = bigDecimal.multiply(amount, price);
|
|
176
|
+
const rounded = bigDecimal.round(value, 2, bigDecimal.RoundingModes.HALF_DOWN);
|
|
177
|
+
return prettify ? prettifyAmount(rounded) : rounded;
|
|
178
|
+
}
|