Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98a208eb3d | ||
|
|
9ca0aa9b54 | ||
|
|
5d1e579899 | ||
|
|
22e905700d | ||
|
|
165e8c57b8 | ||
|
|
6c11bc3e69 | ||
|
|
b3c235af53 | ||
|
|
b8da76bf3e | ||
|
|
5610969730 | ||
|
|
208ee81018 | ||
|
|
8b5a3c8fe9 | ||
|
|
eafe30b80a | ||
|
|
f38a60bcb6 |
@@ -21,7 +21,7 @@ type NavStore = {
|
||||
hide: () => void;
|
||||
};
|
||||
|
||||
export const useNavStore = create<NavStore>((set, get) => ({
|
||||
export const useNavStore = create<NavStore>()((set, get) => ({
|
||||
open: false,
|
||||
toggle: () => set({ open: !get().open }),
|
||||
hide: () => set({ open: false }),
|
||||
|
||||
@@ -9,26 +9,28 @@ export type PendingTxsStore = {
|
||||
resetPendingTxs: () => void;
|
||||
};
|
||||
|
||||
export const usePendingBalancesStore = create<PendingTxsStore>((set, get) => ({
|
||||
pendingBalances: [],
|
||||
addPendingTxs: (event: Event[]) => {
|
||||
set({
|
||||
pendingBalances: uniqBy(
|
||||
[...get().pendingBalances, ...event],
|
||||
'transactionHash'
|
||||
),
|
||||
});
|
||||
},
|
||||
removePendingTx: (event: Event) => {
|
||||
set({
|
||||
pendingBalances: [
|
||||
...get().pendingBalances.filter(
|
||||
({ transactionHash }) => transactionHash !== event.transactionHash
|
||||
export const usePendingBalancesStore = create<PendingTxsStore>()(
|
||||
(set, get) => ({
|
||||
pendingBalances: [],
|
||||
addPendingTxs: (event: Event[]) => {
|
||||
set({
|
||||
pendingBalances: uniqBy(
|
||||
[...get().pendingBalances, ...event],
|
||||
'transactionHash'
|
||||
),
|
||||
],
|
||||
});
|
||||
},
|
||||
resetPendingTxs: () => {
|
||||
set({ pendingBalances: [] });
|
||||
},
|
||||
}));
|
||||
});
|
||||
},
|
||||
removePendingTx: (event: Event) => {
|
||||
set({
|
||||
pendingBalances: [
|
||||
...get().pendingBalances.filter(
|
||||
({ transactionHash }) => transactionHash !== event.transactionHash
|
||||
),
|
||||
],
|
||||
});
|
||||
},
|
||||
resetPendingTxs: () => {
|
||||
set({ pendingBalances: [] });
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
@@ -38,7 +38,7 @@ export interface RefreshBalances {
|
||||
vestingAssociatedBalance: BigNumber;
|
||||
}
|
||||
|
||||
export const useBalances = create<BalancesStore>((set) => ({
|
||||
export const useBalances = create<BalancesStore>()((set) => ({
|
||||
associationBreakdown: {
|
||||
stakingAssociations: {},
|
||||
vestingAssociations: {},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { toBigNum } from '@vegaprotocol/utils';
|
||||
import type { TrancheServiceResponse } from '@vegaprotocol/smart-contracts';
|
||||
import type BigNumber from 'bignumber.js';
|
||||
import create from 'zustand';
|
||||
import { create } from 'zustand';
|
||||
import { ENV } from '../../config';
|
||||
|
||||
export interface Tranche {
|
||||
@@ -36,7 +36,7 @@ export type TranchesStore = {
|
||||
|
||||
const secondsToDate = (seconds: number) => new Date(seconds * 1000);
|
||||
|
||||
export const useTranches = create<TranchesStore>((set) => ({
|
||||
export const useTranches = create<TranchesStore>()((set) => ({
|
||||
tranches: null,
|
||||
loading: false,
|
||||
error: null,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import type ethers from 'ethers';
|
||||
import type { GetState, SetState } from 'zustand';
|
||||
import { create } from 'zustand';
|
||||
|
||||
export interface TxData {
|
||||
@@ -16,27 +15,25 @@ interface TransactionStore {
|
||||
remove: (tx: TxData) => void;
|
||||
}
|
||||
|
||||
export const useTransactionStore = create(
|
||||
(set: SetState<TransactionStore>, get: GetState<TransactionStore>) => ({
|
||||
transactions: [],
|
||||
add: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({ transactions: [...transactions, tx] });
|
||||
},
|
||||
update: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({
|
||||
transactions: [
|
||||
...transactions.filter((t) => t.tx.hash !== tx.tx.hash),
|
||||
tx,
|
||||
],
|
||||
});
|
||||
},
|
||||
remove: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({
|
||||
transactions: transactions.filter((t) => t.tx.hash !== tx.tx.hash),
|
||||
});
|
||||
},
|
||||
})
|
||||
);
|
||||
export const useTransactionStore = create<TransactionStore>()((set, get) => ({
|
||||
transactions: [],
|
||||
add: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({ transactions: [...transactions, tx] });
|
||||
},
|
||||
update: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({
|
||||
transactions: [
|
||||
...transactions.filter((t) => t.tx.hash !== tx.tx.hash),
|
||||
tx,
|
||||
],
|
||||
});
|
||||
},
|
||||
remove: (tx) => {
|
||||
const { transactions } = get();
|
||||
set({
|
||||
transactions: transactions.filter((t) => t.tx.hash !== tx.tx.hash),
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
"tranche_end": "2023-04-06T00:00:00.000Z",
|
||||
"total_added": "14099",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "12617.7575018667867895",
|
||||
"locked_amount": "12845.7134438470736744",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "30",
|
||||
@@ -2772,7 +2772,7 @@
|
||||
"tranche_end": "2023-12-05T00:00:00.000Z",
|
||||
"total_added": "86666.297",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "64285.7673562747065404843",
|
||||
"locked_amount": "64404.7768689454615673836",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "86666.297",
|
||||
@@ -2838,7 +2838,7 @@
|
||||
"tranche_end": "2023-06-01T00:00:00.000Z",
|
||||
"total_added": "2500",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "1150.31781008343525",
|
||||
"locked_amount": "1157.2026353276355",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "2500",
|
||||
@@ -2959,7 +2959,7 @@
|
||||
"tranche_end": "2023-09-01T00:00:00.000Z",
|
||||
"total_added": "17500",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "16714.7004893820455",
|
||||
"locked_amount": "16762.3704206924315",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "12500",
|
||||
@@ -3226,7 +3226,7 @@
|
||||
"tranche_end": "2023-08-01T00:00:00.000Z",
|
||||
"total_added": "37500",
|
||||
"total_removed": "3720.2151432",
|
||||
"locked_amount": "29988.218903468385",
|
||||
"locked_amount": "30092.06184775936125",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "7500",
|
||||
@@ -3436,7 +3436,7 @@
|
||||
"tranche_end": "2023-12-05T00:00:00.000Z",
|
||||
"total_added": "129999.45",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "64227.11468230750679427",
|
||||
"locked_amount": "64346.015613772301177895",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "129999.45",
|
||||
@@ -3502,7 +3502,7 @@
|
||||
"tranche_end": "2023-09-03T00:00:00.000Z",
|
||||
"total_added": "62600",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "30484.165341197362916",
|
||||
"locked_amount": "30570.1271943176011",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "10000",
|
||||
@@ -3695,7 +3695,7 @@
|
||||
"tranche_end": "2023-09-17T00:00:00.000Z",
|
||||
"total_added": "5000",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "2626.6183092338915",
|
||||
"locked_amount": "2633.484271943176",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "5000",
|
||||
@@ -3906,7 +3906,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "97499.58",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "6223.0180998922696421586",
|
||||
"locked_amount": "6339.6488375364585926712",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "97499.58",
|
||||
@@ -3939,7 +3939,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "135173.4239508",
|
||||
"total_removed": "98230.390980249184455396",
|
||||
"locked_amount": "8505.791383297548872197280352",
|
||||
"locked_amount": "8665.205466200317294112311476",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "135173.4239508",
|
||||
@@ -3985,7 +3985,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "32499.86",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "2617.916248850263699179",
|
||||
"locked_amount": "2666.9807860720642474196",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "32499.86",
|
||||
@@ -4018,7 +4018,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "10833.29",
|
||||
"total_removed": "0",
|
||||
"locked_amount": "852.1063353427969979115",
|
||||
"locked_amount": "868.0763660974942076085",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "10833.29",
|
||||
@@ -4051,7 +4051,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "22749.93",
|
||||
"total_removed": "4720.860935375",
|
||||
"locked_amount": "3185.3637960242138921349",
|
||||
"locked_amount": "3245.0633378272258072119",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "6500",
|
||||
@@ -4203,7 +4203,7 @@
|
||||
"tranche_end": "2023-05-01T00:00:00.000Z",
|
||||
"total_added": "22500",
|
||||
"total_removed": "5257.2509016",
|
||||
"locked_amount": "6556.467253683241575",
|
||||
"locked_amount": "6618.773020257828",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "7500",
|
||||
@@ -4533,7 +4533,7 @@
|
||||
"tranche_end": "2023-06-02T00:00:00.000Z",
|
||||
"total_added": "1939928.38",
|
||||
"total_removed": "928642.9598472029154",
|
||||
"locked_amount": "450398.946987019844262332",
|
||||
"locked_amount": "453062.8421701724988668568",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "1852091.69",
|
||||
@@ -9943,7 +9943,7 @@
|
||||
"tranche_start": "2021-09-03T00:00:00.000Z",
|
||||
"tranche_end": "2022-09-03T00:00:00.000Z",
|
||||
"total_added": "55431.000000000000000003",
|
||||
"total_removed": "44310.21518131551",
|
||||
"total_removed": "44298.21518131551",
|
||||
"locked_amount": "0",
|
||||
"deposits": [
|
||||
{
|
||||
@@ -20223,11 +20223,6 @@
|
||||
"user": "0x4043fD11285B4f98A0f7b383D973a17F03e23EC5",
|
||||
"tx": "0xa3689042534a1b09c39510c3a9da4f5838c77e88df0dd7dd76415b759d9ad377"
|
||||
},
|
||||
{
|
||||
"amount": "12",
|
||||
"user": "0xCeE1b5DF292f5EA23798271f8e1374D911Fb4DE0",
|
||||
"tx": "0xfc74f691ee45ff735fd4df873755059973385f62772d50a85d9cc1e5ba53e528"
|
||||
},
|
||||
{
|
||||
"amount": "12",
|
||||
"user": "0x1D92cb812FdeDF1a5aFE3c5080B2D3Ec102694c6",
|
||||
@@ -35734,17 +35729,10 @@
|
||||
"tx": "0xd03e666dd6a358145f291e4ceec193352614d00727ed8910a4cad16374fffa43"
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "12",
|
||||
"user": "0xCeE1b5DF292f5EA23798271f8e1374D911Fb4DE0",
|
||||
"tranche_id": 11,
|
||||
"tx": "0xfc74f691ee45ff735fd4df873755059973385f62772d50a85d9cc1e5ba53e528"
|
||||
}
|
||||
],
|
||||
"withdrawals": [],
|
||||
"total_tokens": "12",
|
||||
"withdrawn_tokens": "12",
|
||||
"remaining_tokens": "0"
|
||||
"withdrawn_tokens": "0",
|
||||
"remaining_tokens": "12"
|
||||
},
|
||||
{
|
||||
"address": "0x2dd204e9cC4D41C68f2bb7Aa3b8Ce49884e482f5",
|
||||
@@ -37281,8 +37269,8 @@
|
||||
"tranche_start": "2022-03-05T00:00:00.000Z",
|
||||
"tranche_end": "2023-06-05T00:00:00.000Z",
|
||||
"total_added": "3732368.4671",
|
||||
"total_removed": "700133.348465855088393",
|
||||
"locked_amount": "716607.693990203113306957658",
|
||||
"total_removed": "618385.665327542135993",
|
||||
"locked_amount": "720701.17341691302668589937",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "1998.95815",
|
||||
@@ -37456,16 +37444,6 @@
|
||||
"user": "0xE6CacAE56Cca8dFdB7910b5A13578719D4E57DA0",
|
||||
"tx": "0xcba878ae28c2c84219f8281dc2a57d0d9b6c99b7920900d5344c76aabe8f1e84"
|
||||
},
|
||||
{
|
||||
"amount": "52343.18016",
|
||||
"user": "0x93b478148FF792B00076B7EdC89Db1FdE7772079",
|
||||
"tx": "0x282e2c8a2d0f87b31d99e0be5d955c1c1a5b69ff43364630a130a1222fb6d06c"
|
||||
},
|
||||
{
|
||||
"amount": "29404.5029783129524",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
"tx": "0x166702670ca700f8d8957a5264ec47f6bcf67609682512d11dabc14276add0fb"
|
||||
},
|
||||
{
|
||||
"amount": "16659.576193025747093",
|
||||
"user": "0xB523235B6c7C74DDB26b10E78bFb2d0Cb63Ae289",
|
||||
@@ -38144,12 +38122,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "29404.5029783129524",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x166702670ca700f8d8957a5264ec47f6bcf67609682512d11dabc14276add0fb"
|
||||
},
|
||||
{
|
||||
"amount": "20348.9930984908397",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
@@ -38176,8 +38148,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "112323.67",
|
||||
"withdrawn_tokens": "90743.8609743760004",
|
||||
"remaining_tokens": "21579.8090256239996"
|
||||
"withdrawn_tokens": "61339.357996063048",
|
||||
"remaining_tokens": "50984.312003936952"
|
||||
},
|
||||
{
|
||||
"address": "0x3D7944C81794Bc621076958cA0dC0F0b31BDc3e2",
|
||||
@@ -38554,12 +38526,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "52343.18016",
|
||||
"user": "0x93b478148FF792B00076B7EdC89Db1FdE7772079",
|
||||
"tranche_id": 1,
|
||||
"tx": "0x282e2c8a2d0f87b31d99e0be5d955c1c1a5b69ff43364630a130a1222fb6d06c"
|
||||
},
|
||||
{
|
||||
"amount": "34960.394886",
|
||||
"user": "0x93b478148FF792B00076B7EdC89Db1FdE7772079",
|
||||
@@ -38586,8 +38552,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "200000",
|
||||
"withdrawn_tokens": "161559.866074",
|
||||
"remaining_tokens": "38440.133926"
|
||||
"withdrawn_tokens": "109216.685914",
|
||||
"remaining_tokens": "90783.314086"
|
||||
},
|
||||
{
|
||||
"address": "0xB523235B6c7C74DDB26b10E78bFb2d0Cb63Ae289",
|
||||
@@ -38663,8 +38629,8 @@
|
||||
"tranche_start": "2022-06-05T00:00:00.000Z",
|
||||
"tranche_end": "2023-12-05T00:00:00.000Z",
|
||||
"total_added": "15870102.715470999700000001",
|
||||
"total_removed": "793252.53458217063817452",
|
||||
"locked_amount": "7840732.4579185194844121091949082385658286",
|
||||
"total_removed": "589571.49512571875997952",
|
||||
"locked_amount": "7855247.6731391336068375002475321149851311",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "16249.93",
|
||||
@@ -39268,41 +39234,6 @@
|
||||
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
|
||||
"tx": "0x16288057d0947efbbbc6ca61d6864ecfd4eb7949ddc1a934a05474ddbe453d4b"
|
||||
},
|
||||
{
|
||||
"amount": "536.260884812357375",
|
||||
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
|
||||
"tx": "0x18cda39375506d544e7a7b9fa9137aa3887b2abac598b151502a2c4eb1835f37"
|
||||
},
|
||||
{
|
||||
"amount": "19140.8654581272429",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
"tx": "0xcfc7eefc60479d3e8470ea1c5d673a12e2417c9b9b3ebf4bf4137e8260fe07c8"
|
||||
},
|
||||
{
|
||||
"amount": "43338.199512",
|
||||
"user": "0x29f1856E73262fc4372BBF442EbB550919459308",
|
||||
"tx": "0x666f2848ebb8b2f7c6d7829fbab733bce6aeb750b6c70a51753ad86321f87247"
|
||||
},
|
||||
{
|
||||
"amount": "43325.172344",
|
||||
"user": "0x21ff84851BdF79de9AA357E47856d58b2d825392",
|
||||
"tx": "0xa13fae0c67f07b9eeaa65833f61e559672ba72a8c5b788ca83de99d95d1b2543"
|
||||
},
|
||||
{
|
||||
"amount": "43329.582318",
|
||||
"user": "0x1b956E6c00E238194B331eddEFF72Cb5f28A8d01",
|
||||
"tx": "0x5eb1aba5b222162fbdec7d3e70bada62541fdef3914d25ba81e4fcb04a9d776b"
|
||||
},
|
||||
{
|
||||
"amount": "43329.683698",
|
||||
"user": "0x74b521F96c641FD59631Dc6a24c558ed39D64352",
|
||||
"tx": "0x9050c6348f5ef78b2a6d6b0947dcf004a8b608434319e9e30d8d6495fa19dc42"
|
||||
},
|
||||
{
|
||||
"amount": "10681.27524151227792",
|
||||
"user": "0x4d982Ab0823fD2f48e934a7be2bb0a5374a26148",
|
||||
"tx": "0x1bb20a86b93d4f463dfab637d48333322efa4562109547456c547a1f7141e324"
|
||||
},
|
||||
{
|
||||
"amount": "535.4042378778335",
|
||||
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
|
||||
@@ -41150,12 +41081,6 @@
|
||||
"tranche_id": 2,
|
||||
"tx": "0x16288057d0947efbbbc6ca61d6864ecfd4eb7949ddc1a934a05474ddbe453d4b"
|
||||
},
|
||||
{
|
||||
"amount": "536.260884812357375",
|
||||
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x18cda39375506d544e7a7b9fa9137aa3887b2abac598b151502a2c4eb1835f37"
|
||||
},
|
||||
{
|
||||
"amount": "535.4042378778335",
|
||||
"user": "0x20CD77B9FC2f1fEDfb6F184E25f7127BFE991C8b",
|
||||
@@ -42370,8 +42295,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "259998.8875",
|
||||
"withdrawn_tokens": "131424.23954109192325",
|
||||
"remaining_tokens": "128574.64795890807675"
|
||||
"withdrawn_tokens": "130887.978656279565875",
|
||||
"remaining_tokens": "129110.908843720434125"
|
||||
},
|
||||
{
|
||||
"address": "0x89051CAb67Bc7F8CC44F7e270c6EDaf1EC57676c",
|
||||
@@ -42489,12 +42414,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "43325.172344",
|
||||
"user": "0x21ff84851BdF79de9AA357E47856d58b2d825392",
|
||||
"tranche_id": 2,
|
||||
"tx": "0xa13fae0c67f07b9eeaa65833f61e559672ba72a8c5b788ca83de99d95d1b2543"
|
||||
},
|
||||
{
|
||||
"amount": "30379.050924",
|
||||
"user": "0x21ff84851BdF79de9AA357E47856d58b2d825392",
|
||||
@@ -42509,8 +42428,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "200000",
|
||||
"withdrawn_tokens": "101182.629594",
|
||||
"remaining_tokens": "98817.370406"
|
||||
"withdrawn_tokens": "57857.45725",
|
||||
"remaining_tokens": "142142.54275"
|
||||
},
|
||||
{
|
||||
"address": "0x8DA3586FF7526E122093EE6dD86DFBf067ad8704",
|
||||
@@ -42872,12 +42791,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "10681.27524151227792",
|
||||
"user": "0x4d982Ab0823fD2f48e934a7be2bb0a5374a26148",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x1bb20a86b93d4f463dfab637d48333322efa4562109547456c547a1f7141e324"
|
||||
},
|
||||
{
|
||||
"amount": "10964.26423788708204",
|
||||
"user": "0x4d982Ab0823fD2f48e934a7be2bb0a5374a26148",
|
||||
@@ -42892,8 +42805,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "49294.676",
|
||||
"withdrawn_tokens": "24940.14903303097784",
|
||||
"remaining_tokens": "24354.52696696902216"
|
||||
"withdrawn_tokens": "14258.87379151869992",
|
||||
"remaining_tokens": "35035.80220848130008"
|
||||
},
|
||||
{
|
||||
"address": "0x4092E429B149b5495265b608FD6Fae69fa5bfBe6",
|
||||
@@ -42921,12 +42834,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "43329.683698",
|
||||
"user": "0x74b521F96c641FD59631Dc6a24c558ed39D64352",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x9050c6348f5ef78b2a6d6b0947dcf004a8b608434319e9e30d8d6495fa19dc42"
|
||||
},
|
||||
{
|
||||
"amount": "30570.627196",
|
||||
"user": "0x74b521F96c641FD59631Dc6a24c558ed39D64352",
|
||||
@@ -42947,8 +42854,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "200000",
|
||||
"withdrawn_tokens": "101186.22854",
|
||||
"remaining_tokens": "98813.77146"
|
||||
"withdrawn_tokens": "57856.544842",
|
||||
"remaining_tokens": "142143.455158"
|
||||
},
|
||||
{
|
||||
"address": "0x834b777E3aB758C84FeBbfb9d6BB675bc4B16915",
|
||||
@@ -43311,12 +43218,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "43329.582318",
|
||||
"user": "0x1b956E6c00E238194B331eddEFF72Cb5f28A8d01",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x5eb1aba5b222162fbdec7d3e70bada62541fdef3914d25ba81e4fcb04a9d776b"
|
||||
},
|
||||
{
|
||||
"amount": "30374.150954",
|
||||
"user": "0x1b956E6c00E238194B331eddEFF72Cb5f28A8d01",
|
||||
@@ -43337,8 +43238,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "200000",
|
||||
"withdrawn_tokens": "101184.251654",
|
||||
"remaining_tokens": "98815.748346"
|
||||
"withdrawn_tokens": "57854.669336",
|
||||
"remaining_tokens": "142145.330664"
|
||||
},
|
||||
{
|
||||
"address": "0xA5d8726fFaD226e65D136ef9C2185750863b4850",
|
||||
@@ -43471,12 +43372,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "19140.8654581272429",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
"tranche_id": 2,
|
||||
"tx": "0xcfc7eefc60479d3e8470ea1c5d673a12e2417c9b9b3ebf4bf4137e8260fe07c8"
|
||||
},
|
||||
{
|
||||
"amount": "13246.0770207423553",
|
||||
"user": "0x1A71e3ED1996CAbB91bB043f880CE963D601707e",
|
||||
@@ -43497,8 +43392,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "87676.33",
|
||||
"withdrawn_tokens": "44350.3417083452635",
|
||||
"remaining_tokens": "43325.9882916547365"
|
||||
"withdrawn_tokens": "25209.4762502180206",
|
||||
"remaining_tokens": "62466.8537497819794"
|
||||
},
|
||||
{
|
||||
"address": "0x9cF9B305601154C85ff86014d10a8762C802db0B",
|
||||
@@ -43706,12 +43601,6 @@
|
||||
}
|
||||
],
|
||||
"withdrawals": [
|
||||
{
|
||||
"amount": "43338.199512",
|
||||
"user": "0x29f1856E73262fc4372BBF442EbB550919459308",
|
||||
"tranche_id": 2,
|
||||
"tx": "0x666f2848ebb8b2f7c6d7829fbab733bce6aeb750b6c70a51753ad86321f87247"
|
||||
},
|
||||
{
|
||||
"amount": "30360.0931",
|
||||
"user": "0x29f1856E73262fc4372BBF442EbB550919459308",
|
||||
@@ -43732,8 +43621,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "200000",
|
||||
"withdrawn_tokens": "101179.892368",
|
||||
"remaining_tokens": "98820.107632"
|
||||
"withdrawn_tokens": "57841.692856",
|
||||
"remaining_tokens": "142158.307144"
|
||||
},
|
||||
{
|
||||
"address": "0x87D71adAbC11c35aF566eD51421eDA0c82828a3A",
|
||||
@@ -44680,8 +44569,8 @@
|
||||
"tranche_start": "2021-11-05T00:00:00.000Z",
|
||||
"tranche_end": "2023-05-05T00:00:00.000Z",
|
||||
"total_added": "14597706.0446472999",
|
||||
"total_removed": "5582737.445026061837194406",
|
||||
"locked_amount": "1517068.915310638703739676396213473",
|
||||
"total_removed": "5581993.656033465744205406",
|
||||
"locked_amount": "1530469.269321785094773221183308807",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "129284.449",
|
||||
@@ -44960,11 +44849,6 @@
|
||||
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
|
||||
"tx": "0xb499e0514e04e8acb67e4e8cc68ceaf57a018bbf844b006f7e77d1a3373ddfec"
|
||||
},
|
||||
{
|
||||
"amount": "743.788992596092989",
|
||||
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
|
||||
"tx": "0xe6310e8b181b7de346b3dacbdda2dfb8191938c1326eb3ccab3c390a1da3fc5d"
|
||||
},
|
||||
{
|
||||
"amount": "800.792718381487871",
|
||||
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
|
||||
@@ -48004,12 +47888,6 @@
|
||||
"tranche_id": 3,
|
||||
"tx": "0xb499e0514e04e8acb67e4e8cc68ceaf57a018bbf844b006f7e77d1a3373ddfec"
|
||||
},
|
||||
{
|
||||
"amount": "743.788992596092989",
|
||||
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
|
||||
"tranche_id": 3,
|
||||
"tx": "0xe6310e8b181b7de346b3dacbdda2dfb8191938c1326eb3ccab3c390a1da3fc5d"
|
||||
},
|
||||
{
|
||||
"amount": "800.792718381487871",
|
||||
"user": "0x4Aa3c35F6CC2d507E5C18205ee57099A4C80B19b",
|
||||
@@ -50526,8 +50404,8 @@
|
||||
}
|
||||
],
|
||||
"total_tokens": "359123.469575",
|
||||
"withdrawn_tokens": "321634.468695554962181",
|
||||
"remaining_tokens": "37489.000879445037819"
|
||||
"withdrawn_tokens": "320890.679702958869192",
|
||||
"remaining_tokens": "38232.789872041130808"
|
||||
},
|
||||
{
|
||||
"address": "0xBdd412797c1B78535Afc5F71503b91fAbD0160fB",
|
||||
@@ -51871,7 +51749,7 @@
|
||||
"tranche_end": "2023-04-05T00:00:00.000Z",
|
||||
"total_added": "5778205.3912159303",
|
||||
"total_removed": "3353757.81738108986999524",
|
||||
"locked_amount": "282499.700055464196170878384972344",
|
||||
"locked_amount": "287794.260969934471042521754104188",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "552496.6455",
|
||||
@@ -53966,7 +53844,7 @@
|
||||
"tranche_end": "2023-06-05T00:00:00.000Z",
|
||||
"total_added": "472355.6199999996",
|
||||
"total_removed": "35983.6942986130685",
|
||||
"locked_amount": "113550.5854169627557241030010147",
|
||||
"locked_amount": "114199.22063145092350782298427196",
|
||||
"deposits": [
|
||||
{
|
||||
"amount": "3000",
|
||||
|
||||
@@ -17,13 +17,6 @@ describe('connect hosted wallet', { tags: '@smoke' }, () => {
|
||||
});
|
||||
|
||||
it('can connect', () => {
|
||||
// 0002-WCON-002
|
||||
// 0002-WCON-003
|
||||
// 0002-WCON-039
|
||||
// 0002-WCON-017
|
||||
// 0002-WCON-018
|
||||
// 0002-WCON-019
|
||||
|
||||
// Mock authentication
|
||||
cy.intercept('POST', 'https://wallet.testnet.vega.xyz/api/v1/auth/token', {
|
||||
body: {
|
||||
@@ -48,9 +41,6 @@ describe('connect hosted wallet', { tags: '@smoke' }, () => {
|
||||
},
|
||||
});
|
||||
cy.getByTestId(connectVegaBtn).click();
|
||||
cy.contains(
|
||||
'Choose wallet app to connect, or to change port or server URL enter a custom wallet location first'
|
||||
);
|
||||
cy.contains('Connect Vega wallet');
|
||||
cy.contains('Hosted Fairground wallet');
|
||||
|
||||
@@ -61,13 +51,9 @@ describe('connect hosted wallet', { tags: '@smoke' }, () => {
|
||||
cy.getByTestId(form).find('#passphrase').click().type('pass');
|
||||
cy.getByTestId('rest-connector-form').find('button[type=submit]').click();
|
||||
cy.getByTestId(manageVegaBtn).should('exist');
|
||||
cy.getByTestId('manage-vega-wallet').click();
|
||||
cy.getByTestId('keypair-list').should('exist');
|
||||
});
|
||||
|
||||
it('doesnt connect with invalid credentials', () => {
|
||||
// 0002-WCON-020
|
||||
|
||||
// Mock incorrect username/password
|
||||
cy.intercept('POST', 'https://wallet.testnet.vega.xyz/api/v1/auth/token', {
|
||||
body: {
|
||||
@@ -113,10 +99,6 @@ describe('connect vega wallet', { tags: '@smoke' }, () => {
|
||||
});
|
||||
|
||||
it('can connect', () => {
|
||||
// 0002-WCON-002
|
||||
// 0002-WCON-005
|
||||
// 0002-WCON-007
|
||||
|
||||
mockConnectWallet();
|
||||
cy.getByTestId(connectVegaBtn).click();
|
||||
cy.getByTestId('connectors-list')
|
||||
@@ -128,40 +110,16 @@ describe('connect vega wallet', { tags: '@smoke' }, () => {
|
||||
});
|
||||
|
||||
it('can change selected public key and disconnect', () => {
|
||||
// 0002-WCON-022
|
||||
// 0002-WCON-023
|
||||
// 0002-WCON-025
|
||||
// 0002-WCON-026
|
||||
// 0002-WCON-021
|
||||
// 0002-WCON-027
|
||||
// 0002-WCON-030
|
||||
// 0002-WCON-029
|
||||
// 0002-WCON-008
|
||||
// 0002-WCON-035
|
||||
// 0002-WCON-014
|
||||
// 0002-WCON-010
|
||||
|
||||
mockConnectWallet();
|
||||
const key2 = Cypress.env('VEGA_PUBLIC_KEY2');
|
||||
const truncatedKey2 = Cypress.env('TRUNCATED_VEGA_PUBLIC_KEY2');
|
||||
cy.connectVegaWallet();
|
||||
cy.getByTestId('manage-vega-wallet').click();
|
||||
cy.getByTestId('keypair-list').should('exist');
|
||||
cy.getByTestId(`key-${key2}`).should('contain.text', truncatedKey2);
|
||||
cy.getByTestId(`key-${key2}`)
|
||||
.find('[data-testid="copy-vega-public-key"]')
|
||||
.should('be.visible');
|
||||
cy.get(`[data-testid="key-${key2}"] > .mr-2`).click();
|
||||
cy.getByTestId('keypair-list')
|
||||
.find('[data-state="checked"]')
|
||||
.should('be.visible');
|
||||
cy.getByTestId('disconnect').click();
|
||||
cy.getByTestId('connect-vega-wallet').should('exist');
|
||||
cy.getByTestId('manage-vega-wallet').should('not.exist');
|
||||
cy.getByTestId('connect-vega-wallet').click();
|
||||
cy.contains(
|
||||
'Choose wallet app to connect, or to change port or server URL enter a custom wallet location first'
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ interface PageTitleStore {
|
||||
updateTitle: (title: string) => void;
|
||||
}
|
||||
|
||||
export const useGlobalStore = create<GlobalStore>((set) => ({
|
||||
export const useGlobalStore = create<GlobalStore>()((set) => ({
|
||||
nodeSwitcherDialog: false,
|
||||
marketId: LocalStorage.getItem('marketId') || null,
|
||||
shouldDisplayWelcomeDialog: false,
|
||||
|
||||
@@ -11,7 +11,7 @@ interface Actions {
|
||||
open: (open?: boolean) => void;
|
||||
}
|
||||
|
||||
export const useTransferDialog = create<State & Actions>((set) => ({
|
||||
export const useTransferDialog = create<State & Actions>()((set) => ({
|
||||
isOpen: false,
|
||||
open: (open = true) => {
|
||||
set(() => ({ isOpen: open }));
|
||||
|
||||
@@ -9,4 +9,4 @@ type HeaderStore = {
|
||||
[url: string]: HeaderEntry | undefined;
|
||||
};
|
||||
|
||||
export const useHeaderStore = create<HeaderStore>(() => ({}));
|
||||
export const useHeaderStore = create<HeaderStore>()(() => ({}));
|
||||
|
||||
@@ -20,7 +20,7 @@ export type AssetDetailsDialogStore = {
|
||||
open: (id: string, trigger?: HTMLElement | null, asJson?: boolean) => void;
|
||||
};
|
||||
|
||||
export const useAssetDetailsDialogStore = create<AssetDetailsDialogStore>(
|
||||
export const useAssetDetailsDialogStore = create<AssetDetailsDialogStore>()(
|
||||
(set) => ({
|
||||
isOpen: false,
|
||||
id: '',
|
||||
|
||||
@@ -15,7 +15,7 @@ interface Actions {
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export const useDepositDialog = create<State & Actions>((set) => ({
|
||||
export const useDepositDialog = create<State & Actions>()((set) => ({
|
||||
isOpen: false,
|
||||
assetId: undefined,
|
||||
open: (assetId) => set(() => ({ assetId, isOpen: true })),
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
const zu = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create = (createState) => {
|
||||
const store = zu.create(createState);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { StateCreator } from 'zustand';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
const { create: actualCreate } = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set<() => void>();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create =
|
||||
() =>
|
||||
<S>(createState: StateCreator<S>) => {
|
||||
const store = actualCreate(createState);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
@@ -34,7 +34,7 @@ export type EnvStore = Env & Actions;
|
||||
export const STORAGE_KEY = 'vega_url';
|
||||
const SUBSCRIPTION_TIMEOUT = 3000;
|
||||
|
||||
export const useEnvironment = create<EnvStore>((set, get) => ({
|
||||
export const useEnvironment = create<EnvStore>()((set, get) => ({
|
||||
...compileEnvVars(),
|
||||
nodes: [],
|
||||
status: 'default',
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"**/*.test.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.jsx",
|
||||
"jest.config.ts"
|
||||
"jest.config.ts",
|
||||
"__mocks__"
|
||||
],
|
||||
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ const randomToast = (): Toast => {
|
||||
};
|
||||
|
||||
type PriceStore = { price: number; setPrice: (p: number) => void };
|
||||
const usePrice = create<PriceStore>((set) => ({
|
||||
const usePrice = create<PriceStore>()((set) => ({
|
||||
price: 0,
|
||||
setPrice: (p) => set((state) => ({ price: p })),
|
||||
}));
|
||||
|
||||
@@ -47,8 +47,8 @@ type Actions = {
|
||||
|
||||
type ToastsStore = State & Actions;
|
||||
|
||||
export const useToasts = create(
|
||||
immer<ToastsStore>((set, get) => ({
|
||||
export const useToasts = create<ToastsStore>()(
|
||||
immer((set) => ({
|
||||
toasts: {},
|
||||
count: 0,
|
||||
add: (toast) =>
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
const zu = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create = (createState) => {
|
||||
const store = zu.create(createState);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
import type { StateCreator } from 'zustand';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
const { create: actualCreate } = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set<() => void>();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create =
|
||||
() =>
|
||||
<S>(createState: StateCreator<S>) => {
|
||||
const store = actualCreate(createState);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
@@ -8,8 +8,11 @@ import {
|
||||
import type { MockedResponse } from '@apollo/client/testing';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { VegaWalletProvider } from '../provider';
|
||||
import { VegaConnectDialog, CLOSE_DELAY } from './connect-dialog';
|
||||
import type { VegaWalletDialogStore } from './connect-dialog';
|
||||
import {
|
||||
VegaConnectDialog,
|
||||
CLOSE_DELAY,
|
||||
useVegaWalletDialogStore,
|
||||
} from './connect-dialog';
|
||||
import type { VegaConnectDialogProps } from '..';
|
||||
import {
|
||||
ClientErrors,
|
||||
@@ -24,11 +27,6 @@ import { ChainIdDocument } from '@vegaprotocol/react-helpers';
|
||||
|
||||
const mockUpdateDialogOpen = jest.fn();
|
||||
const mockCloseVegaDialog = jest.fn();
|
||||
const mockStoreObj: Partial<VegaWalletDialogStore> = {
|
||||
updateVegaWalletDialog: mockUpdateDialogOpen,
|
||||
closeVegaWalletDialog: mockCloseVegaDialog,
|
||||
vegaWalletDialogOpen: true,
|
||||
};
|
||||
|
||||
jest.mock('@vegaprotocol/environment');
|
||||
|
||||
@@ -44,11 +42,6 @@ useEnvironment.mockImplementation(() => ({
|
||||
HOSTED_WALLET_URL: mockHostedWalletUrl,
|
||||
}));
|
||||
|
||||
jest.mock('zustand', () => ({
|
||||
create: () => (storeGetter: (store: VegaWalletDialogStore) => unknown) =>
|
||||
storeGetter(mockStoreObj as VegaWalletDialogStore),
|
||||
}));
|
||||
|
||||
let defaultProps: VegaConnectDialogProps;
|
||||
|
||||
const INITIAL_KEY = 'some-key';
|
||||
@@ -66,6 +59,12 @@ beforeEach(() => {
|
||||
defaultProps = {
|
||||
connectors,
|
||||
};
|
||||
|
||||
useVegaWalletDialogStore.setState({
|
||||
updateVegaWalletDialog: mockUpdateDialogOpen,
|
||||
closeVegaWalletDialog: mockCloseVegaDialog,
|
||||
vegaWalletDialogOpen: true,
|
||||
});
|
||||
});
|
||||
|
||||
const mockVegaWalletUrl = 'http://mock.wallet.com';
|
||||
|
||||
@@ -37,7 +37,7 @@ export interface VegaConnectDialogProps {
|
||||
onChangeOpen?: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export const useVegaWalletDialogStore = create<VegaWalletDialogStore>(
|
||||
export const useVegaWalletDialogStore = create<VegaWalletDialogStore>()(
|
||||
(set) => ({
|
||||
vegaWalletDialogOpen: false,
|
||||
updateVegaWalletDialog: (open: boolean) =>
|
||||
|
||||
@@ -52,8 +52,8 @@ export interface VegaTransactionStore {
|
||||
) => void;
|
||||
}
|
||||
|
||||
export const useVegaTransactionStore = create(
|
||||
subscribeWithSelector<VegaTransactionStore>((set, get) => ({
|
||||
export const useVegaTransactionStore = create<VegaTransactionStore>()(
|
||||
subscribeWithSelector((set, get) => ({
|
||||
transactions: [] as VegaStoredTxState[],
|
||||
create: (body: Transaction, order?: OrderTxUpdateFieldsFragment) => {
|
||||
const transactions = get().transactions;
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"**/*.test.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.jsx",
|
||||
"jest.config.ts"
|
||||
"jest.config.ts",
|
||||
"__mocks__"
|
||||
],
|
||||
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import { act } from '@testing-library/react';
|
||||
const zu = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create = (createState) => {
|
||||
let store;
|
||||
if (typeof createState === 'function') {
|
||||
store = zu.create(createState);
|
||||
} else {
|
||||
store = (selector, equalityFn) =>
|
||||
zu.useStore(createState, selector, equalityFn);
|
||||
Object.assign(store, createState);
|
||||
}
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
|
||||
export default create;
|
||||
@@ -0,0 +1,24 @@
|
||||
import type { StateCreator } from 'zustand';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
const { create: actualCreate } = jest.requireActual('zustand'); // if using jest
|
||||
|
||||
// a variable to hold reset functions for all stores declared in the app
|
||||
const storeResetFns = new Set<() => void>();
|
||||
|
||||
// when creating a store, we get its initial state, create a reset function and add it in the set
|
||||
export const create =
|
||||
() =>
|
||||
<S>(createState: StateCreator<S>) => {
|
||||
const store = actualCreate(createState);
|
||||
const initialState = store.getState();
|
||||
storeResetFns.add(() => store.setState(initialState, true));
|
||||
return store;
|
||||
};
|
||||
|
||||
// Reset all stores after each test run
|
||||
beforeEach(() => {
|
||||
act(() => storeResetFns.forEach((resetFn) => resetFn()));
|
||||
});
|
||||
|
||||
// also export default as web3-react internals import and use zustand as the default import
|
||||
export default create;
|
||||
@@ -55,8 +55,8 @@ export interface EthTransactionStore {
|
||||
delete: (index: number) => void;
|
||||
}
|
||||
|
||||
export const useEthTransactionStore = create(
|
||||
subscribeWithSelector<EthTransactionStore>((set, get) => ({
|
||||
export const useEthTransactionStore = create<EthTransactionStore>()(
|
||||
subscribeWithSelector((set, get) => ({
|
||||
transactions: [] as EthStoredTxState[],
|
||||
create: (
|
||||
contract: Contract | null,
|
||||
|
||||
@@ -49,8 +49,8 @@ export interface EthWithdrawApprovalStore {
|
||||
delete: (index: number) => void;
|
||||
}
|
||||
|
||||
export const useEthWithdrawApprovalsStore = create(
|
||||
subscribeWithSelector<EthWithdrawApprovalStore>((set, get) => ({
|
||||
export const useEthWithdrawApprovalsStore = create<EthWithdrawApprovalStore>()(
|
||||
subscribeWithSelector((set, get) => ({
|
||||
transactions: [] as EthWithdrawalApprovalState[],
|
||||
create: (
|
||||
withdrawal: EthWithdrawalApprovalState['withdrawal'],
|
||||
|
||||
@@ -13,7 +13,7 @@ interface Actions {
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export const useWeb3ConnectStore = create<State & Actions>((set) => ({
|
||||
export const useWeb3ConnectStore = create<State & Actions>()((set) => ({
|
||||
isOpen: false,
|
||||
connectors: [],
|
||||
initialize: (connectors, desiredChainId) => {
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
"**/*.test.js",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.test.jsx",
|
||||
"jest.config.ts"
|
||||
"jest.config.ts",
|
||||
"__mocks__"
|
||||
],
|
||||
"include": ["**/*.js", "**/*.jsx", "**/*.ts", "**/*.tsx"]
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export interface WithdrawStore {
|
||||
update: (state: Partial<WithdrawStore>) => void;
|
||||
}
|
||||
|
||||
export const useWithdrawStore = create<WithdrawStore>((set) => ({
|
||||
export const useWithdrawStore = create<WithdrawStore>()((set) => ({
|
||||
asset: undefined,
|
||||
balance: new BigNumber(0),
|
||||
min: new BigNumber(0),
|
||||
|
||||
@@ -17,7 +17,7 @@ interface Actions {
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export const useWithdrawalDialog = create<State & Actions>((set) => ({
|
||||
export const useWithdrawalDialog = create<State & Actions>()((set) => ({
|
||||
isOpen: false,
|
||||
assetId: undefined,
|
||||
open: (assetId) => set(() => ({ assetId, isOpen: true })),
|
||||
|
||||
Reference in New Issue
Block a user