@meddleware/treasury-ui 0.0.9 → 0.0.10
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meddleware/treasury-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"homepage": "https://docs.meddleware.co.uk/treasury/",
|
|
5
5
|
"description": "Meddleware treasury console — organisation-level accounting across revenue streams (Sui and beyond). Read-only, desktop-console UI built on @meddleware/ui.",
|
|
6
6
|
"author": "Meddleware <dev@meddleware.co.uk>",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@meddleware/access-gate-client": "^0.0.
|
|
47
|
+
"@meddleware/access-gate-client": "^0.0.4",
|
|
48
48
|
"@meddleware/design-tokens": "^0.1.7",
|
|
49
49
|
"@meddleware/ui": "^0.1.28",
|
|
50
50
|
"@mysten/sui": "^2.33.1",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"@meddleware/wallet-adapter": ">=0.0.12 <0.2.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@meddleware/wallet-adapter": "^0.0.
|
|
57
|
+
"@meddleware/wallet-adapter": "^0.0.13",
|
|
58
58
|
"@types/node": "~24.12.2",
|
|
59
59
|
"@vitejs/plugin-vue": "^6.0.9",
|
|
60
60
|
"@vue/eslint-config-typescript": "^14.9.0",
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { ref } from 'vue'
|
|
2
2
|
import { getSuiClient } from '../wallet.js'
|
|
3
|
-
import { onChainContext } from './chainContext.js'
|
|
3
|
+
import { latest, onChainContext } from './chainContext.js'
|
|
4
4
|
|
|
5
5
|
export function useEpoch() {
|
|
6
6
|
const epoch = ref<number | null>(null)
|
|
7
|
+
const begin = latest()
|
|
7
8
|
|
|
8
9
|
async function load() {
|
|
10
|
+
const current = begin()
|
|
9
11
|
try {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
epoch.value = Number(res.systemState.epoch)
|
|
12
|
+
const res = await getSuiClient().getCurrentSystemState()
|
|
13
|
+
if (current()) epoch.value = Number(res.systemState.epoch)
|
|
13
14
|
} catch {
|
|
14
15
|
// non-fatal — status bar shows "Epoch —"
|
|
15
16
|
}
|
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
// Reads the SUI
|
|
2
|
-
//
|
|
1
|
+
// Reads the SUI the treasury address holds: its coin objects plus its address balance (SIP-58), so
|
|
2
|
+
// funds sent with `send_funds` are counted. Reactive to the address getter so it refetches when
|
|
3
|
+
// usePlatformConfig resolves; clears to null while the address is unknown or unreadable. A slower,
|
|
4
|
+
// older read never overwrites a newer one.
|
|
3
5
|
import { ref, watch } from 'vue'
|
|
4
6
|
import { getSuiClient } from '../wallet.js'
|
|
7
|
+
import { latest } from './chainContext.js'
|
|
5
8
|
|
|
6
9
|
export function useTreasury(treasuryAddress: () => string | null) {
|
|
7
10
|
const balance = ref<bigint | null>(null)
|
|
8
11
|
const loading = ref(false)
|
|
9
12
|
const error = ref<string | null>(null)
|
|
13
|
+
const begin = latest()
|
|
10
14
|
|
|
11
15
|
async function load(address: string) {
|
|
16
|
+
const current = begin()
|
|
12
17
|
loading.value = true
|
|
13
18
|
error.value = null
|
|
14
19
|
try {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
balance.value = BigInt(res.balance.coinBalance)
|
|
20
|
+
const res = await getSuiClient().core.getBalance({ owner: address, coinType: '0x2::sui::SUI' })
|
|
21
|
+
if (current()) balance.value = BigInt(res.balance.balance)
|
|
18
22
|
} catch (e) {
|
|
23
|
+
if (!current()) return
|
|
24
|
+
balance.value = null
|
|
19
25
|
error.value = e instanceof Error ? e.message : String(e)
|
|
20
26
|
} finally {
|
|
21
|
-
loading.value = false
|
|
27
|
+
if (current()) loading.value = false
|
|
22
28
|
}
|
|
23
29
|
}
|
|
24
30
|
|
|
25
31
|
watch(
|
|
26
32
|
treasuryAddress,
|
|
27
|
-
(addr) => {
|
|
33
|
+
(addr) => {
|
|
34
|
+
if (addr) {
|
|
35
|
+
void load(addr)
|
|
36
|
+
} else {
|
|
37
|
+
begin()
|
|
38
|
+
balance.value = null
|
|
39
|
+
loading.value = false
|
|
40
|
+
}
|
|
41
|
+
},
|
|
28
42
|
{ immediate: true },
|
|
29
43
|
)
|
|
30
44
|
|