@ecency/wallets 1.5.29 → 1.5.30
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/browser/index.d.ts +15 -1650
- package/dist/browser/index.js +60 -3055
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.cjs +312 -3217
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.mjs +60 -3053
- package/dist/node/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/node/index.cjs
CHANGED
|
@@ -14,9 +14,6 @@ var cryptoLib = require('@okxweb3/crypto-lib');
|
|
|
14
14
|
var dhive = require('@hiveio/dhive');
|
|
15
15
|
var crypto = require('@hiveio/dhive/lib/crypto');
|
|
16
16
|
var memo = require('@hiveio/dhive/lib/memo');
|
|
17
|
-
var dayjs = require('dayjs');
|
|
18
|
-
var hs = require('hivesigner');
|
|
19
|
-
var numeral = require('numeral');
|
|
20
17
|
var R = require('remeda');
|
|
21
18
|
|
|
22
19
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -40,9 +37,6 @@ function _interopNamespace(e) {
|
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
var bip39__default = /*#__PURE__*/_interopDefault(bip39);
|
|
43
|
-
var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
|
|
44
|
-
var hs__default = /*#__PURE__*/_interopDefault(hs);
|
|
45
|
-
var numeral__default = /*#__PURE__*/_interopDefault(numeral);
|
|
46
40
|
var R__namespace = /*#__PURE__*/_interopNamespace(R);
|
|
47
41
|
|
|
48
42
|
var __defProp = Object.defineProperty;
|
|
@@ -609,2326 +603,6 @@ function useHiveKeysQuery(username) {
|
|
|
609
603
|
}
|
|
610
604
|
});
|
|
611
605
|
}
|
|
612
|
-
|
|
613
|
-
// src/modules/assets/utils/parse-asset.ts
|
|
614
|
-
var Symbol2 = /* @__PURE__ */ ((Symbol3) => {
|
|
615
|
-
Symbol3["HIVE"] = "HIVE";
|
|
616
|
-
Symbol3["HBD"] = "HBD";
|
|
617
|
-
Symbol3["VESTS"] = "VESTS";
|
|
618
|
-
Symbol3["SPK"] = "SPK";
|
|
619
|
-
return Symbol3;
|
|
620
|
-
})(Symbol2 || {});
|
|
621
|
-
var NaiMap = /* @__PURE__ */ ((NaiMap2) => {
|
|
622
|
-
NaiMap2["@@000000021"] = "HIVE";
|
|
623
|
-
NaiMap2["@@000000013"] = "HBD";
|
|
624
|
-
NaiMap2["@@000000037"] = "VESTS";
|
|
625
|
-
return NaiMap2;
|
|
626
|
-
})(NaiMap || {});
|
|
627
|
-
function parseAsset(sval) {
|
|
628
|
-
if (typeof sval === "string") {
|
|
629
|
-
const sp = sval.split(" ");
|
|
630
|
-
return {
|
|
631
|
-
amount: parseFloat(sp[0]),
|
|
632
|
-
// @ts-ignore
|
|
633
|
-
symbol: Symbol2[sp[1]]
|
|
634
|
-
};
|
|
635
|
-
} else {
|
|
636
|
-
return {
|
|
637
|
-
amount: parseFloat(sval.amount.toString()) / Math.pow(10, sval.precision),
|
|
638
|
-
// @ts-ignore
|
|
639
|
-
symbol: NaiMap[sval.nai]
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
// src/modules/assets/utils/is-empty-date.ts
|
|
645
|
-
function isEmptyDate(s) {
|
|
646
|
-
if (s === void 0) {
|
|
647
|
-
return true;
|
|
648
|
-
}
|
|
649
|
-
return parseInt(s.split("-")[0], 10) < 1980;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
// src/modules/assets/utils/vests-to-hp.ts
|
|
653
|
-
function vestsToHp(vests, hivePerMVests) {
|
|
654
|
-
return vests / 1e6 * hivePerMVests;
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
// src/modules/assets/utils/reward-spk.ts
|
|
658
|
-
function rewardSpk(data, sstats) {
|
|
659
|
-
let a = 0, b = 0, c = 0, t = 0, diff = data.head_block - data.spk_block;
|
|
660
|
-
if (!data.spk_block) {
|
|
661
|
-
return 0;
|
|
662
|
-
} else if (diff < 28800) {
|
|
663
|
-
return 0;
|
|
664
|
-
} else {
|
|
665
|
-
t = diff / 28800;
|
|
666
|
-
a = data.gov ? simpleInterest(data.gov, t, sstats.spk_rate_lgov) : 0;
|
|
667
|
-
b = data.pow ? simpleInterest(data.pow, t, sstats.spk_rate_lpow) : 0;
|
|
668
|
-
c = simpleInterest(
|
|
669
|
-
(data.granted.t > 0 ? data.granted.t : 0) + (data.granting.t && data.granting.t > 0 ? data.granting.t : 0),
|
|
670
|
-
t,
|
|
671
|
-
sstats.spk_rate_ldel
|
|
672
|
-
);
|
|
673
|
-
const i = a + b + c;
|
|
674
|
-
if (i) {
|
|
675
|
-
return i;
|
|
676
|
-
} else {
|
|
677
|
-
return 0;
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
function simpleInterest(p, t2, r) {
|
|
681
|
-
const amount = p * (1 + r / 365);
|
|
682
|
-
const interest = amount - p;
|
|
683
|
-
return interest * t2;
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
// src/internal/hive-auth.ts
|
|
688
|
-
var broadcastHandler = null;
|
|
689
|
-
function registerHiveAuthBroadcastHandler(handler) {
|
|
690
|
-
broadcastHandler = handler;
|
|
691
|
-
}
|
|
692
|
-
function getHiveAuthBroadcastHandler() {
|
|
693
|
-
return broadcastHandler;
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
// src/modules/assets/utils/hive-auth.ts
|
|
697
|
-
function registerWalletHiveAuthBroadcast(handler) {
|
|
698
|
-
registerHiveAuthBroadcastHandler(handler);
|
|
699
|
-
}
|
|
700
|
-
function broadcastWithWalletHiveAuth(username, operations, keyType) {
|
|
701
|
-
const handler = getHiveAuthBroadcastHandler();
|
|
702
|
-
if (!handler) {
|
|
703
|
-
throw new Error("HiveAuth broadcast handler is not registered");
|
|
704
|
-
}
|
|
705
|
-
return handler(username, operations, keyType);
|
|
706
|
-
}
|
|
707
|
-
function hasWalletHiveAuthBroadcast() {
|
|
708
|
-
return typeof getHiveAuthBroadcastHandler() === "function";
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
// src/modules/assets/hive/queries/get-hive-asset-general-info-query-options.ts
|
|
712
|
-
function getHiveAssetGeneralInfoQueryOptions(username) {
|
|
713
|
-
return reactQuery.queryOptions({
|
|
714
|
-
queryKey: ["assets", "hive", "general-info", username],
|
|
715
|
-
staleTime: 6e4,
|
|
716
|
-
refetchInterval: 9e4,
|
|
717
|
-
queryFn: async () => {
|
|
718
|
-
await sdk.getQueryClient().prefetchQuery(sdk.getDynamicPropsQueryOptions());
|
|
719
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
720
|
-
sdk.getAccountFullQueryOptions(username)
|
|
721
|
-
);
|
|
722
|
-
const dynamicProps = sdk.getQueryClient().getQueryData(
|
|
723
|
-
sdk.getDynamicPropsQueryOptions().queryKey
|
|
724
|
-
);
|
|
725
|
-
const accountData = sdk.getQueryClient().getQueryData(
|
|
726
|
-
sdk.getAccountFullQueryOptions(username).queryKey
|
|
727
|
-
);
|
|
728
|
-
const marketTicker = await sdk.CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
|
|
729
|
-
const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
|
|
730
|
-
if (!accountData) {
|
|
731
|
-
return {
|
|
732
|
-
name: "HIVE",
|
|
733
|
-
title: "Hive",
|
|
734
|
-
price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
|
|
735
|
-
accountBalance: 0
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
const liquidBalance = parseAsset(accountData.balance).amount;
|
|
739
|
-
const savingsBalance = parseAsset(accountData.savings_balance).amount;
|
|
740
|
-
return {
|
|
741
|
-
name: "HIVE",
|
|
742
|
-
title: "Hive",
|
|
743
|
-
price: Number.isFinite(marketPrice) ? marketPrice : dynamicProps ? dynamicProps.base / dynamicProps.quote : 0,
|
|
744
|
-
accountBalance: liquidBalance + savingsBalance,
|
|
745
|
-
parts: [
|
|
746
|
-
{
|
|
747
|
-
name: "current",
|
|
748
|
-
balance: liquidBalance
|
|
749
|
-
},
|
|
750
|
-
{
|
|
751
|
-
name: "savings",
|
|
752
|
-
balance: savingsBalance
|
|
753
|
-
}
|
|
754
|
-
]
|
|
755
|
-
};
|
|
756
|
-
}
|
|
757
|
-
});
|
|
758
|
-
}
|
|
759
|
-
function getAPR(dynamicProps) {
|
|
760
|
-
const initialInflationRate = 9.5;
|
|
761
|
-
const initialBlock = 7e6;
|
|
762
|
-
const decreaseRate = 25e4;
|
|
763
|
-
const decreasePercentPerIncrement = 0.01;
|
|
764
|
-
const headBlock = dynamicProps.headBlock;
|
|
765
|
-
const deltaBlocks = headBlock - initialBlock;
|
|
766
|
-
const decreaseIncrements = deltaBlocks / decreaseRate;
|
|
767
|
-
let currentInflationRate = initialInflationRate - decreaseIncrements * decreasePercentPerIncrement;
|
|
768
|
-
if (currentInflationRate < 0.95) {
|
|
769
|
-
currentInflationRate = 0.95;
|
|
770
|
-
}
|
|
771
|
-
const vestingRewardPercent = dynamicProps.vestingRewardPercent / 1e4;
|
|
772
|
-
const virtualSupply = dynamicProps.virtualSupply;
|
|
773
|
-
const totalVestingFunds = dynamicProps.totalVestingFund;
|
|
774
|
-
return (virtualSupply * currentInflationRate * vestingRewardPercent / totalVestingFunds).toFixed(3);
|
|
775
|
-
}
|
|
776
|
-
function getHivePowerAssetGeneralInfoQueryOptions(username) {
|
|
777
|
-
return reactQuery.queryOptions({
|
|
778
|
-
queryKey: ["assets", "hive-power", "general-info", username],
|
|
779
|
-
staleTime: 6e4,
|
|
780
|
-
refetchInterval: 9e4,
|
|
781
|
-
queryFn: async () => {
|
|
782
|
-
await sdk.getQueryClient().prefetchQuery(sdk.getDynamicPropsQueryOptions());
|
|
783
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
784
|
-
sdk.getAccountFullQueryOptions(username)
|
|
785
|
-
);
|
|
786
|
-
const dynamicProps = sdk.getQueryClient().getQueryData(
|
|
787
|
-
sdk.getDynamicPropsQueryOptions().queryKey
|
|
788
|
-
);
|
|
789
|
-
const accountData = sdk.getQueryClient().getQueryData(
|
|
790
|
-
sdk.getAccountFullQueryOptions(username).queryKey
|
|
791
|
-
);
|
|
792
|
-
if (!dynamicProps || !accountData) {
|
|
793
|
-
return {
|
|
794
|
-
name: "HP",
|
|
795
|
-
title: "Hive Power",
|
|
796
|
-
price: 0,
|
|
797
|
-
accountBalance: 0
|
|
798
|
-
};
|
|
799
|
-
}
|
|
800
|
-
const marketTicker = await sdk.CONFIG.hiveClient.call("condenser_api", "get_ticker", []).catch(() => void 0);
|
|
801
|
-
const marketPrice = Number.parseFloat(marketTicker?.latest ?? "");
|
|
802
|
-
const price = Number.isFinite(marketPrice) ? marketPrice : dynamicProps.base / dynamicProps.quote;
|
|
803
|
-
const vestingShares = parseAsset(accountData.vesting_shares).amount;
|
|
804
|
-
const delegatedVests = parseAsset(accountData.delegated_vesting_shares).amount;
|
|
805
|
-
const receivedVests = parseAsset(accountData.received_vesting_shares).amount;
|
|
806
|
-
const withdrawRateVests = parseAsset(accountData.vesting_withdraw_rate).amount;
|
|
807
|
-
const remainingToWithdrawVests = Math.max(
|
|
808
|
-
(Number(accountData.to_withdraw) - Number(accountData.withdrawn)) / 1e6,
|
|
809
|
-
0
|
|
810
|
-
);
|
|
811
|
-
const nextWithdrawalVests = !isEmptyDate(accountData.next_vesting_withdrawal) ? Math.min(withdrawRateVests, remainingToWithdrawVests) : 0;
|
|
812
|
-
const hpBalance = +vestsToHp(
|
|
813
|
-
vestingShares,
|
|
814
|
-
dynamicProps.hivePerMVests
|
|
815
|
-
).toFixed(3);
|
|
816
|
-
const outgoingDelegationsHp = +vestsToHp(
|
|
817
|
-
delegatedVests,
|
|
818
|
-
dynamicProps.hivePerMVests
|
|
819
|
-
).toFixed(3);
|
|
820
|
-
const incomingDelegationsHp = +vestsToHp(
|
|
821
|
-
receivedVests,
|
|
822
|
-
dynamicProps.hivePerMVests
|
|
823
|
-
).toFixed(3);
|
|
824
|
-
const pendingPowerDownHp = +vestsToHp(
|
|
825
|
-
remainingToWithdrawVests,
|
|
826
|
-
dynamicProps.hivePerMVests
|
|
827
|
-
).toFixed(3);
|
|
828
|
-
const nextPowerDownHp = +vestsToHp(
|
|
829
|
-
nextWithdrawalVests,
|
|
830
|
-
dynamicProps.hivePerMVests
|
|
831
|
-
).toFixed(3);
|
|
832
|
-
const totalBalance = Math.max(hpBalance - pendingPowerDownHp, 0);
|
|
833
|
-
const availableHp = Math.max(
|
|
834
|
-
// Owned HP minus the portions already delegated away.
|
|
835
|
-
hpBalance - outgoingDelegationsHp,
|
|
836
|
-
0
|
|
837
|
-
);
|
|
838
|
-
return {
|
|
839
|
-
name: "HP",
|
|
840
|
-
title: "Hive Power",
|
|
841
|
-
price,
|
|
842
|
-
accountBalance: +totalBalance.toFixed(3),
|
|
843
|
-
apr: getAPR(dynamicProps),
|
|
844
|
-
parts: [
|
|
845
|
-
{
|
|
846
|
-
name: "hp_balance",
|
|
847
|
-
balance: hpBalance
|
|
848
|
-
},
|
|
849
|
-
{
|
|
850
|
-
name: "available",
|
|
851
|
-
balance: +availableHp.toFixed(3)
|
|
852
|
-
},
|
|
853
|
-
{
|
|
854
|
-
name: "outgoing_delegations",
|
|
855
|
-
balance: outgoingDelegationsHp
|
|
856
|
-
},
|
|
857
|
-
{
|
|
858
|
-
name: "incoming_delegations",
|
|
859
|
-
balance: incomingDelegationsHp
|
|
860
|
-
},
|
|
861
|
-
...pendingPowerDownHp > 0 ? [
|
|
862
|
-
{
|
|
863
|
-
name: "pending_power_down",
|
|
864
|
-
balance: +pendingPowerDownHp.toFixed(3)
|
|
865
|
-
}
|
|
866
|
-
] : [],
|
|
867
|
-
...nextPowerDownHp > 0 && nextPowerDownHp !== pendingPowerDownHp ? [
|
|
868
|
-
{
|
|
869
|
-
name: "next_power_down",
|
|
870
|
-
balance: +nextPowerDownHp.toFixed(3)
|
|
871
|
-
}
|
|
872
|
-
] : []
|
|
873
|
-
]
|
|
874
|
-
};
|
|
875
|
-
}
|
|
876
|
-
});
|
|
877
|
-
}
|
|
878
|
-
function getHbdAssetGeneralInfoQueryOptions(username) {
|
|
879
|
-
return reactQuery.queryOptions({
|
|
880
|
-
queryKey: ["assets", "hbd", "general-info", username],
|
|
881
|
-
staleTime: 6e4,
|
|
882
|
-
refetchInterval: 9e4,
|
|
883
|
-
queryFn: async () => {
|
|
884
|
-
await sdk.getQueryClient().prefetchQuery(sdk.getDynamicPropsQueryOptions());
|
|
885
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
886
|
-
sdk.getAccountFullQueryOptions(username)
|
|
887
|
-
);
|
|
888
|
-
const accountData = sdk.getQueryClient().getQueryData(
|
|
889
|
-
sdk.getAccountFullQueryOptions(username).queryKey
|
|
890
|
-
);
|
|
891
|
-
const dynamicProps = sdk.getQueryClient().getQueryData(
|
|
892
|
-
sdk.getDynamicPropsQueryOptions().queryKey
|
|
893
|
-
);
|
|
894
|
-
let price = 1;
|
|
895
|
-
try {
|
|
896
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
897
|
-
getTokenPriceQueryOptions("HBD")
|
|
898
|
-
);
|
|
899
|
-
const marketPrice = sdk.CONFIG.queryClient.getQueryData(
|
|
900
|
-
getTokenPriceQueryOptions("HBD").queryKey
|
|
901
|
-
) ?? 0;
|
|
902
|
-
if (typeof marketPrice === "number" && Number.isFinite(marketPrice)) {
|
|
903
|
-
price = marketPrice;
|
|
904
|
-
}
|
|
905
|
-
} catch {
|
|
906
|
-
}
|
|
907
|
-
if (!accountData) {
|
|
908
|
-
return {
|
|
909
|
-
name: "HBD",
|
|
910
|
-
title: "Hive Dollar",
|
|
911
|
-
price,
|
|
912
|
-
accountBalance: 0
|
|
913
|
-
};
|
|
914
|
-
}
|
|
915
|
-
return {
|
|
916
|
-
name: "HBD",
|
|
917
|
-
title: "Hive Dollar",
|
|
918
|
-
price,
|
|
919
|
-
accountBalance: parseAsset(accountData.hbd_balance).amount + parseAsset(accountData?.savings_hbd_balance).amount,
|
|
920
|
-
apr: ((dynamicProps?.hbdInterestRate ?? 0) / 100).toFixed(3),
|
|
921
|
-
parts: [
|
|
922
|
-
{
|
|
923
|
-
name: "current",
|
|
924
|
-
balance: parseAsset(accountData.hbd_balance).amount
|
|
925
|
-
},
|
|
926
|
-
{
|
|
927
|
-
name: "savings",
|
|
928
|
-
balance: parseAsset(accountData.savings_hbd_balance).amount
|
|
929
|
-
}
|
|
930
|
-
]
|
|
931
|
-
};
|
|
932
|
-
}
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
var ops = dhive.utils.operationOrders;
|
|
936
|
-
var HIVE_ACCOUNT_OPERATION_GROUPS = {
|
|
937
|
-
transfers: [
|
|
938
|
-
ops.transfer,
|
|
939
|
-
ops.transfer_to_savings,
|
|
940
|
-
ops.transfer_from_savings,
|
|
941
|
-
ops.cancel_transfer_from_savings,
|
|
942
|
-
ops.recurrent_transfer,
|
|
943
|
-
ops.fill_recurrent_transfer,
|
|
944
|
-
ops.escrow_transfer,
|
|
945
|
-
ops.fill_recurrent_transfer
|
|
946
|
-
],
|
|
947
|
-
"market-orders": [
|
|
948
|
-
ops.fill_convert_request,
|
|
949
|
-
ops.fill_order,
|
|
950
|
-
ops.fill_collateralized_convert_request,
|
|
951
|
-
ops.limit_order_create2,
|
|
952
|
-
ops.limit_order_create,
|
|
953
|
-
ops.limit_order_cancel
|
|
954
|
-
],
|
|
955
|
-
interests: [ops.interest],
|
|
956
|
-
"stake-operations": [
|
|
957
|
-
ops.return_vesting_delegation,
|
|
958
|
-
ops.withdraw_vesting,
|
|
959
|
-
ops.transfer_to_vesting,
|
|
960
|
-
ops.set_withdraw_vesting_route,
|
|
961
|
-
ops.update_proposal_votes,
|
|
962
|
-
ops.fill_vesting_withdraw,
|
|
963
|
-
ops.account_witness_proxy,
|
|
964
|
-
ops.delegate_vesting_shares
|
|
965
|
-
],
|
|
966
|
-
rewards: [
|
|
967
|
-
ops.author_reward,
|
|
968
|
-
ops.curation_reward,
|
|
969
|
-
ops.producer_reward,
|
|
970
|
-
ops.claim_reward_balance,
|
|
971
|
-
ops.comment_benefactor_reward,
|
|
972
|
-
ops.liquidity_reward,
|
|
973
|
-
ops.proposal_pay
|
|
974
|
-
],
|
|
975
|
-
"": []
|
|
976
|
-
};
|
|
977
|
-
var HIVE_OPERATION_LIST = Object.keys(
|
|
978
|
-
dhive.utils.operationOrders
|
|
979
|
-
);
|
|
980
|
-
var operationOrders = dhive.utils.operationOrders;
|
|
981
|
-
var HIVE_OPERATION_ORDERS = operationOrders;
|
|
982
|
-
var HIVE_OPERATION_NAME_BY_ID = Object.entries(operationOrders).reduce((acc, [name, id]) => {
|
|
983
|
-
acc[id] = name;
|
|
984
|
-
return acc;
|
|
985
|
-
}, {});
|
|
986
|
-
|
|
987
|
-
// src/modules/assets/hive/queries/get-hive-asset-transactions-query-options.ts
|
|
988
|
-
var operationOrders2 = dhive.utils.operationOrders;
|
|
989
|
-
function isHiveOperationName(value) {
|
|
990
|
-
return Object.prototype.hasOwnProperty.call(operationOrders2, value);
|
|
991
|
-
}
|
|
992
|
-
function resolveHiveOperationFilters(filters) {
|
|
993
|
-
const rawValues = Array.isArray(filters) ? filters : [filters];
|
|
994
|
-
const hasAll = rawValues.includes("");
|
|
995
|
-
const uniqueValues = Array.from(
|
|
996
|
-
new Set(
|
|
997
|
-
rawValues.filter(
|
|
998
|
-
(value) => value !== void 0 && value !== null && value !== ""
|
|
999
|
-
)
|
|
1000
|
-
)
|
|
1001
|
-
);
|
|
1002
|
-
const filterKey = hasAll || uniqueValues.length === 0 ? "all" : uniqueValues.map((value) => value.toString()).sort().join("|");
|
|
1003
|
-
const operationIds = /* @__PURE__ */ new Set();
|
|
1004
|
-
if (!hasAll) {
|
|
1005
|
-
uniqueValues.forEach((value) => {
|
|
1006
|
-
if (value in HIVE_ACCOUNT_OPERATION_GROUPS) {
|
|
1007
|
-
HIVE_ACCOUNT_OPERATION_GROUPS[value].forEach(
|
|
1008
|
-
(id) => operationIds.add(id)
|
|
1009
|
-
);
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
if (isHiveOperationName(value)) {
|
|
1013
|
-
operationIds.add(operationOrders2[value]);
|
|
1014
|
-
}
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
const filterArgs = makeBitMaskFilter(Array.from(operationIds));
|
|
1018
|
-
return {
|
|
1019
|
-
filterKey,
|
|
1020
|
-
filterArgs
|
|
1021
|
-
};
|
|
1022
|
-
}
|
|
1023
|
-
function makeBitMaskFilter(allowedOperations) {
|
|
1024
|
-
let low = 0n;
|
|
1025
|
-
let high = 0n;
|
|
1026
|
-
allowedOperations.forEach((operation) => {
|
|
1027
|
-
if (operation < 64) {
|
|
1028
|
-
low |= 1n << BigInt(operation);
|
|
1029
|
-
} else {
|
|
1030
|
-
high |= 1n << BigInt(operation - 64);
|
|
1031
|
-
}
|
|
1032
|
-
});
|
|
1033
|
-
return [low !== 0n ? low.toString() : null, high !== 0n ? high.toString() : null];
|
|
1034
|
-
}
|
|
1035
|
-
function getHiveAssetTransactionsQueryOptions(username, limit = 20, filters = []) {
|
|
1036
|
-
const { filterArgs, filterKey } = resolveHiveOperationFilters(filters);
|
|
1037
|
-
return reactQuery.infiniteQueryOptions({
|
|
1038
|
-
queryKey: ["assets", "hive", "transactions", username, limit, filterKey],
|
|
1039
|
-
initialData: { pages: [], pageParams: [] },
|
|
1040
|
-
initialPageParam: -1,
|
|
1041
|
-
getNextPageParam: (lastPage, __) => lastPage ? +(lastPage[lastPage.length - 1]?.num ?? 0) - 1 : -1,
|
|
1042
|
-
queryFn: async ({ pageParam }) => {
|
|
1043
|
-
const response = await sdk.CONFIG.hiveClient.call(
|
|
1044
|
-
"condenser_api",
|
|
1045
|
-
"get_account_history",
|
|
1046
|
-
[username, pageParam, limit, ...filterArgs]
|
|
1047
|
-
);
|
|
1048
|
-
return response.map(
|
|
1049
|
-
(x) => ({
|
|
1050
|
-
num: x[0],
|
|
1051
|
-
type: x[1].op[0],
|
|
1052
|
-
timestamp: x[1].timestamp,
|
|
1053
|
-
trx_id: x[1].trx_id,
|
|
1054
|
-
...x[1].op[1]
|
|
1055
|
-
})
|
|
1056
|
-
);
|
|
1057
|
-
},
|
|
1058
|
-
select: ({ pages, pageParams }) => ({
|
|
1059
|
-
pageParams,
|
|
1060
|
-
pages: pages.map(
|
|
1061
|
-
(page) => page.filter((item) => {
|
|
1062
|
-
switch (item.type) {
|
|
1063
|
-
case "author_reward":
|
|
1064
|
-
case "comment_benefactor_reward":
|
|
1065
|
-
const hivePayout = parseAsset(item.hive_payout);
|
|
1066
|
-
return hivePayout.amount > 0;
|
|
1067
|
-
case "transfer":
|
|
1068
|
-
case "transfer_to_savings":
|
|
1069
|
-
case "transfer_to_vesting":
|
|
1070
|
-
case "recurrent_transfer":
|
|
1071
|
-
return parseAsset(item.amount).symbol === "HIVE";
|
|
1072
|
-
case "transfer_from_savings":
|
|
1073
|
-
return parseAsset(item.amount).symbol === "HIVE";
|
|
1074
|
-
case "fill_recurrent_transfer":
|
|
1075
|
-
const asset = parseAsset(item.amount);
|
|
1076
|
-
return ["HIVE"].includes(asset.symbol);
|
|
1077
|
-
case "claim_reward_balance":
|
|
1078
|
-
const rewardHive = parseAsset(
|
|
1079
|
-
item.reward_hive
|
|
1080
|
-
);
|
|
1081
|
-
return rewardHive.amount > 0;
|
|
1082
|
-
case "curation_reward":
|
|
1083
|
-
case "cancel_transfer_from_savings":
|
|
1084
|
-
case "fill_order":
|
|
1085
|
-
case "limit_order_create":
|
|
1086
|
-
case "limit_order_cancel":
|
|
1087
|
-
case "fill_convert_request":
|
|
1088
|
-
case "fill_collateralized_convert_request":
|
|
1089
|
-
return true;
|
|
1090
|
-
case "limit_order_create2":
|
|
1091
|
-
return true;
|
|
1092
|
-
default:
|
|
1093
|
-
return false;
|
|
1094
|
-
}
|
|
1095
|
-
})
|
|
1096
|
-
)
|
|
1097
|
-
})
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
function getHivePowerAssetTransactionsQueryOptions(username, limit = 20, filters = []) {
|
|
1101
|
-
const { filterKey } = resolveHiveOperationFilters(filters);
|
|
1102
|
-
const userSelectedOperations = new Set(
|
|
1103
|
-
Array.isArray(filters) ? filters : [filters]
|
|
1104
|
-
);
|
|
1105
|
-
const hasAllFilter = userSelectedOperations.has("") || userSelectedOperations.size === 0;
|
|
1106
|
-
return reactQuery.infiniteQueryOptions({
|
|
1107
|
-
...getHiveAssetTransactionsQueryOptions(username, limit, filters),
|
|
1108
|
-
queryKey: [
|
|
1109
|
-
"assets",
|
|
1110
|
-
"hive-power",
|
|
1111
|
-
"transactions",
|
|
1112
|
-
username,
|
|
1113
|
-
limit,
|
|
1114
|
-
filterKey
|
|
1115
|
-
],
|
|
1116
|
-
select: ({ pages, pageParams }) => ({
|
|
1117
|
-
pageParams,
|
|
1118
|
-
pages: pages.map(
|
|
1119
|
-
(page) => page.filter((item) => {
|
|
1120
|
-
switch (item.type) {
|
|
1121
|
-
case "author_reward":
|
|
1122
|
-
case "comment_benefactor_reward":
|
|
1123
|
-
const vestingPayout = parseAsset(
|
|
1124
|
-
item.vesting_payout
|
|
1125
|
-
);
|
|
1126
|
-
return vestingPayout.amount > 0;
|
|
1127
|
-
case "claim_reward_balance":
|
|
1128
|
-
const rewardVests = parseAsset(
|
|
1129
|
-
item.reward_vests
|
|
1130
|
-
);
|
|
1131
|
-
return rewardVests.amount > 0;
|
|
1132
|
-
case "transfer_to_vesting":
|
|
1133
|
-
return true;
|
|
1134
|
-
case "transfer":
|
|
1135
|
-
case "transfer_to_savings":
|
|
1136
|
-
case "recurrent_transfer":
|
|
1137
|
-
return ["VESTS", "HP"].includes(
|
|
1138
|
-
parseAsset(item.amount).symbol
|
|
1139
|
-
);
|
|
1140
|
-
case "fill_recurrent_transfer":
|
|
1141
|
-
const asset = parseAsset(item.amount);
|
|
1142
|
-
return ["VESTS", "HP"].includes(asset.symbol);
|
|
1143
|
-
case "curation_reward":
|
|
1144
|
-
case "withdraw_vesting":
|
|
1145
|
-
case "delegate_vesting_shares":
|
|
1146
|
-
case "fill_vesting_withdraw":
|
|
1147
|
-
case "return_vesting_delegation":
|
|
1148
|
-
case "producer_reward":
|
|
1149
|
-
case "set_withdraw_vesting_route":
|
|
1150
|
-
return true;
|
|
1151
|
-
default:
|
|
1152
|
-
return hasAllFilter || userSelectedOperations.has(item.type);
|
|
1153
|
-
}
|
|
1154
|
-
})
|
|
1155
|
-
)
|
|
1156
|
-
})
|
|
1157
|
-
});
|
|
1158
|
-
}
|
|
1159
|
-
function getHbdAssetTransactionsQueryOptions(username, limit = 20, filters = []) {
|
|
1160
|
-
const { filterKey } = resolveHiveOperationFilters(filters);
|
|
1161
|
-
return reactQuery.infiniteQueryOptions({
|
|
1162
|
-
...getHiveAssetTransactionsQueryOptions(username, limit, filters),
|
|
1163
|
-
queryKey: ["assets", "hbd", "transactions", username, limit, filterKey],
|
|
1164
|
-
select: ({ pages, pageParams }) => ({
|
|
1165
|
-
pageParams,
|
|
1166
|
-
pages: pages.map(
|
|
1167
|
-
(page) => page.filter((item) => {
|
|
1168
|
-
switch (item.type) {
|
|
1169
|
-
case "author_reward":
|
|
1170
|
-
case "comment_benefactor_reward":
|
|
1171
|
-
const hbdPayout = parseAsset(item.hbd_payout);
|
|
1172
|
-
return hbdPayout.amount > 0;
|
|
1173
|
-
case "claim_reward_balance":
|
|
1174
|
-
const rewardHbd = parseAsset(
|
|
1175
|
-
item.reward_hbd
|
|
1176
|
-
);
|
|
1177
|
-
return rewardHbd.amount > 0;
|
|
1178
|
-
case "transfer":
|
|
1179
|
-
case "transfer_to_savings":
|
|
1180
|
-
case "transfer_to_vesting":
|
|
1181
|
-
case "recurrent_transfer":
|
|
1182
|
-
return parseAsset(item.amount).symbol === "HBD";
|
|
1183
|
-
case "transfer_from_savings":
|
|
1184
|
-
return parseAsset(item.amount).symbol === "HBD";
|
|
1185
|
-
case "fill_recurrent_transfer":
|
|
1186
|
-
const asset = parseAsset(item.amount);
|
|
1187
|
-
return ["HBD"].includes(asset.symbol);
|
|
1188
|
-
case "cancel_transfer_from_savings":
|
|
1189
|
-
case "fill_order":
|
|
1190
|
-
case "limit_order_create":
|
|
1191
|
-
case "limit_order_cancel":
|
|
1192
|
-
case "fill_convert_request":
|
|
1193
|
-
case "fill_collateralized_convert_request":
|
|
1194
|
-
case "proposal_pay":
|
|
1195
|
-
case "interest":
|
|
1196
|
-
return true;
|
|
1197
|
-
case "limit_order_create2":
|
|
1198
|
-
return true;
|
|
1199
|
-
default:
|
|
1200
|
-
return false;
|
|
1201
|
-
}
|
|
1202
|
-
})
|
|
1203
|
-
)
|
|
1204
|
-
})
|
|
1205
|
-
});
|
|
1206
|
-
}
|
|
1207
|
-
function getHiveAssetMetricQueryOptions(bucketSeconds = 86400) {
|
|
1208
|
-
return reactQuery.infiniteQueryOptions({
|
|
1209
|
-
queryKey: ["assets", "hive", "metrics", bucketSeconds],
|
|
1210
|
-
queryFn: async ({ pageParam: [startDate, endDate] }) => {
|
|
1211
|
-
const apiData = await sdk.CONFIG.hiveClient.call(
|
|
1212
|
-
"condenser_api",
|
|
1213
|
-
"get_market_history",
|
|
1214
|
-
[
|
|
1215
|
-
bucketSeconds,
|
|
1216
|
-
dayjs__default.default(startDate).format("YYYY-MM-DDTHH:mm:ss"),
|
|
1217
|
-
dayjs__default.default(endDate).format("YYYY-MM-DDTHH:mm:ss")
|
|
1218
|
-
]
|
|
1219
|
-
);
|
|
1220
|
-
return apiData.map(({ hive, non_hive, open }) => ({
|
|
1221
|
-
close: non_hive.close / hive.close,
|
|
1222
|
-
open: non_hive.open / hive.open,
|
|
1223
|
-
low: non_hive.low / hive.low,
|
|
1224
|
-
high: non_hive.high / hive.high,
|
|
1225
|
-
volume: hive.volume,
|
|
1226
|
-
time: new Date(open)
|
|
1227
|
-
}));
|
|
1228
|
-
},
|
|
1229
|
-
initialPageParam: [
|
|
1230
|
-
// Fetch at least 8 hours or given interval
|
|
1231
|
-
dayjs__default.default().subtract(Math.max(100 * bucketSeconds, 28800), "second").toDate(),
|
|
1232
|
-
/* @__PURE__ */ new Date()
|
|
1233
|
-
],
|
|
1234
|
-
getNextPageParam: (_, __, [prevStartDate]) => [
|
|
1235
|
-
dayjs__default.default(prevStartDate.getTime()).subtract(Math.max(100 * bucketSeconds, 28800), "second").toDate(),
|
|
1236
|
-
dayjs__default.default(prevStartDate.getTime()).subtract(bucketSeconds, "second").toDate()
|
|
1237
|
-
]
|
|
1238
|
-
});
|
|
1239
|
-
}
|
|
1240
|
-
function getHiveAssetWithdrawalRoutesQueryOptions(username) {
|
|
1241
|
-
return reactQuery.queryOptions({
|
|
1242
|
-
queryKey: ["assets", "hive", "withdrawal-routes", username],
|
|
1243
|
-
queryFn: () => sdk.CONFIG.hiveClient.database.call("get_withdraw_routes", [
|
|
1244
|
-
username,
|
|
1245
|
-
"outgoing"
|
|
1246
|
-
])
|
|
1247
|
-
});
|
|
1248
|
-
}
|
|
1249
|
-
function getHivePowerDelegatesInfiniteQueryOptions(username, limit = 50) {
|
|
1250
|
-
return reactQuery.queryOptions({
|
|
1251
|
-
queryKey: ["assets", "hive-power", "delegates", username],
|
|
1252
|
-
enabled: !!username,
|
|
1253
|
-
queryFn: () => sdk.CONFIG.hiveClient.database.call("get_vesting_delegations", [
|
|
1254
|
-
username,
|
|
1255
|
-
"",
|
|
1256
|
-
limit
|
|
1257
|
-
])
|
|
1258
|
-
});
|
|
1259
|
-
}
|
|
1260
|
-
function getHivePowerDelegatingsQueryOptions(username) {
|
|
1261
|
-
return reactQuery.queryOptions({
|
|
1262
|
-
queryKey: ["assets", "hive-power", "delegatings", username],
|
|
1263
|
-
queryFn: async () => {
|
|
1264
|
-
const response = await fetch(
|
|
1265
|
-
sdk.CONFIG.privateApiHost + `/private-api/received-vesting/${username}`,
|
|
1266
|
-
{
|
|
1267
|
-
headers: {
|
|
1268
|
-
"Content-Type": "application/json"
|
|
1269
|
-
}
|
|
1270
|
-
}
|
|
1271
|
-
);
|
|
1272
|
-
return (await response.json()).list;
|
|
1273
|
-
},
|
|
1274
|
-
select: (data) => data.sort(
|
|
1275
|
-
(a, b) => parseAsset(b.vesting_shares).amount - parseAsset(a.vesting_shares).amount
|
|
1276
|
-
)
|
|
1277
|
-
});
|
|
1278
|
-
}
|
|
1279
|
-
|
|
1280
|
-
// src/modules/assets/utils/keychain-fallback.ts
|
|
1281
|
-
async function broadcastWithKeychainFallback(account, operations, authority = "Active") {
|
|
1282
|
-
if (typeof window === "undefined" || !window.hive_keychain) {
|
|
1283
|
-
throw new Error("[SDK][Wallets] \u2013 Keychain extension not found");
|
|
1284
|
-
}
|
|
1285
|
-
return new Promise((resolve, reject) => {
|
|
1286
|
-
window.hive_keychain.requestBroadcast(
|
|
1287
|
-
account,
|
|
1288
|
-
operations,
|
|
1289
|
-
authority,
|
|
1290
|
-
(response) => {
|
|
1291
|
-
if (!response.success) {
|
|
1292
|
-
reject(new Error(response.message || "Keychain operation cancelled"));
|
|
1293
|
-
return;
|
|
1294
|
-
}
|
|
1295
|
-
resolve(response.result);
|
|
1296
|
-
}
|
|
1297
|
-
);
|
|
1298
|
-
});
|
|
1299
|
-
}
|
|
1300
|
-
|
|
1301
|
-
// src/modules/assets/hive/mutations/transfer.ts
|
|
1302
|
-
async function transferHive(payload, auth) {
|
|
1303
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
1304
|
-
const token = parsedAsset.symbol;
|
|
1305
|
-
const precision = token === "VESTS" /* VESTS */ ? 6 : 3;
|
|
1306
|
-
const formattedAmount = parsedAsset.amount.toFixed(precision);
|
|
1307
|
-
const amountWithSymbol = `${formattedAmount} ${token}`;
|
|
1308
|
-
const operation = [
|
|
1309
|
-
"transfer",
|
|
1310
|
-
{
|
|
1311
|
-
from: payload.from,
|
|
1312
|
-
to: payload.to,
|
|
1313
|
-
amount: amountWithSymbol,
|
|
1314
|
-
memo: payload.memo
|
|
1315
|
-
}
|
|
1316
|
-
];
|
|
1317
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1318
|
-
const { key, type, ...params } = payload;
|
|
1319
|
-
return sdk.CONFIG.hiveClient.broadcast.transfer(
|
|
1320
|
-
{
|
|
1321
|
-
from: params.from,
|
|
1322
|
-
to: params.to,
|
|
1323
|
-
amount: amountWithSymbol,
|
|
1324
|
-
memo: params.memo
|
|
1325
|
-
},
|
|
1326
|
-
key
|
|
1327
|
-
);
|
|
1328
|
-
} else if (payload.type === "keychain") {
|
|
1329
|
-
if (auth?.broadcast) {
|
|
1330
|
-
return auth.broadcast([operation], "active");
|
|
1331
|
-
}
|
|
1332
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1333
|
-
} else if (payload.type === "hiveauth") {
|
|
1334
|
-
if (auth?.broadcast) {
|
|
1335
|
-
return auth.broadcast([operation], "active");
|
|
1336
|
-
}
|
|
1337
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1338
|
-
} else {
|
|
1339
|
-
return hs__default.default.sendOperation(
|
|
1340
|
-
operation,
|
|
1341
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
1342
|
-
() => {
|
|
1343
|
-
}
|
|
1344
|
-
);
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
async function transferToSavingsHive(payload, auth) {
|
|
1348
|
-
const operationPayload = {
|
|
1349
|
-
from: payload.from,
|
|
1350
|
-
to: payload.to,
|
|
1351
|
-
amount: payload.amount,
|
|
1352
|
-
memo: payload.memo
|
|
1353
|
-
};
|
|
1354
|
-
const operation = ["transfer_to_savings", operationPayload];
|
|
1355
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1356
|
-
const { key, type, ...params } = payload;
|
|
1357
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1358
|
-
[["transfer_to_savings", params]],
|
|
1359
|
-
key
|
|
1360
|
-
);
|
|
1361
|
-
} else if (payload.type === "keychain") {
|
|
1362
|
-
if (auth?.broadcast) {
|
|
1363
|
-
return auth.broadcast([operation], "active");
|
|
1364
|
-
}
|
|
1365
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1366
|
-
} else if (payload.type === "hiveauth") {
|
|
1367
|
-
if (auth?.broadcast) {
|
|
1368
|
-
return auth.broadcast([operation], "active");
|
|
1369
|
-
}
|
|
1370
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1371
|
-
} else {
|
|
1372
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1373
|
-
});
|
|
1374
|
-
}
|
|
1375
|
-
}
|
|
1376
|
-
async function transferFromSavingsHive(payload, auth) {
|
|
1377
|
-
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1378
|
-
const operationPayload = {
|
|
1379
|
-
from: payload.from,
|
|
1380
|
-
to: payload.to,
|
|
1381
|
-
amount: payload.amount,
|
|
1382
|
-
memo: payload.memo,
|
|
1383
|
-
request_id: requestId
|
|
1384
|
-
};
|
|
1385
|
-
const operation = ["transfer_from_savings", operationPayload];
|
|
1386
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1387
|
-
const { key } = payload;
|
|
1388
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1389
|
-
[operation],
|
|
1390
|
-
key
|
|
1391
|
-
);
|
|
1392
|
-
}
|
|
1393
|
-
if (payload.type === "keychain") {
|
|
1394
|
-
if (auth?.broadcast) {
|
|
1395
|
-
return auth.broadcast([operation], "active");
|
|
1396
|
-
}
|
|
1397
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1398
|
-
}
|
|
1399
|
-
if (payload.type === "hiveauth") {
|
|
1400
|
-
if (auth?.broadcast) {
|
|
1401
|
-
return auth.broadcast([operation], "active");
|
|
1402
|
-
}
|
|
1403
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1404
|
-
}
|
|
1405
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1406
|
-
});
|
|
1407
|
-
}
|
|
1408
|
-
async function powerUpHive(payload, auth) {
|
|
1409
|
-
const operationPayload = {
|
|
1410
|
-
from: payload.from,
|
|
1411
|
-
to: payload.to,
|
|
1412
|
-
amount: payload.amount,
|
|
1413
|
-
memo: payload.memo
|
|
1414
|
-
};
|
|
1415
|
-
const operation = ["transfer_to_vesting", operationPayload];
|
|
1416
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1417
|
-
const { key, type, ...params } = payload;
|
|
1418
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1419
|
-
[["transfer_to_vesting", params]],
|
|
1420
|
-
key
|
|
1421
|
-
);
|
|
1422
|
-
} else if (payload.type === "keychain") {
|
|
1423
|
-
if (auth?.broadcast) {
|
|
1424
|
-
return auth.broadcast([operation], "active");
|
|
1425
|
-
}
|
|
1426
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1427
|
-
} else if (payload.type === "hiveauth") {
|
|
1428
|
-
if (auth?.broadcast) {
|
|
1429
|
-
return auth.broadcast([operation], "active");
|
|
1430
|
-
}
|
|
1431
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1432
|
-
} else {
|
|
1433
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1434
|
-
});
|
|
1435
|
-
}
|
|
1436
|
-
}
|
|
1437
|
-
async function delegateHive(payload, auth) {
|
|
1438
|
-
const operationPayload = {
|
|
1439
|
-
delegator: payload.from,
|
|
1440
|
-
delegatee: payload.to,
|
|
1441
|
-
vesting_shares: payload.amount
|
|
1442
|
-
};
|
|
1443
|
-
const operation = ["delegate_vesting_shares", operationPayload];
|
|
1444
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1445
|
-
const { key } = payload;
|
|
1446
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1447
|
-
[operation],
|
|
1448
|
-
key
|
|
1449
|
-
);
|
|
1450
|
-
} else if (payload.type === "keychain") {
|
|
1451
|
-
if (auth?.broadcast) {
|
|
1452
|
-
return auth.broadcast([operation], "active");
|
|
1453
|
-
}
|
|
1454
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1455
|
-
} else if (payload.type === "hiveauth") {
|
|
1456
|
-
if (auth?.broadcast) {
|
|
1457
|
-
return auth.broadcast([operation], "active");
|
|
1458
|
-
}
|
|
1459
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1460
|
-
} else {
|
|
1461
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1462
|
-
});
|
|
1463
|
-
}
|
|
1464
|
-
}
|
|
1465
|
-
async function powerDownHive(payload, auth) {
|
|
1466
|
-
const operationPayload = {
|
|
1467
|
-
account: payload.from,
|
|
1468
|
-
vesting_shares: payload.amount
|
|
1469
|
-
};
|
|
1470
|
-
const operation = ["withdraw_vesting", operationPayload];
|
|
1471
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1472
|
-
const { key } = payload;
|
|
1473
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1474
|
-
[operation],
|
|
1475
|
-
key
|
|
1476
|
-
);
|
|
1477
|
-
} else if (payload.type === "keychain") {
|
|
1478
|
-
if (auth?.broadcast) {
|
|
1479
|
-
return auth.broadcast([operation], "active");
|
|
1480
|
-
}
|
|
1481
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1482
|
-
} else if (payload.type === "hiveauth") {
|
|
1483
|
-
if (auth?.broadcast) {
|
|
1484
|
-
return auth.broadcast([operation], "active");
|
|
1485
|
-
}
|
|
1486
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1487
|
-
} else {
|
|
1488
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
async function withdrawVestingRouteHive(payload, auth) {
|
|
1493
|
-
const baseParams = {
|
|
1494
|
-
from_account: payload.from_account,
|
|
1495
|
-
to_account: payload.to_account,
|
|
1496
|
-
percent: payload.percent,
|
|
1497
|
-
auto_vest: payload.auto_vest
|
|
1498
|
-
};
|
|
1499
|
-
const operation = ["set_withdraw_vesting_route", baseParams];
|
|
1500
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1501
|
-
const { key, type: type2, ...params2 } = payload;
|
|
1502
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1503
|
-
[["set_withdraw_vesting_route", params2]],
|
|
1504
|
-
key
|
|
1505
|
-
);
|
|
1506
|
-
}
|
|
1507
|
-
if (payload.type === "keychain") {
|
|
1508
|
-
if (auth?.broadcast) {
|
|
1509
|
-
return auth.broadcast([operation], "active");
|
|
1510
|
-
}
|
|
1511
|
-
return broadcastWithKeychainFallback(payload.from_account, [operation], "Active");
|
|
1512
|
-
}
|
|
1513
|
-
if (payload.type === "hiveauth") {
|
|
1514
|
-
if (auth?.broadcast) {
|
|
1515
|
-
return auth.broadcast([operation], "active");
|
|
1516
|
-
}
|
|
1517
|
-
return broadcastWithWalletHiveAuth(payload.from_account, [operation], "active");
|
|
1518
|
-
}
|
|
1519
|
-
const { type, ...params } = payload;
|
|
1520
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${params.from_account}/wallet` }, () => {
|
|
1521
|
-
});
|
|
1522
|
-
}
|
|
1523
|
-
function useClaimRewards(username, auth, onSuccess) {
|
|
1524
|
-
const { data } = reactQuery.useQuery(sdk.getAccountFullQueryOptions(username));
|
|
1525
|
-
const queryClient = reactQuery.useQueryClient();
|
|
1526
|
-
return sdk.useBroadcastMutation(
|
|
1527
|
-
["assets", "hive", "claim-rewards", data?.name],
|
|
1528
|
-
username,
|
|
1529
|
-
() => {
|
|
1530
|
-
if (!data) {
|
|
1531
|
-
throw new Error("Failed to fetch account while claiming balance");
|
|
1532
|
-
}
|
|
1533
|
-
const {
|
|
1534
|
-
reward_hive_balance: hiveBalance,
|
|
1535
|
-
reward_hbd_balance: hbdBalance,
|
|
1536
|
-
reward_vesting_balance: vestingBalance
|
|
1537
|
-
} = data;
|
|
1538
|
-
return [
|
|
1539
|
-
[
|
|
1540
|
-
"claim_reward_balance",
|
|
1541
|
-
{
|
|
1542
|
-
account: username,
|
|
1543
|
-
reward_hive: hiveBalance,
|
|
1544
|
-
reward_hbd: hbdBalance,
|
|
1545
|
-
reward_vests: vestingBalance
|
|
1546
|
-
}
|
|
1547
|
-
]
|
|
1548
|
-
];
|
|
1549
|
-
},
|
|
1550
|
-
async () => {
|
|
1551
|
-
onSuccess();
|
|
1552
|
-
await delay(1e3);
|
|
1553
|
-
queryClient.invalidateQueries({
|
|
1554
|
-
queryKey: sdk.getAccountFullQueryOptions(username).queryKey
|
|
1555
|
-
});
|
|
1556
|
-
queryClient.invalidateQueries({
|
|
1557
|
-
queryKey: ["ecency-wallets", "portfolio", "v2", username]
|
|
1558
|
-
});
|
|
1559
|
-
queryClient.invalidateQueries({
|
|
1560
|
-
queryKey: getHiveAssetGeneralInfoQueryOptions(username).queryKey
|
|
1561
|
-
});
|
|
1562
|
-
queryClient.invalidateQueries({
|
|
1563
|
-
queryKey: getHbdAssetGeneralInfoQueryOptions(username).queryKey
|
|
1564
|
-
});
|
|
1565
|
-
queryClient.invalidateQueries({
|
|
1566
|
-
queryKey: getHivePowerAssetGeneralInfoQueryOptions(username).queryKey
|
|
1567
|
-
});
|
|
1568
|
-
["HIVE", "HBD", "HP"].forEach((asset) => {
|
|
1569
|
-
queryClient.invalidateQueries({
|
|
1570
|
-
queryKey: ["ecency-wallets", "asset-info", username, asset]
|
|
1571
|
-
});
|
|
1572
|
-
});
|
|
1573
|
-
setTimeout(() => {
|
|
1574
|
-
queryClient.invalidateQueries({
|
|
1575
|
-
queryKey: sdk.getAccountFullQueryOptions(username).queryKey
|
|
1576
|
-
});
|
|
1577
|
-
queryClient.invalidateQueries({
|
|
1578
|
-
queryKey: ["ecency-wallets", "portfolio", "v2", username]
|
|
1579
|
-
});
|
|
1580
|
-
queryClient.invalidateQueries({
|
|
1581
|
-
queryKey: getHiveAssetGeneralInfoQueryOptions(username).queryKey
|
|
1582
|
-
});
|
|
1583
|
-
queryClient.invalidateQueries({
|
|
1584
|
-
queryKey: getHbdAssetGeneralInfoQueryOptions(username).queryKey
|
|
1585
|
-
});
|
|
1586
|
-
queryClient.invalidateQueries({
|
|
1587
|
-
queryKey: getHivePowerAssetGeneralInfoQueryOptions(username).queryKey
|
|
1588
|
-
});
|
|
1589
|
-
["HIVE", "HBD", "HP"].forEach((asset) => {
|
|
1590
|
-
queryClient.invalidateQueries({
|
|
1591
|
-
queryKey: ["ecency-wallets", "asset-info", username, asset]
|
|
1592
|
-
});
|
|
1593
|
-
});
|
|
1594
|
-
}, 5e3);
|
|
1595
|
-
},
|
|
1596
|
-
auth
|
|
1597
|
-
);
|
|
1598
|
-
}
|
|
1599
|
-
async function claimInterestHive(payload, auth) {
|
|
1600
|
-
const requestId = payload.request_id ?? Date.now() >>> 0;
|
|
1601
|
-
const baseOperation = {
|
|
1602
|
-
from: payload.from,
|
|
1603
|
-
to: payload.to,
|
|
1604
|
-
amount: payload.amount,
|
|
1605
|
-
memo: payload.memo,
|
|
1606
|
-
request_id: requestId
|
|
1607
|
-
};
|
|
1608
|
-
const cancelOperation = {
|
|
1609
|
-
from: payload.from,
|
|
1610
|
-
request_id: requestId
|
|
1611
|
-
};
|
|
1612
|
-
const operations = [
|
|
1613
|
-
["transfer_from_savings", baseOperation],
|
|
1614
|
-
["cancel_transfer_from_savings", cancelOperation]
|
|
1615
|
-
];
|
|
1616
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1617
|
-
const { key } = payload;
|
|
1618
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(operations, key);
|
|
1619
|
-
}
|
|
1620
|
-
if (payload.type === "keychain") {
|
|
1621
|
-
if (auth?.broadcast) {
|
|
1622
|
-
return auth.broadcast(operations, "active");
|
|
1623
|
-
}
|
|
1624
|
-
return broadcastWithKeychainFallback(payload.from, operations, "Active");
|
|
1625
|
-
}
|
|
1626
|
-
if (payload.type === "hiveauth") {
|
|
1627
|
-
if (auth?.broadcast) {
|
|
1628
|
-
return auth.broadcast(operations, "active");
|
|
1629
|
-
}
|
|
1630
|
-
return broadcastWithWalletHiveAuth(payload.from, operations, "active");
|
|
1631
|
-
}
|
|
1632
|
-
return hs__default.default.sendOperations(operations, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1633
|
-
});
|
|
1634
|
-
}
|
|
1635
|
-
async function convertHbd(payload, auth) {
|
|
1636
|
-
const requestid = Math.floor(Date.now() / 1e3);
|
|
1637
|
-
const operationPayload = {
|
|
1638
|
-
owner: payload.from,
|
|
1639
|
-
requestid,
|
|
1640
|
-
amount: payload.amount
|
|
1641
|
-
};
|
|
1642
|
-
const operation = ["convert", operationPayload];
|
|
1643
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1644
|
-
const { key, type, ...params } = payload;
|
|
1645
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations(
|
|
1646
|
-
[["convert", { ...params, owner: params.from, requestid }]],
|
|
1647
|
-
key
|
|
1648
|
-
);
|
|
1649
|
-
} else if (payload.type === "keychain") {
|
|
1650
|
-
if (auth?.broadcast) {
|
|
1651
|
-
return auth.broadcast([operation], "active");
|
|
1652
|
-
}
|
|
1653
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1654
|
-
} else if (payload.type === "hiveauth") {
|
|
1655
|
-
if (auth?.broadcast) {
|
|
1656
|
-
return auth.broadcast([operation], "active");
|
|
1657
|
-
}
|
|
1658
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1659
|
-
} else {
|
|
1660
|
-
return hs__default.default.sendOperation(operation, { callback: `https://ecency.com/@${payload.from}/wallet` }, () => {
|
|
1661
|
-
});
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
|
|
1665
|
-
// src/modules/assets/types/asset-operation.ts
|
|
1666
|
-
var AssetOperation = /* @__PURE__ */ ((AssetOperation2) => {
|
|
1667
|
-
AssetOperation2["Transfer"] = "transfer";
|
|
1668
|
-
AssetOperation2["TransferToSavings"] = "transfer-saving";
|
|
1669
|
-
AssetOperation2["WithdrawFromSavings"] = "withdraw-saving";
|
|
1670
|
-
AssetOperation2["Delegate"] = "delegate";
|
|
1671
|
-
AssetOperation2["PowerUp"] = "power-up";
|
|
1672
|
-
AssetOperation2["PowerDown"] = "power-down";
|
|
1673
|
-
AssetOperation2["WithdrawRoutes"] = "withdraw-routes";
|
|
1674
|
-
AssetOperation2["ClaimInterest"] = "claim-interest";
|
|
1675
|
-
AssetOperation2["Swap"] = "swap";
|
|
1676
|
-
AssetOperation2["Convert"] = "convert";
|
|
1677
|
-
AssetOperation2["Gift"] = "gift";
|
|
1678
|
-
AssetOperation2["Promote"] = "promote";
|
|
1679
|
-
AssetOperation2["Claim"] = "claim";
|
|
1680
|
-
AssetOperation2["Buy"] = "buy";
|
|
1681
|
-
AssetOperation2["LockLiquidity"] = "lock";
|
|
1682
|
-
AssetOperation2["Stake"] = "stake";
|
|
1683
|
-
AssetOperation2["Unstake"] = "unstake";
|
|
1684
|
-
AssetOperation2["Undelegate"] = "undelegate";
|
|
1685
|
-
return AssetOperation2;
|
|
1686
|
-
})(AssetOperation || {});
|
|
1687
|
-
async function transferSpk(payload, auth) {
|
|
1688
|
-
const json = JSON.stringify({
|
|
1689
|
-
to: payload.to,
|
|
1690
|
-
amount: parseAsset(payload.amount).amount * 1e3,
|
|
1691
|
-
...typeof payload.memo === "string" ? { memo: payload.memo } : {}
|
|
1692
|
-
});
|
|
1693
|
-
const op = {
|
|
1694
|
-
id: "spkcc_spk_send",
|
|
1695
|
-
json,
|
|
1696
|
-
required_auths: [payload.from],
|
|
1697
|
-
required_posting_auths: []
|
|
1698
|
-
};
|
|
1699
|
-
const operation = [
|
|
1700
|
-
"custom_json",
|
|
1701
|
-
{
|
|
1702
|
-
id: op.id,
|
|
1703
|
-
required_auths: [payload.from],
|
|
1704
|
-
required_posting_auths: [],
|
|
1705
|
-
json
|
|
1706
|
-
}
|
|
1707
|
-
];
|
|
1708
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1709
|
-
const { key } = payload;
|
|
1710
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
1711
|
-
} else if (payload.type === "keychain") {
|
|
1712
|
-
if (auth?.broadcast) {
|
|
1713
|
-
return auth.broadcast([operation], "active");
|
|
1714
|
-
}
|
|
1715
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1716
|
-
} else if (payload.type === "hiveauth") {
|
|
1717
|
-
if (auth?.broadcast) {
|
|
1718
|
-
return auth.broadcast([operation], "active");
|
|
1719
|
-
}
|
|
1720
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1721
|
-
} else {
|
|
1722
|
-
const { amount } = parseAsset(payload.amount);
|
|
1723
|
-
return hs__default.default.sign(
|
|
1724
|
-
"custom_json",
|
|
1725
|
-
{
|
|
1726
|
-
authority: "active",
|
|
1727
|
-
required_auths: `["${payload.from}"]`,
|
|
1728
|
-
required_posting_auths: "[]",
|
|
1729
|
-
id: "spkcc_spk_send",
|
|
1730
|
-
json: JSON.stringify({
|
|
1731
|
-
to: payload.to,
|
|
1732
|
-
amount: +amount * 1e3,
|
|
1733
|
-
...typeof payload.memo === "string" ? { memo: payload.memo } : {}
|
|
1734
|
-
})
|
|
1735
|
-
},
|
|
1736
|
-
`https://ecency.com/@${payload.from}/wallet`
|
|
1737
|
-
);
|
|
1738
|
-
}
|
|
1739
|
-
}
|
|
1740
|
-
var lockLarynx = async (payload, auth) => {
|
|
1741
|
-
const json = JSON.stringify({ amount: +payload.amount * 1e3 });
|
|
1742
|
-
const op = {
|
|
1743
|
-
id: payload.mode === "lock" ? "spkcc_gov_up" : "spkcc_gov_down",
|
|
1744
|
-
json,
|
|
1745
|
-
required_auths: [payload.from],
|
|
1746
|
-
required_posting_auths: []
|
|
1747
|
-
};
|
|
1748
|
-
const operation = [
|
|
1749
|
-
"custom_json",
|
|
1750
|
-
{
|
|
1751
|
-
id: op.id,
|
|
1752
|
-
required_auths: [payload.from],
|
|
1753
|
-
required_posting_auths: [],
|
|
1754
|
-
json
|
|
1755
|
-
}
|
|
1756
|
-
];
|
|
1757
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1758
|
-
const { key } = payload;
|
|
1759
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
1760
|
-
} else if (payload.type === "keychain") {
|
|
1761
|
-
if (auth?.broadcast) {
|
|
1762
|
-
return auth.broadcast([operation], "active");
|
|
1763
|
-
}
|
|
1764
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1765
|
-
} else if (payload.type === "hiveauth") {
|
|
1766
|
-
if (auth?.broadcast) {
|
|
1767
|
-
return auth.broadcast([operation], "active");
|
|
1768
|
-
}
|
|
1769
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1770
|
-
} else {
|
|
1771
|
-
const { amount } = parseAsset(payload.amount);
|
|
1772
|
-
return hs__default.default.sign(
|
|
1773
|
-
"custom_json",
|
|
1774
|
-
{
|
|
1775
|
-
authority: "active",
|
|
1776
|
-
required_auths: `["${payload.from}"]`,
|
|
1777
|
-
required_posting_auths: "[]",
|
|
1778
|
-
id: op.id,
|
|
1779
|
-
json: JSON.stringify({ amount: +amount * 1e3 })
|
|
1780
|
-
},
|
|
1781
|
-
`https://ecency.com/@${payload.from}/wallet`
|
|
1782
|
-
);
|
|
1783
|
-
}
|
|
1784
|
-
};
|
|
1785
|
-
async function powerUpLarynx(payload, auth) {
|
|
1786
|
-
const json = JSON.stringify({ amount: +payload.amount * 1e3 });
|
|
1787
|
-
const op = {
|
|
1788
|
-
id: `spkcc_power_${payload.mode}`,
|
|
1789
|
-
json,
|
|
1790
|
-
required_auths: [payload.from],
|
|
1791
|
-
required_posting_auths: []
|
|
1792
|
-
};
|
|
1793
|
-
const operation = [
|
|
1794
|
-
"custom_json",
|
|
1795
|
-
{
|
|
1796
|
-
id: `spkcc_power_${payload.mode}`,
|
|
1797
|
-
required_auths: [payload.from],
|
|
1798
|
-
required_posting_auths: [],
|
|
1799
|
-
json
|
|
1800
|
-
}
|
|
1801
|
-
];
|
|
1802
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1803
|
-
const { key } = payload;
|
|
1804
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
1805
|
-
} else if (payload.type === "keychain") {
|
|
1806
|
-
if (auth?.broadcast) {
|
|
1807
|
-
return auth.broadcast([operation], "active");
|
|
1808
|
-
}
|
|
1809
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1810
|
-
} else if (payload.type === "hiveauth") {
|
|
1811
|
-
if (auth?.broadcast) {
|
|
1812
|
-
return auth.broadcast([operation], "active");
|
|
1813
|
-
}
|
|
1814
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1815
|
-
} else {
|
|
1816
|
-
const { amount } = parseAsset(payload.amount);
|
|
1817
|
-
return hs__default.default.sign(
|
|
1818
|
-
"custom_json",
|
|
1819
|
-
{
|
|
1820
|
-
authority: "active",
|
|
1821
|
-
required_auths: `["${payload.from}"]`,
|
|
1822
|
-
required_posting_auths: "[]",
|
|
1823
|
-
id: `spkcc_power_${payload.mode}`,
|
|
1824
|
-
json: JSON.stringify({ amount: +amount * 1e3 })
|
|
1825
|
-
},
|
|
1826
|
-
`https://ecency.com/@${payload.from}/wallet`
|
|
1827
|
-
);
|
|
1828
|
-
}
|
|
1829
|
-
}
|
|
1830
|
-
async function transferLarynx(payload, auth) {
|
|
1831
|
-
const json = JSON.stringify({
|
|
1832
|
-
to: payload.to,
|
|
1833
|
-
amount: parseAsset(payload.amount).amount * 1e3,
|
|
1834
|
-
...typeof payload.memo === "string" ? { memo: payload.memo } : {}
|
|
1835
|
-
});
|
|
1836
|
-
const op = {
|
|
1837
|
-
id: "spkcc_send",
|
|
1838
|
-
json,
|
|
1839
|
-
required_auths: [payload.from],
|
|
1840
|
-
required_posting_auths: []
|
|
1841
|
-
};
|
|
1842
|
-
const operation = [
|
|
1843
|
-
"custom_json",
|
|
1844
|
-
{
|
|
1845
|
-
id: "spkcc_send",
|
|
1846
|
-
required_auths: [payload.from],
|
|
1847
|
-
required_posting_auths: [],
|
|
1848
|
-
json
|
|
1849
|
-
}
|
|
1850
|
-
];
|
|
1851
|
-
if (payload.type === "key" && "key" in payload) {
|
|
1852
|
-
const { key } = payload;
|
|
1853
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
1854
|
-
} else if (payload.type === "keychain") {
|
|
1855
|
-
if (auth?.broadcast) {
|
|
1856
|
-
return auth.broadcast([operation], "active");
|
|
1857
|
-
}
|
|
1858
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
1859
|
-
} else if (payload.type === "hiveauth") {
|
|
1860
|
-
if (auth?.broadcast) {
|
|
1861
|
-
return auth.broadcast([operation], "active");
|
|
1862
|
-
}
|
|
1863
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
1864
|
-
} else {
|
|
1865
|
-
const { amount } = parseAsset(payload.amount);
|
|
1866
|
-
return hs__default.default.sign(
|
|
1867
|
-
"custom_json",
|
|
1868
|
-
{
|
|
1869
|
-
authority: "active",
|
|
1870
|
-
required_auths: `["${payload.from}"]`,
|
|
1871
|
-
required_posting_auths: "[]",
|
|
1872
|
-
id: "spkcc_send",
|
|
1873
|
-
json: JSON.stringify({
|
|
1874
|
-
to: payload.to,
|
|
1875
|
-
amount: +amount * 1e3,
|
|
1876
|
-
...typeof payload.memo === "string" ? { memo: payload.memo } : {}
|
|
1877
|
-
})
|
|
1878
|
-
},
|
|
1879
|
-
`https://ecency.com/@${payload.from}/wallet`
|
|
1880
|
-
);
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
function getSpkMarketsQueryOptions() {
|
|
1884
|
-
return reactQuery.queryOptions({
|
|
1885
|
-
queryKey: ["assets", "spk", "markets"],
|
|
1886
|
-
staleTime: 6e4,
|
|
1887
|
-
refetchInterval: 9e4,
|
|
1888
|
-
queryFn: async () => {
|
|
1889
|
-
const data = await sdk.getSpkMarkets();
|
|
1890
|
-
return {
|
|
1891
|
-
list: Object.entries(data.markets.node).map(([name, node]) => ({
|
|
1892
|
-
name,
|
|
1893
|
-
status: node.lastGood >= data.head_block - 1200 ? "\u{1F7E9}" : node.lastGood > data.head_block - 28800 ? "\u{1F7E8}" : "\u{1F7E5}"
|
|
1894
|
-
})),
|
|
1895
|
-
raw: data
|
|
1896
|
-
};
|
|
1897
|
-
}
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
function getSpkWalletQueryOptions(username) {
|
|
1901
|
-
return reactQuery.queryOptions({
|
|
1902
|
-
queryKey: ["assets", "spk", "wallet", username],
|
|
1903
|
-
queryFn: async () => {
|
|
1904
|
-
if (!username) {
|
|
1905
|
-
throw new Error("[SDK][Wallets][SPK] \u2013 username wasn't provided");
|
|
1906
|
-
}
|
|
1907
|
-
return sdk.getSpkWallet(username);
|
|
1908
|
-
},
|
|
1909
|
-
enabled: !!username,
|
|
1910
|
-
staleTime: 6e4,
|
|
1911
|
-
refetchInterval: 9e4
|
|
1912
|
-
});
|
|
1913
|
-
}
|
|
1914
|
-
|
|
1915
|
-
// src/modules/assets/spk/queries/get-larynx-asset-general-info-query-options.ts
|
|
1916
|
-
function format(value) {
|
|
1917
|
-
return value.toFixed(3);
|
|
1918
|
-
}
|
|
1919
|
-
function getLarynxAssetGeneralInfoQueryOptions(username) {
|
|
1920
|
-
return reactQuery.queryOptions({
|
|
1921
|
-
queryKey: ["assets", "larynx", "general-info", username],
|
|
1922
|
-
staleTime: 6e4,
|
|
1923
|
-
refetchInterval: 9e4,
|
|
1924
|
-
queryFn: async () => {
|
|
1925
|
-
await sdk.getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
|
|
1926
|
-
await sdk.getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
|
|
1927
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
1928
|
-
getHiveAssetGeneralInfoQueryOptions(username)
|
|
1929
|
-
);
|
|
1930
|
-
const wallet = sdk.getQueryClient().getQueryData(
|
|
1931
|
-
getSpkWalletQueryOptions(username).queryKey
|
|
1932
|
-
);
|
|
1933
|
-
const market = sdk.getQueryClient().getQueryData(
|
|
1934
|
-
getSpkMarketsQueryOptions().queryKey
|
|
1935
|
-
);
|
|
1936
|
-
const hiveAsset = sdk.getQueryClient().getQueryData(
|
|
1937
|
-
getHiveAssetGeneralInfoQueryOptions(username).queryKey
|
|
1938
|
-
);
|
|
1939
|
-
if (!wallet || !market) {
|
|
1940
|
-
return {
|
|
1941
|
-
name: "LARYNX",
|
|
1942
|
-
title: "SPK Network / LARYNX",
|
|
1943
|
-
price: 1,
|
|
1944
|
-
accountBalance: 0
|
|
1945
|
-
};
|
|
1946
|
-
}
|
|
1947
|
-
const price = +format(
|
|
1948
|
-
wallet.balance / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
|
|
1949
|
-
);
|
|
1950
|
-
const accountBalance = +format(wallet.balance / 1e3);
|
|
1951
|
-
return {
|
|
1952
|
-
name: "LARYNX",
|
|
1953
|
-
layer: "SPK",
|
|
1954
|
-
title: "LARYNX",
|
|
1955
|
-
price: price / accountBalance,
|
|
1956
|
-
accountBalance
|
|
1957
|
-
};
|
|
1958
|
-
}
|
|
1959
|
-
});
|
|
1960
|
-
}
|
|
1961
|
-
function format2(value) {
|
|
1962
|
-
return value.toFixed(3);
|
|
1963
|
-
}
|
|
1964
|
-
function getSpkAssetGeneralInfoQueryOptions(username) {
|
|
1965
|
-
return reactQuery.queryOptions({
|
|
1966
|
-
queryKey: ["assets", "spk", "general-info", username],
|
|
1967
|
-
staleTime: 6e4,
|
|
1968
|
-
refetchInterval: 9e4,
|
|
1969
|
-
queryFn: async () => {
|
|
1970
|
-
await sdk.getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
|
|
1971
|
-
await sdk.getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
|
|
1972
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
1973
|
-
getHiveAssetGeneralInfoQueryOptions(username)
|
|
1974
|
-
);
|
|
1975
|
-
const wallet = sdk.getQueryClient().getQueryData(
|
|
1976
|
-
getSpkWalletQueryOptions(username).queryKey
|
|
1977
|
-
);
|
|
1978
|
-
const market = sdk.getQueryClient().getQueryData(
|
|
1979
|
-
getSpkMarketsQueryOptions().queryKey
|
|
1980
|
-
);
|
|
1981
|
-
const hiveAsset = sdk.getQueryClient().getQueryData(
|
|
1982
|
-
getHiveAssetGeneralInfoQueryOptions(username).queryKey
|
|
1983
|
-
);
|
|
1984
|
-
if (!wallet || !market) {
|
|
1985
|
-
return {
|
|
1986
|
-
name: "SPK",
|
|
1987
|
-
layer: "SPK",
|
|
1988
|
-
title: "SPK Network",
|
|
1989
|
-
price: 1,
|
|
1990
|
-
accountBalance: 0
|
|
1991
|
-
};
|
|
1992
|
-
}
|
|
1993
|
-
const price = +format2(
|
|
1994
|
-
(wallet.gov + wallet.spk) / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
|
|
1995
|
-
);
|
|
1996
|
-
const accountBalance = +format2(
|
|
1997
|
-
(wallet.spk + rewardSpk(
|
|
1998
|
-
wallet,
|
|
1999
|
-
market.raw.stats || {
|
|
2000
|
-
spk_rate_lgov: "0.001",
|
|
2001
|
-
spk_rate_lpow: format2(
|
|
2002
|
-
parseFloat(market.raw.stats.spk_rate_lpow) * 100
|
|
2003
|
-
),
|
|
2004
|
-
spk_rate_ldel: format2(
|
|
2005
|
-
parseFloat(market.raw.stats.spk_rate_ldel) * 100
|
|
2006
|
-
)
|
|
2007
|
-
}
|
|
2008
|
-
)) / 1e3
|
|
2009
|
-
);
|
|
2010
|
-
return {
|
|
2011
|
-
name: "SPK",
|
|
2012
|
-
layer: "SPK",
|
|
2013
|
-
title: "SPK Network",
|
|
2014
|
-
price: price / accountBalance,
|
|
2015
|
-
accountBalance
|
|
2016
|
-
};
|
|
2017
|
-
}
|
|
2018
|
-
});
|
|
2019
|
-
}
|
|
2020
|
-
function format3(value) {
|
|
2021
|
-
return value.toFixed(3);
|
|
2022
|
-
}
|
|
2023
|
-
function getLarynxPowerAssetGeneralInfoQueryOptions(username) {
|
|
2024
|
-
return reactQuery.queryOptions({
|
|
2025
|
-
queryKey: ["assets", "larynx-power", "general-info", username],
|
|
2026
|
-
staleTime: 6e4,
|
|
2027
|
-
refetchInterval: 9e4,
|
|
2028
|
-
queryFn: async () => {
|
|
2029
|
-
await sdk.getQueryClient().prefetchQuery(getSpkWalletQueryOptions(username));
|
|
2030
|
-
await sdk.getQueryClient().prefetchQuery(getSpkMarketsQueryOptions());
|
|
2031
|
-
await sdk.getQueryClient().prefetchQuery(
|
|
2032
|
-
getHiveAssetGeneralInfoQueryOptions(username)
|
|
2033
|
-
);
|
|
2034
|
-
const wallet = sdk.getQueryClient().getQueryData(
|
|
2035
|
-
getSpkWalletQueryOptions(username).queryKey
|
|
2036
|
-
);
|
|
2037
|
-
const market = sdk.getQueryClient().getQueryData(
|
|
2038
|
-
getSpkMarketsQueryOptions().queryKey
|
|
2039
|
-
);
|
|
2040
|
-
const hiveAsset = sdk.getQueryClient().getQueryData(
|
|
2041
|
-
getHiveAssetGeneralInfoQueryOptions(username).queryKey
|
|
2042
|
-
);
|
|
2043
|
-
if (!wallet || !market) {
|
|
2044
|
-
return {
|
|
2045
|
-
name: "LP",
|
|
2046
|
-
title: "SPK Network / LARYNX Power",
|
|
2047
|
-
price: 1,
|
|
2048
|
-
accountBalance: 0
|
|
2049
|
-
};
|
|
2050
|
-
}
|
|
2051
|
-
const price = +format3(
|
|
2052
|
-
wallet.poweredUp / 1e3 * +wallet.tick * (hiveAsset?.price ?? 0)
|
|
2053
|
-
);
|
|
2054
|
-
const accountBalance = +format3(wallet.poweredUp / 1e3);
|
|
2055
|
-
return {
|
|
2056
|
-
name: "LP",
|
|
2057
|
-
title: "LARYNX Power",
|
|
2058
|
-
layer: "SPK",
|
|
2059
|
-
price: price / accountBalance,
|
|
2060
|
-
accountBalance,
|
|
2061
|
-
parts: [
|
|
2062
|
-
{
|
|
2063
|
-
name: "delegating",
|
|
2064
|
-
balance: wallet.granting?.t ? +format3(wallet.granting.t / 1e3) : 0
|
|
2065
|
-
},
|
|
2066
|
-
{
|
|
2067
|
-
name: "recieved",
|
|
2068
|
-
balance: wallet.granted?.t ? +format3(wallet.granted.t / 1e3) : 0
|
|
2069
|
-
}
|
|
2070
|
-
]
|
|
2071
|
-
};
|
|
2072
|
-
}
|
|
2073
|
-
});
|
|
2074
|
-
}
|
|
2075
|
-
function getAllHiveEngineTokensQueryOptions(account, symbol) {
|
|
2076
|
-
return reactQuery.queryOptions({
|
|
2077
|
-
queryKey: ["assets", "hive-engine", "all-tokens", account, symbol],
|
|
2078
|
-
queryFn: async () => {
|
|
2079
|
-
return sdk.getHiveEngineTokensMarket(account, symbol);
|
|
2080
|
-
}
|
|
2081
|
-
});
|
|
2082
|
-
}
|
|
2083
|
-
function formattedNumber(value, options2 = void 0) {
|
|
2084
|
-
let opts = {
|
|
2085
|
-
fractionDigits: 3,
|
|
2086
|
-
prefix: "",
|
|
2087
|
-
suffix: ""
|
|
2088
|
-
};
|
|
2089
|
-
if (options2) {
|
|
2090
|
-
opts = { ...opts, ...options2 };
|
|
2091
|
-
}
|
|
2092
|
-
const { fractionDigits, prefix, suffix } = opts;
|
|
2093
|
-
let format4 = "0,0";
|
|
2094
|
-
if (fractionDigits) {
|
|
2095
|
-
format4 += "." + "0".repeat(fractionDigits);
|
|
2096
|
-
}
|
|
2097
|
-
let out = "";
|
|
2098
|
-
if (prefix) out += prefix + " ";
|
|
2099
|
-
const av = Math.abs(parseFloat(value.toString())) < 1e-4 ? 0 : value;
|
|
2100
|
-
out += numeral__default.default(av).format(format4);
|
|
2101
|
-
if (suffix) out += " " + suffix;
|
|
2102
|
-
return out;
|
|
2103
|
-
}
|
|
2104
|
-
|
|
2105
|
-
// src/modules/assets/hive-engine/utils/hive-engine-token.ts
|
|
2106
|
-
var HiveEngineToken = class {
|
|
2107
|
-
symbol;
|
|
2108
|
-
name;
|
|
2109
|
-
icon;
|
|
2110
|
-
precision;
|
|
2111
|
-
stakingEnabled;
|
|
2112
|
-
delegationEnabled;
|
|
2113
|
-
balance;
|
|
2114
|
-
stake;
|
|
2115
|
-
stakedBalance;
|
|
2116
|
-
delegationsIn;
|
|
2117
|
-
delegationsOut;
|
|
2118
|
-
usdValue;
|
|
2119
|
-
constructor(props) {
|
|
2120
|
-
this.symbol = props.symbol;
|
|
2121
|
-
this.name = props.name || "";
|
|
2122
|
-
this.icon = props.icon || "";
|
|
2123
|
-
this.precision = props.precision || 0;
|
|
2124
|
-
this.stakingEnabled = props.stakingEnabled || false;
|
|
2125
|
-
this.delegationEnabled = props.delegationEnabled || false;
|
|
2126
|
-
this.balance = parseFloat(props.balance) || 0;
|
|
2127
|
-
this.stake = parseFloat(props.stake) || 0;
|
|
2128
|
-
this.delegationsIn = parseFloat(props.delegationsIn) || 0;
|
|
2129
|
-
this.delegationsOut = parseFloat(props.delegationsOut) || 0;
|
|
2130
|
-
this.stakedBalance = this.stake + this.delegationsIn - this.delegationsOut;
|
|
2131
|
-
this.usdValue = props.usdValue;
|
|
2132
|
-
}
|
|
2133
|
-
hasDelegations = () => {
|
|
2134
|
-
if (!this.delegationEnabled) {
|
|
2135
|
-
return false;
|
|
2136
|
-
}
|
|
2137
|
-
return this.delegationsIn > 0 && this.delegationsOut > 0;
|
|
2138
|
-
};
|
|
2139
|
-
delegations = () => {
|
|
2140
|
-
if (!this.hasDelegations()) {
|
|
2141
|
-
return "";
|
|
2142
|
-
}
|
|
2143
|
-
return `(${formattedNumber(this.stake, {
|
|
2144
|
-
fractionDigits: this.precision
|
|
2145
|
-
})} + ${formattedNumber(this.delegationsIn, {
|
|
2146
|
-
fractionDigits: this.precision
|
|
2147
|
-
})} - ${formattedNumber(this.delegationsOut, {
|
|
2148
|
-
fractionDigits: this.precision
|
|
2149
|
-
})})`;
|
|
2150
|
-
};
|
|
2151
|
-
staked = () => {
|
|
2152
|
-
if (!this.stakingEnabled) {
|
|
2153
|
-
return "-";
|
|
2154
|
-
}
|
|
2155
|
-
if (this.stakedBalance < 1e-4) {
|
|
2156
|
-
return this.stakedBalance.toString();
|
|
2157
|
-
}
|
|
2158
|
-
return formattedNumber(this.stakedBalance, {
|
|
2159
|
-
fractionDigits: this.precision
|
|
2160
|
-
});
|
|
2161
|
-
};
|
|
2162
|
-
balanced = () => {
|
|
2163
|
-
if (this.balance < 1e-4) {
|
|
2164
|
-
return this.balance.toString();
|
|
2165
|
-
}
|
|
2166
|
-
return formattedNumber(this.balance, { fractionDigits: this.precision });
|
|
2167
|
-
};
|
|
2168
|
-
};
|
|
2169
|
-
|
|
2170
|
-
// src/modules/assets/hive-engine/queries/get-hive-engine-balances-with-usd-query-options.ts
|
|
2171
|
-
function getHiveEngineBalancesWithUsdQueryOptions(account, dynamicProps, allTokens) {
|
|
2172
|
-
return reactQuery.queryOptions({
|
|
2173
|
-
queryKey: [
|
|
2174
|
-
"assets",
|
|
2175
|
-
"hive-engine",
|
|
2176
|
-
"balances-with-usd",
|
|
2177
|
-
account,
|
|
2178
|
-
dynamicProps,
|
|
2179
|
-
allTokens
|
|
2180
|
-
],
|
|
2181
|
-
queryFn: async () => {
|
|
2182
|
-
if (!account) {
|
|
2183
|
-
throw new Error("[HiveEngine] No account in a balances query");
|
|
2184
|
-
}
|
|
2185
|
-
const balances = await sdk.getHiveEngineTokensBalances(account);
|
|
2186
|
-
const tokens = await sdk.getHiveEngineTokensMetadata(
|
|
2187
|
-
balances.map((t) => t.symbol)
|
|
2188
|
-
);
|
|
2189
|
-
const pricePerHive = dynamicProps ? dynamicProps.base / dynamicProps.quote : 0;
|
|
2190
|
-
const metrics = Array.isArray(
|
|
2191
|
-
allTokens
|
|
2192
|
-
) ? allTokens : [];
|
|
2193
|
-
return balances.map((balance) => {
|
|
2194
|
-
const token = tokens.find((t) => t.symbol === balance.symbol);
|
|
2195
|
-
let tokenMetadata;
|
|
2196
|
-
if (token?.metadata) {
|
|
2197
|
-
try {
|
|
2198
|
-
tokenMetadata = JSON.parse(token.metadata);
|
|
2199
|
-
} catch {
|
|
2200
|
-
tokenMetadata = void 0;
|
|
2201
|
-
}
|
|
2202
|
-
}
|
|
2203
|
-
const metric = metrics.find((m) => m.symbol === balance.symbol);
|
|
2204
|
-
const lastPrice = Number(metric?.lastPrice ?? "0");
|
|
2205
|
-
const balanceAmount = Number(balance.balance);
|
|
2206
|
-
const usdValue = balance.symbol === "SWAP.HIVE" ? pricePerHive * balanceAmount : lastPrice === 0 ? 0 : Number(
|
|
2207
|
-
(lastPrice * pricePerHive * balanceAmount).toFixed(10)
|
|
2208
|
-
);
|
|
2209
|
-
return new HiveEngineToken({
|
|
2210
|
-
symbol: balance.symbol,
|
|
2211
|
-
name: token?.name ?? balance.symbol,
|
|
2212
|
-
icon: tokenMetadata?.icon ?? "",
|
|
2213
|
-
precision: token?.precision ?? 0,
|
|
2214
|
-
stakingEnabled: token?.stakingEnabled ?? false,
|
|
2215
|
-
delegationEnabled: token?.delegationEnabled ?? false,
|
|
2216
|
-
balance: balance.balance,
|
|
2217
|
-
stake: balance.stake,
|
|
2218
|
-
delegationsIn: balance.delegationsIn,
|
|
2219
|
-
delegationsOut: balance.delegationsOut,
|
|
2220
|
-
usdValue
|
|
2221
|
-
});
|
|
2222
|
-
});
|
|
2223
|
-
},
|
|
2224
|
-
enabled: !!account
|
|
2225
|
-
});
|
|
2226
|
-
}
|
|
2227
|
-
function getHiveEngineTokensMetadataQueryOptions(tokens) {
|
|
2228
|
-
return reactQuery.queryOptions({
|
|
2229
|
-
queryKey: ["assets", "hive-engine", "metadata-list", tokens],
|
|
2230
|
-
staleTime: 6e4,
|
|
2231
|
-
refetchInterval: 9e4,
|
|
2232
|
-
queryFn: async () => {
|
|
2233
|
-
return sdk.getHiveEngineTokensMetadata(tokens);
|
|
2234
|
-
}
|
|
2235
|
-
});
|
|
2236
|
-
}
|
|
2237
|
-
function getHiveEngineTokensBalancesQueryOptions(username) {
|
|
2238
|
-
return reactQuery.queryOptions({
|
|
2239
|
-
queryKey: ["assets", "hive-engine", "balances", username],
|
|
2240
|
-
staleTime: 6e4,
|
|
2241
|
-
refetchInterval: 9e4,
|
|
2242
|
-
queryFn: async () => {
|
|
2243
|
-
return sdk.getHiveEngineTokensBalances(username);
|
|
2244
|
-
}
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
function getHiveEngineTokensMarketQueryOptions() {
|
|
2248
|
-
return reactQuery.queryOptions({
|
|
2249
|
-
queryKey: ["assets", "hive-engine", "markets"],
|
|
2250
|
-
staleTime: 6e4,
|
|
2251
|
-
refetchInterval: 9e4,
|
|
2252
|
-
queryFn: async () => {
|
|
2253
|
-
return sdk.getHiveEngineTokensMarket();
|
|
2254
|
-
}
|
|
2255
|
-
});
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
// src/modules/assets/hive-engine/queries/get-hive-engine-token-general-info-query-options.ts
|
|
2259
|
-
function getHiveEngineTokenGeneralInfoQueryOptions(username, symbol) {
|
|
2260
|
-
return reactQuery.queryOptions({
|
|
2261
|
-
queryKey: ["assets", "hive-engine", symbol, "general-info", username],
|
|
2262
|
-
enabled: !!symbol && !!username,
|
|
2263
|
-
staleTime: 6e4,
|
|
2264
|
-
refetchInterval: 9e4,
|
|
2265
|
-
queryFn: async () => {
|
|
2266
|
-
if (!symbol || !username) {
|
|
2267
|
-
throw new Error(
|
|
2268
|
-
"[SDK][Wallets] \u2013 hive engine token or username missed"
|
|
2269
|
-
);
|
|
2270
|
-
}
|
|
2271
|
-
const queryClient = sdk.getQueryClient();
|
|
2272
|
-
const hiveQuery = getHiveAssetGeneralInfoQueryOptions(username);
|
|
2273
|
-
await queryClient.prefetchQuery(hiveQuery);
|
|
2274
|
-
const hiveData = queryClient.getQueryData(
|
|
2275
|
-
hiveQuery.queryKey
|
|
2276
|
-
);
|
|
2277
|
-
const metadataList = await queryClient.ensureQueryData(
|
|
2278
|
-
getHiveEngineTokensMetadataQueryOptions([symbol])
|
|
2279
|
-
);
|
|
2280
|
-
const balanceList = await queryClient.ensureQueryData(
|
|
2281
|
-
getHiveEngineTokensBalancesQueryOptions(username)
|
|
2282
|
-
);
|
|
2283
|
-
const marketList = await queryClient.ensureQueryData(
|
|
2284
|
-
getHiveEngineTokensMarketQueryOptions()
|
|
2285
|
-
);
|
|
2286
|
-
const metadata = metadataList?.find((i) => i.symbol === symbol);
|
|
2287
|
-
const balance = balanceList?.find((i) => i.symbol === symbol);
|
|
2288
|
-
const market = marketList?.find((i) => i.symbol === symbol);
|
|
2289
|
-
const lastPrice = +(market?.lastPrice ?? "0");
|
|
2290
|
-
const liquidBalance = parseFloat(balance?.balance ?? "0");
|
|
2291
|
-
const stakedBalance = parseFloat(balance?.stake ?? "0");
|
|
2292
|
-
const unstakingBalance = parseFloat(balance?.pendingUnstake ?? "0");
|
|
2293
|
-
const parts = [
|
|
2294
|
-
{ name: "liquid", balance: liquidBalance },
|
|
2295
|
-
{ name: "staked", balance: stakedBalance }
|
|
2296
|
-
];
|
|
2297
|
-
if (unstakingBalance > 0) {
|
|
2298
|
-
parts.push({ name: "unstaking", balance: unstakingBalance });
|
|
2299
|
-
}
|
|
2300
|
-
return {
|
|
2301
|
-
name: symbol,
|
|
2302
|
-
title: metadata?.name ?? "",
|
|
2303
|
-
price: lastPrice === 0 ? 0 : Number(lastPrice * (hiveData?.price ?? 0)),
|
|
2304
|
-
accountBalance: liquidBalance + stakedBalance,
|
|
2305
|
-
layer: "ENGINE",
|
|
2306
|
-
parts
|
|
2307
|
-
};
|
|
2308
|
-
}
|
|
2309
|
-
});
|
|
2310
|
-
}
|
|
2311
|
-
function getHiveEngineTokenTransactionsQueryOptions(username, symbol, limit = 20) {
|
|
2312
|
-
return reactQuery.infiniteQueryOptions({
|
|
2313
|
-
queryKey: ["assets", "hive-engine", symbol, "transactions", username],
|
|
2314
|
-
enabled: !!symbol && !!username,
|
|
2315
|
-
initialPageParam: 0,
|
|
2316
|
-
getNextPageParam: (lastPage) => (lastPage?.length ?? 0) + limit,
|
|
2317
|
-
queryFn: async ({ pageParam }) => {
|
|
2318
|
-
if (!symbol || !username) {
|
|
2319
|
-
throw new Error(
|
|
2320
|
-
"[SDK][Wallets] \u2013 hive engine token or username missed"
|
|
2321
|
-
);
|
|
2322
|
-
}
|
|
2323
|
-
return sdk.getHiveEngineTokenTransactions(
|
|
2324
|
-
username,
|
|
2325
|
-
symbol,
|
|
2326
|
-
limit,
|
|
2327
|
-
pageParam
|
|
2328
|
-
);
|
|
2329
|
-
}
|
|
2330
|
-
});
|
|
2331
|
-
}
|
|
2332
|
-
function getHiveEngineTokensMetricsQueryOptions(symbol, interval = "daily") {
|
|
2333
|
-
return reactQuery.queryOptions({
|
|
2334
|
-
queryKey: ["assets", "hive-engine", symbol],
|
|
2335
|
-
staleTime: 6e4,
|
|
2336
|
-
refetchInterval: 9e4,
|
|
2337
|
-
queryFn: async () => {
|
|
2338
|
-
return sdk.getHiveEngineTokenMetrics(symbol, interval);
|
|
2339
|
-
}
|
|
2340
|
-
});
|
|
2341
|
-
}
|
|
2342
|
-
function getHiveEngineUnclaimedRewardsQueryOptions(username) {
|
|
2343
|
-
return reactQuery.queryOptions({
|
|
2344
|
-
queryKey: ["assets", "hive-engine", "unclaimed", username],
|
|
2345
|
-
staleTime: 6e4,
|
|
2346
|
-
refetchInterval: 9e4,
|
|
2347
|
-
enabled: !!username,
|
|
2348
|
-
queryFn: async () => {
|
|
2349
|
-
try {
|
|
2350
|
-
const data = await sdk.getHiveEngineUnclaimedRewards(
|
|
2351
|
-
username
|
|
2352
|
-
);
|
|
2353
|
-
return Object.values(data).filter(
|
|
2354
|
-
({ pending_token }) => pending_token > 0
|
|
2355
|
-
);
|
|
2356
|
-
} catch (e) {
|
|
2357
|
-
return [];
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
});
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
// src/modules/assets/hive-engine/mutations/broadcast-hive-engine-operation.ts
|
|
2364
|
-
async function broadcastHiveEngineOperation(payload, operation, auth) {
|
|
2365
|
-
if (payload.type === "keychain") {
|
|
2366
|
-
if (auth?.broadcast) {
|
|
2367
|
-
return auth.broadcast([operation], "active");
|
|
2368
|
-
}
|
|
2369
|
-
return broadcastWithKeychainFallback(payload.from, [operation], "Active");
|
|
2370
|
-
}
|
|
2371
|
-
if (payload.type === "hiveauth") {
|
|
2372
|
-
if (auth?.broadcast) {
|
|
2373
|
-
return auth.broadcast([operation], "active");
|
|
2374
|
-
}
|
|
2375
|
-
return broadcastWithWalletHiveAuth(payload.from, [operation], "active");
|
|
2376
|
-
}
|
|
2377
|
-
throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
|
|
2378
|
-
}
|
|
2379
|
-
|
|
2380
|
-
// src/modules/assets/hive-engine/mutations/delegate.ts
|
|
2381
|
-
async function delegateEngineToken(payload, auth) {
|
|
2382
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
2383
|
-
const quantity = parsedAsset.amount.toString();
|
|
2384
|
-
const operation = [
|
|
2385
|
-
"custom_json",
|
|
2386
|
-
{
|
|
2387
|
-
id: "ssc-mainnet-hive",
|
|
2388
|
-
required_auths: [payload.from],
|
|
2389
|
-
required_posting_auths: [],
|
|
2390
|
-
json: JSON.stringify({
|
|
2391
|
-
contractName: "tokens",
|
|
2392
|
-
contractAction: "delegate",
|
|
2393
|
-
contractPayload: {
|
|
2394
|
-
symbol: payload.asset,
|
|
2395
|
-
to: payload.to,
|
|
2396
|
-
quantity
|
|
2397
|
-
}
|
|
2398
|
-
})
|
|
2399
|
-
}
|
|
2400
|
-
];
|
|
2401
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2402
|
-
const { key, type, ...params } = payload;
|
|
2403
|
-
const op = {
|
|
2404
|
-
id: "ssc-mainnet-hive",
|
|
2405
|
-
json: JSON.stringify({
|
|
2406
|
-
contractName: "tokens",
|
|
2407
|
-
contractAction: "delegate",
|
|
2408
|
-
contractPayload: {
|
|
2409
|
-
symbol: params.asset,
|
|
2410
|
-
to: params.to,
|
|
2411
|
-
quantity
|
|
2412
|
-
}
|
|
2413
|
-
}),
|
|
2414
|
-
required_auths: [params.from],
|
|
2415
|
-
required_posting_auths: []
|
|
2416
|
-
};
|
|
2417
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
2418
|
-
} else if (payload.type === "keychain" || payload.type === "hiveauth") {
|
|
2419
|
-
return broadcastHiveEngineOperation(payload, operation, auth);
|
|
2420
|
-
} else {
|
|
2421
|
-
return hs__default.default.sendOperation(
|
|
2422
|
-
operation,
|
|
2423
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
2424
|
-
() => {
|
|
2425
|
-
}
|
|
2426
|
-
);
|
|
2427
|
-
}
|
|
2428
|
-
}
|
|
2429
|
-
async function undelegateEngineToken(payload, auth) {
|
|
2430
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
2431
|
-
const quantity = parsedAsset.amount.toString();
|
|
2432
|
-
const operation = [
|
|
2433
|
-
"custom_json",
|
|
2434
|
-
{
|
|
2435
|
-
id: "ssc-mainnet-hive",
|
|
2436
|
-
required_auths: [payload.from],
|
|
2437
|
-
required_posting_auths: [],
|
|
2438
|
-
json: JSON.stringify({
|
|
2439
|
-
contractName: "tokens",
|
|
2440
|
-
contractAction: "undelegate",
|
|
2441
|
-
contractPayload: {
|
|
2442
|
-
symbol: payload.asset,
|
|
2443
|
-
from: payload.to,
|
|
2444
|
-
quantity
|
|
2445
|
-
}
|
|
2446
|
-
})
|
|
2447
|
-
}
|
|
2448
|
-
];
|
|
2449
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2450
|
-
const { key, type, ...params } = payload;
|
|
2451
|
-
const op = {
|
|
2452
|
-
id: "ssc-mainnet-hive",
|
|
2453
|
-
json: JSON.stringify({
|
|
2454
|
-
contractName: "tokens",
|
|
2455
|
-
contractAction: "undelegate",
|
|
2456
|
-
contractPayload: {
|
|
2457
|
-
symbol: params.asset,
|
|
2458
|
-
from: params.to,
|
|
2459
|
-
quantity
|
|
2460
|
-
}
|
|
2461
|
-
}),
|
|
2462
|
-
required_auths: [params.from],
|
|
2463
|
-
required_posting_auths: []
|
|
2464
|
-
};
|
|
2465
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
2466
|
-
} else if (payload.type === "keychain" || payload.type === "hiveauth") {
|
|
2467
|
-
return broadcastHiveEngineOperation(payload, operation, auth);
|
|
2468
|
-
} else {
|
|
2469
|
-
return hs__default.default.sendOperation(
|
|
2470
|
-
operation,
|
|
2471
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
2472
|
-
() => {
|
|
2473
|
-
}
|
|
2474
|
-
);
|
|
2475
|
-
}
|
|
2476
|
-
}
|
|
2477
|
-
async function stakeEngineToken(payload, auth) {
|
|
2478
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
2479
|
-
const quantity = parsedAsset.amount.toString();
|
|
2480
|
-
const operation = [
|
|
2481
|
-
"custom_json",
|
|
2482
|
-
{
|
|
2483
|
-
id: "ssc-mainnet-hive",
|
|
2484
|
-
required_auths: [payload.from],
|
|
2485
|
-
required_posting_auths: [],
|
|
2486
|
-
json: JSON.stringify({
|
|
2487
|
-
contractName: "tokens",
|
|
2488
|
-
contractAction: "stake",
|
|
2489
|
-
contractPayload: {
|
|
2490
|
-
symbol: payload.asset,
|
|
2491
|
-
to: payload.to,
|
|
2492
|
-
quantity
|
|
2493
|
-
}
|
|
2494
|
-
})
|
|
2495
|
-
}
|
|
2496
|
-
];
|
|
2497
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2498
|
-
const { key, type, ...params } = payload;
|
|
2499
|
-
const op = {
|
|
2500
|
-
id: "ssc-mainnet-hive",
|
|
2501
|
-
json: JSON.stringify({
|
|
2502
|
-
contractName: "tokens",
|
|
2503
|
-
contractAction: "stake",
|
|
2504
|
-
contractPayload: {
|
|
2505
|
-
symbol: params.asset,
|
|
2506
|
-
to: params.to,
|
|
2507
|
-
quantity
|
|
2508
|
-
}
|
|
2509
|
-
}),
|
|
2510
|
-
required_auths: [params.from],
|
|
2511
|
-
required_posting_auths: []
|
|
2512
|
-
};
|
|
2513
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
2514
|
-
} else if (payload.type === "keychain" || payload.type === "hiveauth") {
|
|
2515
|
-
return broadcastHiveEngineOperation(payload, operation, auth);
|
|
2516
|
-
} else {
|
|
2517
|
-
return hs__default.default.sendOperation(
|
|
2518
|
-
operation,
|
|
2519
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
2520
|
-
() => {
|
|
2521
|
-
}
|
|
2522
|
-
);
|
|
2523
|
-
}
|
|
2524
|
-
}
|
|
2525
|
-
async function unstakeEngineToken(payload, auth) {
|
|
2526
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
2527
|
-
const quantity = parsedAsset.amount.toString();
|
|
2528
|
-
const operation = [
|
|
2529
|
-
"custom_json",
|
|
2530
|
-
{
|
|
2531
|
-
id: "ssc-mainnet-hive",
|
|
2532
|
-
required_auths: [payload.from],
|
|
2533
|
-
required_posting_auths: [],
|
|
2534
|
-
json: JSON.stringify({
|
|
2535
|
-
contractName: "tokens",
|
|
2536
|
-
contractAction: "unstake",
|
|
2537
|
-
contractPayload: {
|
|
2538
|
-
symbol: payload.asset,
|
|
2539
|
-
to: payload.to,
|
|
2540
|
-
quantity
|
|
2541
|
-
}
|
|
2542
|
-
})
|
|
2543
|
-
}
|
|
2544
|
-
];
|
|
2545
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2546
|
-
const { key, type, ...params } = payload;
|
|
2547
|
-
const op = {
|
|
2548
|
-
id: "ssc-mainnet-hive",
|
|
2549
|
-
json: JSON.stringify({
|
|
2550
|
-
contractName: "tokens",
|
|
2551
|
-
contractAction: "unstake",
|
|
2552
|
-
contractPayload: {
|
|
2553
|
-
symbol: params.asset,
|
|
2554
|
-
to: params.to,
|
|
2555
|
-
quantity
|
|
2556
|
-
}
|
|
2557
|
-
}),
|
|
2558
|
-
required_auths: [params.from],
|
|
2559
|
-
required_posting_auths: []
|
|
2560
|
-
};
|
|
2561
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
2562
|
-
} else if (payload.type === "keychain" || payload.type === "hiveauth") {
|
|
2563
|
-
return broadcastHiveEngineOperation(payload, operation, auth);
|
|
2564
|
-
} else {
|
|
2565
|
-
return hs__default.default.sendOperation(
|
|
2566
|
-
operation,
|
|
2567
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
2568
|
-
() => {
|
|
2569
|
-
}
|
|
2570
|
-
);
|
|
2571
|
-
}
|
|
2572
|
-
}
|
|
2573
|
-
async function transferEngineToken(payload, auth) {
|
|
2574
|
-
const parsedAsset = parseAsset(payload.amount);
|
|
2575
|
-
const quantity = parsedAsset.amount.toString();
|
|
2576
|
-
const operation = [
|
|
2577
|
-
"custom_json",
|
|
2578
|
-
{
|
|
2579
|
-
id: "ssc-mainnet-hive",
|
|
2580
|
-
required_auths: [payload.from],
|
|
2581
|
-
required_posting_auths: [],
|
|
2582
|
-
json: JSON.stringify({
|
|
2583
|
-
contractName: "tokens",
|
|
2584
|
-
contractAction: "transfer",
|
|
2585
|
-
contractPayload: {
|
|
2586
|
-
symbol: payload.asset,
|
|
2587
|
-
to: payload.to,
|
|
2588
|
-
quantity,
|
|
2589
|
-
memo: payload.memo
|
|
2590
|
-
}
|
|
2591
|
-
})
|
|
2592
|
-
}
|
|
2593
|
-
];
|
|
2594
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2595
|
-
const { key, type, ...params } = payload;
|
|
2596
|
-
const op = {
|
|
2597
|
-
id: "ssc-mainnet-hive",
|
|
2598
|
-
json: JSON.stringify({
|
|
2599
|
-
contractName: "tokens",
|
|
2600
|
-
contractAction: "transfer",
|
|
2601
|
-
contractPayload: {
|
|
2602
|
-
symbol: params.asset,
|
|
2603
|
-
to: params.to,
|
|
2604
|
-
quantity,
|
|
2605
|
-
memo: params.memo
|
|
2606
|
-
}
|
|
2607
|
-
}),
|
|
2608
|
-
required_auths: [params.from],
|
|
2609
|
-
required_posting_auths: []
|
|
2610
|
-
};
|
|
2611
|
-
return sdk.CONFIG.hiveClient.broadcast.json(op, key);
|
|
2612
|
-
} else if (payload.type === "keychain" || payload.type === "hiveauth") {
|
|
2613
|
-
return broadcastHiveEngineOperation(payload, operation, auth);
|
|
2614
|
-
} else {
|
|
2615
|
-
return hs__default.default.sendOperation(
|
|
2616
|
-
operation,
|
|
2617
|
-
{ callback: `https://ecency.com/@${payload.from}/wallet` },
|
|
2618
|
-
() => {
|
|
2619
|
-
}
|
|
2620
|
-
);
|
|
2621
|
-
}
|
|
2622
|
-
}
|
|
2623
|
-
var ENGINE_CONTRACT_ID = "ssc-mainnet-hive";
|
|
2624
|
-
function buildEngineOrderPayload(action, symbol, quantity, price) {
|
|
2625
|
-
return {
|
|
2626
|
-
contractName: "market",
|
|
2627
|
-
contractAction: action,
|
|
2628
|
-
contractPayload: { symbol, quantity, price }
|
|
2629
|
-
};
|
|
2630
|
-
}
|
|
2631
|
-
function buildEngineCancelPayload(type, orderId) {
|
|
2632
|
-
return {
|
|
2633
|
-
contractName: "market",
|
|
2634
|
-
contractAction: "cancel",
|
|
2635
|
-
contractPayload: { type, id: orderId }
|
|
2636
|
-
};
|
|
2637
|
-
}
|
|
2638
|
-
function buildEngineOperation(account, payload) {
|
|
2639
|
-
return {
|
|
2640
|
-
id: ENGINE_CONTRACT_ID,
|
|
2641
|
-
required_auths: [account],
|
|
2642
|
-
required_posting_auths: [],
|
|
2643
|
-
json: JSON.stringify(payload)
|
|
2644
|
-
};
|
|
2645
|
-
}
|
|
2646
|
-
async function broadcastEngineOperation(account, payload, options2) {
|
|
2647
|
-
const operation = buildEngineOperation(account, payload);
|
|
2648
|
-
const opTuple = ["custom_json", operation];
|
|
2649
|
-
switch (options2?.method) {
|
|
2650
|
-
case "key": {
|
|
2651
|
-
if (!options2.key) {
|
|
2652
|
-
throw new Error("[SDK][Wallets] \u2013 active key is required");
|
|
2653
|
-
}
|
|
2654
|
-
return sdk.CONFIG.hiveClient.broadcast.json(operation, options2.key);
|
|
2655
|
-
}
|
|
2656
|
-
case "keychain": {
|
|
2657
|
-
if (options2.auth?.broadcast) {
|
|
2658
|
-
return options2.auth.broadcast([opTuple], "active");
|
|
2659
|
-
}
|
|
2660
|
-
return broadcastWithKeychainFallback(account, [opTuple], "Active");
|
|
2661
|
-
}
|
|
2662
|
-
case "hiveauth": {
|
|
2663
|
-
if (options2.auth?.broadcast) {
|
|
2664
|
-
return options2.auth.broadcast([opTuple], "active");
|
|
2665
|
-
}
|
|
2666
|
-
return broadcastWithWalletHiveAuth(account, [opTuple], "active");
|
|
2667
|
-
}
|
|
2668
|
-
case "hivesigner":
|
|
2669
|
-
return hs__default.default.sendOperation(
|
|
2670
|
-
opTuple,
|
|
2671
|
-
{ callback: `https://ecency.com/@${account}/wallet/engine` },
|
|
2672
|
-
() => {
|
|
2673
|
-
}
|
|
2674
|
-
);
|
|
2675
|
-
default:
|
|
2676
|
-
throw new Error("[SDK][Wallets] \u2013 broadcast method is required");
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
var placeHiveEngineBuyOrder = async (account, symbol, quantity, price, options2) => broadcastEngineOperation(
|
|
2680
|
-
account,
|
|
2681
|
-
buildEngineOrderPayload("buy", symbol, quantity, price),
|
|
2682
|
-
options2
|
|
2683
|
-
);
|
|
2684
|
-
var placeHiveEngineSellOrder = async (account, symbol, quantity, price, options2) => broadcastEngineOperation(
|
|
2685
|
-
account,
|
|
2686
|
-
buildEngineOrderPayload("sell", symbol, quantity, price),
|
|
2687
|
-
options2
|
|
2688
|
-
);
|
|
2689
|
-
var cancelHiveEngineOrder = async (account, type, orderId, options2) => broadcastEngineOperation(
|
|
2690
|
-
account,
|
|
2691
|
-
buildEngineCancelPayload(type, orderId),
|
|
2692
|
-
options2
|
|
2693
|
-
);
|
|
2694
|
-
async function claimHiveEngineRewards(payload, auth) {
|
|
2695
|
-
const json = JSON.stringify(payload.tokens.map((symbol) => ({ symbol })));
|
|
2696
|
-
const operation = [
|
|
2697
|
-
"custom_json",
|
|
2698
|
-
{
|
|
2699
|
-
id: "scot_claim_token",
|
|
2700
|
-
required_auths: [],
|
|
2701
|
-
required_posting_auths: [payload.account],
|
|
2702
|
-
json
|
|
2703
|
-
}
|
|
2704
|
-
];
|
|
2705
|
-
if (payload.type === "key" && "key" in payload) {
|
|
2706
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations([operation], payload.key);
|
|
2707
|
-
}
|
|
2708
|
-
if (auth?.broadcast) {
|
|
2709
|
-
return auth.broadcast([operation], "posting");
|
|
2710
|
-
}
|
|
2711
|
-
if (auth?.postingKey) {
|
|
2712
|
-
const key = dhive.PrivateKey.fromString(auth.postingKey);
|
|
2713
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations([operation], key);
|
|
2714
|
-
}
|
|
2715
|
-
if (auth?.accessToken) {
|
|
2716
|
-
const client = new hs__default.default.Client({ accessToken: auth.accessToken });
|
|
2717
|
-
return client.broadcast([operation]);
|
|
2718
|
-
}
|
|
2719
|
-
if (payload.type === "hiveauth") {
|
|
2720
|
-
return broadcastWithWalletHiveAuth(payload.account, [operation], "posting");
|
|
2721
|
-
}
|
|
2722
|
-
throw new Error("[SDK][Wallets] \u2013 cannot broadcast without auth context");
|
|
2723
|
-
}
|
|
2724
|
-
function getPointsQueryOptions(username) {
|
|
2725
|
-
return reactQuery.queryOptions({
|
|
2726
|
-
queryKey: ["assets", "points", username],
|
|
2727
|
-
queryFn: async () => {
|
|
2728
|
-
if (!username) {
|
|
2729
|
-
throw new Error(
|
|
2730
|
-
"[SDK][Wallets][Assets][Points][Query] \u2013 username wasn`t provided"
|
|
2731
|
-
);
|
|
2732
|
-
}
|
|
2733
|
-
const response = await fetch(
|
|
2734
|
-
sdk.CONFIG.privateApiHost + "/private-api/points",
|
|
2735
|
-
{
|
|
2736
|
-
method: "POST",
|
|
2737
|
-
headers: {
|
|
2738
|
-
"Content-Type": "application/json"
|
|
2739
|
-
},
|
|
2740
|
-
body: JSON.stringify({ username })
|
|
2741
|
-
}
|
|
2742
|
-
);
|
|
2743
|
-
const points = await response.json();
|
|
2744
|
-
return {
|
|
2745
|
-
points: points.points,
|
|
2746
|
-
uPoints: points.unclaimed_points
|
|
2747
|
-
};
|
|
2748
|
-
},
|
|
2749
|
-
staleTime: 6e4,
|
|
2750
|
-
refetchInterval: 9e4,
|
|
2751
|
-
refetchOnMount: true,
|
|
2752
|
-
enabled: !!username
|
|
2753
|
-
});
|
|
2754
|
-
}
|
|
2755
|
-
function getPointsAssetGeneralInfoQueryOptions(username) {
|
|
2756
|
-
return reactQuery.queryOptions({
|
|
2757
|
-
queryKey: ["assets", "points", "general-info", username],
|
|
2758
|
-
staleTime: 6e4,
|
|
2759
|
-
refetchInterval: 9e4,
|
|
2760
|
-
queryFn: async () => {
|
|
2761
|
-
await sdk.getQueryClient().prefetchQuery(getPointsQueryOptions(username));
|
|
2762
|
-
const data = sdk.getQueryClient().getQueryData(
|
|
2763
|
-
getPointsQueryOptions(username).queryKey
|
|
2764
|
-
);
|
|
2765
|
-
return {
|
|
2766
|
-
name: "POINTS",
|
|
2767
|
-
title: "Ecency Points",
|
|
2768
|
-
price: 2e-3,
|
|
2769
|
-
accountBalance: +data?.points
|
|
2770
|
-
};
|
|
2771
|
-
}
|
|
2772
|
-
});
|
|
2773
|
-
}
|
|
2774
|
-
function getPointsAssetTransactionsQueryOptions(username, type) {
|
|
2775
|
-
return reactQuery.queryOptions({
|
|
2776
|
-
queryKey: ["assets", "points", "transactions", username, type],
|
|
2777
|
-
queryFn: async () => {
|
|
2778
|
-
const response = await fetch(
|
|
2779
|
-
`${sdk.CONFIG.privateApiHost}/private-api/point-list`,
|
|
2780
|
-
{
|
|
2781
|
-
method: "POST",
|
|
2782
|
-
headers: {
|
|
2783
|
-
"Content-Type": "application/json"
|
|
2784
|
-
},
|
|
2785
|
-
body: JSON.stringify({
|
|
2786
|
-
username,
|
|
2787
|
-
type: type ?? 0
|
|
2788
|
-
})
|
|
2789
|
-
}
|
|
2790
|
-
);
|
|
2791
|
-
const data = await response.json();
|
|
2792
|
-
return data.map(({ created, type: type2, amount, id, sender, receiver, memo }) => ({
|
|
2793
|
-
created: new Date(created),
|
|
2794
|
-
type: type2,
|
|
2795
|
-
results: [
|
|
2796
|
-
{
|
|
2797
|
-
amount: parseFloat(amount),
|
|
2798
|
-
asset: "POINTS"
|
|
2799
|
-
}
|
|
2800
|
-
],
|
|
2801
|
-
id,
|
|
2802
|
-
from: sender ?? void 0,
|
|
2803
|
-
to: receiver ?? void 0,
|
|
2804
|
-
memo: memo ?? void 0
|
|
2805
|
-
}));
|
|
2806
|
-
}
|
|
2807
|
-
});
|
|
2808
|
-
}
|
|
2809
|
-
|
|
2810
|
-
// src/modules/assets/points/mutations/claim-points.ts
|
|
2811
|
-
function useClaimPoints(username, accessToken, onSuccess, onError) {
|
|
2812
|
-
const { mutateAsync: recordActivity } = sdk.EcencyAnalytics.useRecordActivity(
|
|
2813
|
-
username,
|
|
2814
|
-
"points-claimed"
|
|
2815
|
-
);
|
|
2816
|
-
const fetchApi = getBoundFetch();
|
|
2817
|
-
return reactQuery.useMutation({
|
|
2818
|
-
mutationFn: async () => {
|
|
2819
|
-
if (!username) {
|
|
2820
|
-
throw new Error(
|
|
2821
|
-
"[SDK][Wallets][Assets][Points][Claim] \u2013 username wasn't provided"
|
|
2822
|
-
);
|
|
2823
|
-
}
|
|
2824
|
-
if (!accessToken) {
|
|
2825
|
-
throw new Error(
|
|
2826
|
-
"[SDK][Wallets][Assets][Points][Claim] \u2013 access token wasn't found"
|
|
2827
|
-
);
|
|
2828
|
-
}
|
|
2829
|
-
const response = await fetchApi(
|
|
2830
|
-
sdk.CONFIG.privateApiHost + "/private-api/points-claim",
|
|
2831
|
-
{
|
|
2832
|
-
method: "POST",
|
|
2833
|
-
headers: {
|
|
2834
|
-
"Content-Type": "application/json"
|
|
2835
|
-
},
|
|
2836
|
-
body: JSON.stringify({ code: accessToken })
|
|
2837
|
-
}
|
|
2838
|
-
);
|
|
2839
|
-
if (!response.ok) {
|
|
2840
|
-
const body = await response.text();
|
|
2841
|
-
if (response.status === 406) {
|
|
2842
|
-
try {
|
|
2843
|
-
return JSON.parse(body);
|
|
2844
|
-
} catch {
|
|
2845
|
-
return { message: body, code: response.status };
|
|
2846
|
-
}
|
|
2847
|
-
}
|
|
2848
|
-
throw new Error(
|
|
2849
|
-
`[SDK][Wallets][Assets][Points][Claim] \u2013 failed with status ${response.status}${body ? `: ${body}` : ""}`
|
|
2850
|
-
);
|
|
2851
|
-
}
|
|
2852
|
-
return response.json();
|
|
2853
|
-
},
|
|
2854
|
-
onError,
|
|
2855
|
-
onSuccess: () => {
|
|
2856
|
-
recordActivity();
|
|
2857
|
-
sdk.CONFIG.queryClient.setQueryData(
|
|
2858
|
-
getPointsQueryOptions(username).queryKey,
|
|
2859
|
-
(data) => {
|
|
2860
|
-
if (!data) {
|
|
2861
|
-
return data;
|
|
2862
|
-
}
|
|
2863
|
-
return {
|
|
2864
|
-
points: (parseFloat(data.points) + parseFloat(data.uPoints)).toFixed(3),
|
|
2865
|
-
uPoints: "0"
|
|
2866
|
-
};
|
|
2867
|
-
}
|
|
2868
|
-
);
|
|
2869
|
-
onSuccess?.();
|
|
2870
|
-
}
|
|
2871
|
-
});
|
|
2872
|
-
}
|
|
2873
|
-
async function transferPoint({
|
|
2874
|
-
from,
|
|
2875
|
-
to,
|
|
2876
|
-
amount,
|
|
2877
|
-
memo,
|
|
2878
|
-
type,
|
|
2879
|
-
...payload
|
|
2880
|
-
}, auth) {
|
|
2881
|
-
const op = [
|
|
2882
|
-
"custom_json",
|
|
2883
|
-
{
|
|
2884
|
-
id: "ecency_point_transfer",
|
|
2885
|
-
json: JSON.stringify({
|
|
2886
|
-
sender: from,
|
|
2887
|
-
receiver: to,
|
|
2888
|
-
amount: amount.replace("POINTS", "POINT"),
|
|
2889
|
-
memo
|
|
2890
|
-
}),
|
|
2891
|
-
required_auths: [from],
|
|
2892
|
-
required_posting_auths: []
|
|
2893
|
-
}
|
|
2894
|
-
];
|
|
2895
|
-
if (type === "key" && "key" in payload) {
|
|
2896
|
-
const { key } = payload;
|
|
2897
|
-
return sdk.CONFIG.hiveClient.broadcast.sendOperations([op], key);
|
|
2898
|
-
}
|
|
2899
|
-
if (type === "keychain") {
|
|
2900
|
-
if (auth?.broadcast) {
|
|
2901
|
-
return auth.broadcast([op], "active");
|
|
2902
|
-
}
|
|
2903
|
-
throw new Error("[SDK][Wallets] \u2013 missing broadcaster");
|
|
2904
|
-
}
|
|
2905
|
-
if (type === "hiveauth") {
|
|
2906
|
-
if (auth?.broadcast) {
|
|
2907
|
-
return auth.broadcast([op], "active");
|
|
2908
|
-
}
|
|
2909
|
-
return broadcastWithWalletHiveAuth(from, [op], "active");
|
|
2910
|
-
}
|
|
2911
|
-
return hs__default.default.sendOperation(op, { callback: `https://ecency.com/@${from}/wallet` }, () => {
|
|
2912
|
-
});
|
|
2913
|
-
}
|
|
2914
|
-
|
|
2915
|
-
// src/modules/assets/points/types/point-transaction-type.ts
|
|
2916
|
-
var PointTransactionType = /* @__PURE__ */ ((PointTransactionType2) => {
|
|
2917
|
-
PointTransactionType2[PointTransactionType2["CHECKIN"] = 10] = "CHECKIN";
|
|
2918
|
-
PointTransactionType2[PointTransactionType2["LOGIN"] = 20] = "LOGIN";
|
|
2919
|
-
PointTransactionType2[PointTransactionType2["CHECKIN_EXTRA"] = 30] = "CHECKIN_EXTRA";
|
|
2920
|
-
PointTransactionType2[PointTransactionType2["POST"] = 100] = "POST";
|
|
2921
|
-
PointTransactionType2[PointTransactionType2["COMMENT"] = 110] = "COMMENT";
|
|
2922
|
-
PointTransactionType2[PointTransactionType2["VOTE"] = 120] = "VOTE";
|
|
2923
|
-
PointTransactionType2[PointTransactionType2["REBLOG"] = 130] = "REBLOG";
|
|
2924
|
-
PointTransactionType2[PointTransactionType2["DELEGATION"] = 150] = "DELEGATION";
|
|
2925
|
-
PointTransactionType2[PointTransactionType2["REFERRAL"] = 160] = "REFERRAL";
|
|
2926
|
-
PointTransactionType2[PointTransactionType2["COMMUNITY"] = 170] = "COMMUNITY";
|
|
2927
|
-
PointTransactionType2[PointTransactionType2["TRANSFER_SENT"] = 998] = "TRANSFER_SENT";
|
|
2928
|
-
PointTransactionType2[PointTransactionType2["TRANSFER_INCOMING"] = 999] = "TRANSFER_INCOMING";
|
|
2929
|
-
PointTransactionType2[PointTransactionType2["MINTED"] = 991] = "MINTED";
|
|
2930
|
-
return PointTransactionType2;
|
|
2931
|
-
})(PointTransactionType || {});
|
|
2932
606
|
function createFallbackTokenMetadata(symbol) {
|
|
2933
607
|
return {
|
|
2934
608
|
issuer: "",
|
|
@@ -2954,7 +628,7 @@ async function getLayer2TokensMetadata(username) {
|
|
|
2954
628
|
let balances = [];
|
|
2955
629
|
try {
|
|
2956
630
|
balances = await sdk.getQueryClient().fetchQuery(
|
|
2957
|
-
getHiveEngineTokensBalancesQueryOptions(username)
|
|
631
|
+
sdk.getHiveEngineTokensBalancesQueryOptions(username)
|
|
2958
632
|
);
|
|
2959
633
|
} catch {
|
|
2960
634
|
balances = [];
|
|
@@ -2970,669 +644,109 @@ async function getLayer2TokensMetadata(username) {
|
|
|
2970
644
|
let metadataList = [];
|
|
2971
645
|
try {
|
|
2972
646
|
metadataList = await sdk.getQueryClient().fetchQuery(
|
|
2973
|
-
getHiveEngineTokensMetadataQueryOptions(uniqueSymbols)
|
|
2974
|
-
);
|
|
2975
|
-
} catch {
|
|
2976
|
-
metadataList = [];
|
|
2977
|
-
}
|
|
2978
|
-
const metadataBySymbol = new Map(
|
|
2979
|
-
metadataList.map((token) => [token.symbol, token])
|
|
2980
|
-
);
|
|
2981
|
-
return uniqueSymbols.map(
|
|
2982
|
-
(symbol) => metadataBySymbol.get(symbol) ?? createFallbackTokenMetadata(symbol)
|
|
2983
|
-
);
|
|
2984
|
-
}
|
|
2985
|
-
function getAllTokensListQueryOptions(username) {
|
|
2986
|
-
return reactQuery.queryOptions({
|
|
2987
|
-
queryKey: ["ecency-wallets", "all-tokens-list", username ?? null],
|
|
2988
|
-
queryFn: async () => {
|
|
2989
|
-
return {
|
|
2990
|
-
basic: [
|
|
2991
|
-
"POINTS" /* Points */,
|
|
2992
|
-
"HIVE" /* Hive */,
|
|
2993
|
-
"HP" /* HivePower */,
|
|
2994
|
-
"HBD" /* HiveDollar */
|
|
2995
|
-
],
|
|
2996
|
-
external: Object.values(EcencyWalletCurrency),
|
|
2997
|
-
spk: ["SPK", "LARYNX", "LP"],
|
|
2998
|
-
layer2: await getLayer2TokensMetadata(username)
|
|
2999
|
-
};
|
|
3000
|
-
}
|
|
3001
|
-
});
|
|
3002
|
-
}
|
|
3003
|
-
function getVisionPortfolioQueryOptions(username, currency = "usd") {
|
|
3004
|
-
return sdk.getPortfolioQueryOptions(username, currency, true);
|
|
3005
|
-
}
|
|
3006
|
-
|
|
3007
|
-
// src/modules/wallets/queries/use-get-account-wallet-list-query.ts
|
|
3008
|
-
function normalizeAccountTokens(tokens) {
|
|
3009
|
-
if (Array.isArray(tokens)) {
|
|
3010
|
-
return tokens.filter(Boolean);
|
|
3011
|
-
}
|
|
3012
|
-
if (tokens && typeof tokens === "object") {
|
|
3013
|
-
return Object.values(tokens).flatMap(
|
|
3014
|
-
(value) => Array.isArray(value) ? value.filter(Boolean) : []
|
|
3015
|
-
);
|
|
3016
|
-
}
|
|
3017
|
-
return [];
|
|
3018
|
-
}
|
|
3019
|
-
var BASIC_TOKENS = [
|
|
3020
|
-
"POINTS" /* Points */,
|
|
3021
|
-
"HIVE" /* Hive */,
|
|
3022
|
-
"HP" /* HivePower */,
|
|
3023
|
-
"HBD" /* HiveDollar */
|
|
3024
|
-
];
|
|
3025
|
-
function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
3026
|
-
return reactQuery.queryOptions({
|
|
3027
|
-
queryKey: ["ecency-wallets", "list", username, currency],
|
|
3028
|
-
enabled: !!username,
|
|
3029
|
-
queryFn: async () => {
|
|
3030
|
-
const portfolioQuery = getVisionPortfolioQueryOptions(username, currency);
|
|
3031
|
-
const queryClient = sdk.getQueryClient();
|
|
3032
|
-
const accountQuery = sdk.getAccountFullQueryOptions(username);
|
|
3033
|
-
let account;
|
|
3034
|
-
try {
|
|
3035
|
-
account = await queryClient.fetchQuery(accountQuery);
|
|
3036
|
-
} catch {
|
|
3037
|
-
}
|
|
3038
|
-
const tokenVisibility = /* @__PURE__ */ new Map();
|
|
3039
|
-
const accountTokens = normalizeAccountTokens(account?.profile?.tokens);
|
|
3040
|
-
accountTokens.forEach((token) => {
|
|
3041
|
-
const symbol = token.symbol?.toUpperCase?.();
|
|
3042
|
-
if (!symbol) {
|
|
3043
|
-
return;
|
|
3044
|
-
}
|
|
3045
|
-
const showValue = token?.meta?.show;
|
|
3046
|
-
if (typeof showValue === "boolean") {
|
|
3047
|
-
tokenVisibility.set(symbol, showValue);
|
|
3048
|
-
}
|
|
3049
|
-
});
|
|
3050
|
-
const isTokenVisible = (symbol) => {
|
|
3051
|
-
const normalized = symbol?.toUpperCase();
|
|
3052
|
-
if (!normalized) {
|
|
3053
|
-
return false;
|
|
3054
|
-
}
|
|
3055
|
-
if (BASIC_TOKENS.includes(normalized)) {
|
|
3056
|
-
return true;
|
|
3057
|
-
}
|
|
3058
|
-
return tokenVisibility.get(normalized) === true;
|
|
3059
|
-
};
|
|
3060
|
-
try {
|
|
3061
|
-
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3062
|
-
const tokensFromPortfolio = portfolio.wallets.map(
|
|
3063
|
-
(asset) => asset.symbol
|
|
3064
|
-
);
|
|
3065
|
-
if (tokensFromPortfolio.length > 0) {
|
|
3066
|
-
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
3067
|
-
if (visibleTokens.length > 0) {
|
|
3068
|
-
return Array.from(new Set(visibleTokens));
|
|
3069
|
-
}
|
|
3070
|
-
}
|
|
3071
|
-
} catch {
|
|
3072
|
-
}
|
|
3073
|
-
if (accountTokens.length > 0) {
|
|
3074
|
-
const list = [
|
|
3075
|
-
...BASIC_TOKENS,
|
|
3076
|
-
...accountTokens.map((token) => token.symbol).filter(isTokenVisible)
|
|
3077
|
-
];
|
|
3078
|
-
return Array.from(new Set(list).values());
|
|
3079
|
-
}
|
|
3080
|
-
return [...BASIC_TOKENS];
|
|
3081
|
-
}
|
|
3082
|
-
});
|
|
3083
|
-
}
|
|
3084
|
-
|
|
3085
|
-
// src/modules/assets/external/common/parse-private-api-balance.ts
|
|
3086
|
-
function normalizeBalance2(balance) {
|
|
3087
|
-
if (typeof balance === "number") {
|
|
3088
|
-
if (!Number.isFinite(balance)) {
|
|
3089
|
-
throw new Error("Private API returned a non-finite numeric balance");
|
|
3090
|
-
}
|
|
3091
|
-
return Math.trunc(balance).toString();
|
|
3092
|
-
}
|
|
3093
|
-
if (typeof balance === "string") {
|
|
3094
|
-
const trimmed = balance.trim();
|
|
3095
|
-
if (trimmed === "") {
|
|
3096
|
-
throw new Error("Private API returned an empty balance string");
|
|
3097
|
-
}
|
|
3098
|
-
return trimmed;
|
|
3099
|
-
}
|
|
3100
|
-
throw new Error("Private API returned balance in an unexpected format");
|
|
3101
|
-
}
|
|
3102
|
-
function parsePrivateApiBalance2(result, expectedChain) {
|
|
3103
|
-
if (!result || typeof result !== "object") {
|
|
3104
|
-
throw new Error("Private API returned an unexpected response");
|
|
3105
|
-
}
|
|
3106
|
-
const { chain, balance, unit, raw, nodeId } = result;
|
|
3107
|
-
if (typeof chain !== "string" || chain !== expectedChain) {
|
|
3108
|
-
throw new Error("Private API response chain did not match request");
|
|
3109
|
-
}
|
|
3110
|
-
if (typeof unit !== "string" || unit.length === 0) {
|
|
3111
|
-
throw new Error("Private API response is missing unit information");
|
|
3112
|
-
}
|
|
3113
|
-
if (balance === void 0 || balance === null) {
|
|
3114
|
-
throw new Error("Private API response is missing balance information");
|
|
3115
|
-
}
|
|
3116
|
-
const balanceString = normalizeBalance2(balance);
|
|
3117
|
-
let balanceBigInt;
|
|
3118
|
-
try {
|
|
3119
|
-
balanceBigInt = BigInt(balanceString);
|
|
3120
|
-
} catch (error) {
|
|
3121
|
-
throw new Error("Private API returned a balance that is not an integer");
|
|
3122
|
-
}
|
|
3123
|
-
return {
|
|
3124
|
-
chain,
|
|
3125
|
-
unit,
|
|
3126
|
-
raw,
|
|
3127
|
-
nodeId: typeof nodeId === "string" && nodeId.length > 0 ? nodeId : void 0,
|
|
3128
|
-
balanceBigInt,
|
|
3129
|
-
balanceString
|
|
3130
|
-
};
|
|
3131
|
-
}
|
|
3132
|
-
|
|
3133
|
-
// src/modules/assets/external/apt/get-apt-asset-balance-query-options.ts
|
|
3134
|
-
function getAptAssetBalanceQueryOptions(address) {
|
|
3135
|
-
return reactQuery.queryOptions({
|
|
3136
|
-
queryKey: ["assets", "apt", "balance", address],
|
|
3137
|
-
queryFn: async () => {
|
|
3138
|
-
const baseUrl = `${sdk.CONFIG.privateApiHost}/private-api/balance/apt/${encodeURIComponent(
|
|
3139
|
-
address
|
|
3140
|
-
)}`;
|
|
3141
|
-
try {
|
|
3142
|
-
const response = await fetch(baseUrl);
|
|
3143
|
-
if (!response.ok) {
|
|
3144
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3145
|
-
}
|
|
3146
|
-
return +parsePrivateApiBalance2(await response.json(), "apt").balanceString;
|
|
3147
|
-
} catch (error) {
|
|
3148
|
-
console.error(error);
|
|
3149
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3150
|
-
return +parsePrivateApiBalance2(await response.json(), "apt").balanceString;
|
|
3151
|
-
}
|
|
3152
|
-
}
|
|
3153
|
-
});
|
|
3154
|
-
}
|
|
3155
|
-
async function getAddressFromAccount(username, tokenName) {
|
|
3156
|
-
await sdk.CONFIG.queryClient.prefetchQuery(sdk.getAccountFullQueryOptions(username));
|
|
3157
|
-
const account = sdk.CONFIG.queryClient.getQueryData(
|
|
3158
|
-
sdk.getAccountFullQueryOptions(username).queryKey
|
|
3159
|
-
);
|
|
3160
|
-
const address = account?.profile?.tokens?.find((t) => t.symbol === tokenName)?.meta?.address;
|
|
3161
|
-
if (!address) {
|
|
3162
|
-
throw new Error(
|
|
3163
|
-
"[SDK][Wallets] \u2013\xA0cannot fetch APT balance with empty adrress"
|
|
647
|
+
sdk.getHiveEngineTokensMetadataQueryOptions(uniqueSymbols)
|
|
3164
648
|
);
|
|
3165
|
-
}
|
|
3166
|
-
|
|
3167
|
-
}
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
return
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
refetchInterval: 9e4,
|
|
3175
|
-
queryFn: async () => {
|
|
3176
|
-
const address = await getAddressFromAccount(username, "APT");
|
|
3177
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3178
|
-
getAptAssetBalanceQueryOptions(address)
|
|
3179
|
-
);
|
|
3180
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3181
|
-
getAptAssetBalanceQueryOptions(address).queryKey
|
|
3182
|
-
) ?? 0) / 1e8;
|
|
3183
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3184
|
-
getTokenPriceQueryOptions("APT")
|
|
3185
|
-
);
|
|
3186
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3187
|
-
getTokenPriceQueryOptions("APT").queryKey
|
|
3188
|
-
) ?? 0;
|
|
3189
|
-
return {
|
|
3190
|
-
name: "APT",
|
|
3191
|
-
title: "Aptos",
|
|
3192
|
-
price,
|
|
3193
|
-
accountBalance
|
|
3194
|
-
};
|
|
3195
|
-
}
|
|
3196
|
-
});
|
|
3197
|
-
}
|
|
3198
|
-
function getBnbAssetBalanceQueryOptions(address) {
|
|
3199
|
-
return reactQuery.queryOptions({
|
|
3200
|
-
queryKey: ["assets", "bnb", "balance", address],
|
|
3201
|
-
queryFn: async () => {
|
|
3202
|
-
const baseUrl = `${sdk.CONFIG.privateApiHost}/private-api/balance/bnb/${encodeURIComponent(
|
|
3203
|
-
address
|
|
3204
|
-
)}`;
|
|
3205
|
-
try {
|
|
3206
|
-
const response = await fetch(baseUrl);
|
|
3207
|
-
if (!response.ok) {
|
|
3208
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3209
|
-
}
|
|
3210
|
-
return +parsePrivateApiBalance2(await response.json(), "bnb").balanceString;
|
|
3211
|
-
} catch (error) {
|
|
3212
|
-
console.error(error);
|
|
3213
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3214
|
-
return +parsePrivateApiBalance2(await response.json(), "bnb").balanceString;
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
});
|
|
3218
|
-
}
|
|
3219
|
-
|
|
3220
|
-
// src/modules/assets/external/bnb/get-bnb-asset-general-info-query-options.ts
|
|
3221
|
-
function getBnbAssetGeneralInfoQueryOptions(username) {
|
|
3222
|
-
return reactQuery.queryOptions({
|
|
3223
|
-
queryKey: ["assets", "bnb", "general-info", username],
|
|
3224
|
-
staleTime: 6e4,
|
|
3225
|
-
refetchInterval: 9e4,
|
|
3226
|
-
queryFn: async () => {
|
|
3227
|
-
const address = await getAddressFromAccount(username, "BNB");
|
|
3228
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3229
|
-
getBnbAssetBalanceQueryOptions(address)
|
|
3230
|
-
);
|
|
3231
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3232
|
-
getBnbAssetBalanceQueryOptions(address).queryKey
|
|
3233
|
-
) ?? 0) / 1e18;
|
|
3234
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3235
|
-
getTokenPriceQueryOptions("BNB")
|
|
3236
|
-
);
|
|
3237
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3238
|
-
getTokenPriceQueryOptions("BNB").queryKey
|
|
3239
|
-
) ?? 0;
|
|
3240
|
-
return {
|
|
3241
|
-
name: "BNB",
|
|
3242
|
-
title: "Binance coin",
|
|
3243
|
-
price,
|
|
3244
|
-
accountBalance
|
|
3245
|
-
};
|
|
3246
|
-
}
|
|
3247
|
-
});
|
|
3248
|
-
}
|
|
3249
|
-
function getBtcAssetBalanceQueryOptions(address) {
|
|
3250
|
-
return reactQuery.queryOptions({
|
|
3251
|
-
queryKey: ["assets", "btc", "balance", address],
|
|
3252
|
-
queryFn: async () => {
|
|
3253
|
-
const baseUrl = `${sdk.CONFIG.privateApiHost}/private-api/balance/btc/${encodeURIComponent(
|
|
3254
|
-
address
|
|
3255
|
-
)}`;
|
|
3256
|
-
try {
|
|
3257
|
-
const response = await fetch(baseUrl);
|
|
3258
|
-
if (!response.ok) {
|
|
3259
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3260
|
-
}
|
|
3261
|
-
return +parsePrivateApiBalance2(await response.json(), "btc").balanceString;
|
|
3262
|
-
} catch (error) {
|
|
3263
|
-
console.error(error);
|
|
3264
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3265
|
-
return +parsePrivateApiBalance2(await response.json(), "btc").balanceString;
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
|
-
});
|
|
3269
|
-
}
|
|
3270
|
-
|
|
3271
|
-
// src/modules/assets/external/btc/get-btc-asset-general-info-query-options.ts
|
|
3272
|
-
function getBtcAssetGeneralInfoQueryOptions(username) {
|
|
3273
|
-
return reactQuery.queryOptions({
|
|
3274
|
-
queryKey: ["assets", "btc", "general-info", username],
|
|
3275
|
-
staleTime: 6e4,
|
|
3276
|
-
refetchInterval: 9e4,
|
|
3277
|
-
queryFn: async () => {
|
|
3278
|
-
const address = await getAddressFromAccount(username, "BTC");
|
|
3279
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3280
|
-
getBtcAssetBalanceQueryOptions(address)
|
|
3281
|
-
);
|
|
3282
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3283
|
-
getBtcAssetBalanceQueryOptions(address).queryKey
|
|
3284
|
-
) ?? 0) / 1e8;
|
|
3285
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3286
|
-
getTokenPriceQueryOptions("BTC")
|
|
3287
|
-
);
|
|
3288
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3289
|
-
getTokenPriceQueryOptions("BTC").queryKey
|
|
3290
|
-
) ?? 0;
|
|
3291
|
-
return {
|
|
3292
|
-
name: "BTC",
|
|
3293
|
-
title: "Bitcoin",
|
|
3294
|
-
price,
|
|
3295
|
-
accountBalance
|
|
3296
|
-
};
|
|
3297
|
-
}
|
|
3298
|
-
});
|
|
3299
|
-
}
|
|
3300
|
-
function getEthAssetBalanceQueryOptions(address) {
|
|
3301
|
-
return reactQuery.queryOptions({
|
|
3302
|
-
queryKey: ["assets", "eth", "balance", address],
|
|
3303
|
-
queryFn: async () => {
|
|
3304
|
-
const baseUrl = `${sdk.CONFIG.privateApiHost}/private-api/balance/eth/${encodeURIComponent(
|
|
3305
|
-
address
|
|
3306
|
-
)}`;
|
|
3307
|
-
try {
|
|
3308
|
-
const response = await fetch(baseUrl);
|
|
3309
|
-
if (!response.ok) {
|
|
3310
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3311
|
-
}
|
|
3312
|
-
return +parsePrivateApiBalance2(await response.json(), "eth").balanceString;
|
|
3313
|
-
} catch (error) {
|
|
3314
|
-
console.error(error);
|
|
3315
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3316
|
-
return +parsePrivateApiBalance2(await response.json(), "eth").balanceString;
|
|
3317
|
-
}
|
|
3318
|
-
}
|
|
3319
|
-
});
|
|
3320
|
-
}
|
|
3321
|
-
|
|
3322
|
-
// src/modules/assets/external/eth/get-eth-asset-general-info-query-options.ts
|
|
3323
|
-
function getEthAssetGeneralInfoQueryOptions(username) {
|
|
3324
|
-
return reactQuery.queryOptions({
|
|
3325
|
-
queryKey: ["assets", "eth", "general-info", username],
|
|
3326
|
-
staleTime: 6e4,
|
|
3327
|
-
refetchInterval: 9e4,
|
|
3328
|
-
queryFn: async () => {
|
|
3329
|
-
const address = await getAddressFromAccount(username, "ETH");
|
|
3330
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3331
|
-
getEthAssetBalanceQueryOptions(address)
|
|
3332
|
-
);
|
|
3333
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3334
|
-
getEthAssetBalanceQueryOptions(address).queryKey
|
|
3335
|
-
) ?? 0) / 1e18;
|
|
3336
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3337
|
-
getTokenPriceQueryOptions("ETH")
|
|
3338
|
-
);
|
|
3339
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3340
|
-
getTokenPriceQueryOptions("ETH").queryKey
|
|
3341
|
-
) ?? 0;
|
|
3342
|
-
return {
|
|
3343
|
-
name: "ETH",
|
|
3344
|
-
title: "Ethereum",
|
|
3345
|
-
price,
|
|
3346
|
-
accountBalance
|
|
3347
|
-
};
|
|
3348
|
-
}
|
|
3349
|
-
});
|
|
3350
|
-
}
|
|
3351
|
-
function getSolAssetBalanceQueryOptions(address) {
|
|
3352
|
-
return reactQuery.queryOptions({
|
|
3353
|
-
queryKey: ["assets", "sol", "balance", address],
|
|
3354
|
-
queryFn: async () => {
|
|
3355
|
-
const baseUrl = `${sdk.CONFIG.privateApiHost}/private-api/balance/sol/${encodeURIComponent(
|
|
3356
|
-
address
|
|
3357
|
-
)}`;
|
|
3358
|
-
try {
|
|
3359
|
-
const response = await fetch(baseUrl);
|
|
3360
|
-
if (!response.ok) {
|
|
3361
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3362
|
-
}
|
|
3363
|
-
return +parsePrivateApiBalance2(await response.json(), "sol").balanceString;
|
|
3364
|
-
} catch (error) {
|
|
3365
|
-
console.error(error);
|
|
3366
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3367
|
-
return +parsePrivateApiBalance2(await response.json(), "sol").balanceString;
|
|
3368
|
-
}
|
|
3369
|
-
}
|
|
3370
|
-
});
|
|
649
|
+
} catch {
|
|
650
|
+
metadataList = [];
|
|
651
|
+
}
|
|
652
|
+
const metadataBySymbol = new Map(
|
|
653
|
+
metadataList.map((token) => [token.symbol, token])
|
|
654
|
+
);
|
|
655
|
+
return uniqueSymbols.map(
|
|
656
|
+
(symbol) => metadataBySymbol.get(symbol) ?? createFallbackTokenMetadata(symbol)
|
|
657
|
+
);
|
|
3371
658
|
}
|
|
3372
|
-
|
|
3373
|
-
// src/modules/assets/external/sol/get-sol-asset-general-info-query-options.ts
|
|
3374
|
-
function getSolAssetGeneralInfoQueryOptions(username) {
|
|
659
|
+
function getAllTokensListQueryOptions(username) {
|
|
3375
660
|
return reactQuery.queryOptions({
|
|
3376
|
-
queryKey: ["
|
|
3377
|
-
staleTime: 6e4,
|
|
3378
|
-
refetchInterval: 9e4,
|
|
661
|
+
queryKey: ["ecency-wallets", "all-tokens-list", username ?? null],
|
|
3379
662
|
queryFn: async () => {
|
|
3380
|
-
const address = await getAddressFromAccount(username, "SOL");
|
|
3381
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3382
|
-
getSolAssetBalanceQueryOptions(address)
|
|
3383
|
-
);
|
|
3384
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3385
|
-
getSolAssetBalanceQueryOptions(address).queryKey
|
|
3386
|
-
) ?? 0) / 1e9;
|
|
3387
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3388
|
-
getTokenPriceQueryOptions("SOL")
|
|
3389
|
-
);
|
|
3390
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3391
|
-
getTokenPriceQueryOptions("SOL").queryKey
|
|
3392
|
-
) ?? 0;
|
|
3393
663
|
return {
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
664
|
+
basic: [
|
|
665
|
+
"POINTS" /* Points */,
|
|
666
|
+
"HIVE" /* Hive */,
|
|
667
|
+
"HP" /* HivePower */,
|
|
668
|
+
"HBD" /* HiveDollar */
|
|
669
|
+
],
|
|
670
|
+
external: Object.values(EcencyWalletCurrency),
|
|
671
|
+
spk: ["SPK", "LARYNX", "LP"],
|
|
672
|
+
layer2: await getLayer2TokensMetadata(username)
|
|
3398
673
|
};
|
|
3399
674
|
}
|
|
3400
675
|
});
|
|
3401
676
|
}
|
|
3402
|
-
function
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
)
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3413
|
-
}
|
|
3414
|
-
return +parsePrivateApiBalance2(await response.json(), "ton").balanceString;
|
|
3415
|
-
} catch (error) {
|
|
3416
|
-
console.error(error);
|
|
3417
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3418
|
-
return +parsePrivateApiBalance2(await response.json(), "ton").balanceString;
|
|
3419
|
-
}
|
|
3420
|
-
}
|
|
3421
|
-
});
|
|
3422
|
-
}
|
|
3423
|
-
|
|
3424
|
-
// src/modules/assets/external/ton/get-ton-asset-general-info-query-options.ts
|
|
3425
|
-
function getTonAssetGeneralInfoQueryOptions(username) {
|
|
3426
|
-
return reactQuery.queryOptions({
|
|
3427
|
-
queryKey: ["assets", "ton", "general-info", username],
|
|
3428
|
-
staleTime: 6e4,
|
|
3429
|
-
refetchInterval: 9e4,
|
|
3430
|
-
queryFn: async () => {
|
|
3431
|
-
const address = await getAddressFromAccount(username, "TON");
|
|
3432
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3433
|
-
getTonAssetBalanceQueryOptions(address)
|
|
3434
|
-
);
|
|
3435
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3436
|
-
getTonAssetBalanceQueryOptions(address).queryKey
|
|
3437
|
-
) ?? 0) / 1e9;
|
|
3438
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3439
|
-
getTokenPriceQueryOptions("TON")
|
|
3440
|
-
);
|
|
3441
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3442
|
-
getTokenPriceQueryOptions("TON").queryKey
|
|
3443
|
-
) ?? 0;
|
|
3444
|
-
return {
|
|
3445
|
-
name: "TON",
|
|
3446
|
-
title: "The open network",
|
|
3447
|
-
price,
|
|
3448
|
-
accountBalance
|
|
3449
|
-
};
|
|
3450
|
-
}
|
|
3451
|
-
});
|
|
677
|
+
function normalizeAccountTokens(tokens) {
|
|
678
|
+
if (Array.isArray(tokens)) {
|
|
679
|
+
return tokens.filter(Boolean);
|
|
680
|
+
}
|
|
681
|
+
if (tokens && typeof tokens === "object") {
|
|
682
|
+
return Object.values(tokens).flatMap(
|
|
683
|
+
(value) => Array.isArray(value) ? value.filter(Boolean) : []
|
|
684
|
+
);
|
|
685
|
+
}
|
|
686
|
+
return [];
|
|
3452
687
|
}
|
|
3453
|
-
|
|
688
|
+
var BASIC_TOKENS = [
|
|
689
|
+
"POINTS" /* Points */,
|
|
690
|
+
"HIVE" /* Hive */,
|
|
691
|
+
"HP" /* HivePower */,
|
|
692
|
+
"HBD" /* HiveDollar */
|
|
693
|
+
];
|
|
694
|
+
function getAccountWalletListQueryOptions(username, currency = "usd") {
|
|
3454
695
|
return reactQuery.queryOptions({
|
|
3455
|
-
queryKey: ["
|
|
696
|
+
queryKey: ["ecency-wallets", "list", username, currency],
|
|
697
|
+
enabled: !!username,
|
|
3456
698
|
queryFn: async () => {
|
|
3457
|
-
const
|
|
3458
|
-
|
|
3459
|
-
)
|
|
699
|
+
const portfolioQuery = sdk.getPortfolioQueryOptions(username, currency, true);
|
|
700
|
+
const queryClient = sdk.getQueryClient();
|
|
701
|
+
const accountQuery = sdk.getAccountFullQueryOptions(username);
|
|
702
|
+
let account;
|
|
3460
703
|
try {
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
throw new Error(`[SDK][Wallets] \u2013 request failed(${baseUrl})`);
|
|
3464
|
-
}
|
|
3465
|
-
return +parsePrivateApiBalance2(await response.json(), "tron").balanceString;
|
|
3466
|
-
} catch (error) {
|
|
3467
|
-
console.error(error);
|
|
3468
|
-
const response = await fetch(`${baseUrl}?provider=chainz`);
|
|
3469
|
-
return +parsePrivateApiBalance2(await response.json(), "tron").balanceString;
|
|
3470
|
-
}
|
|
3471
|
-
}
|
|
3472
|
-
});
|
|
3473
|
-
}
|
|
3474
|
-
|
|
3475
|
-
// src/modules/assets/external/tron/get-tron-asset-general-info-query-options.ts
|
|
3476
|
-
function getTronAssetGeneralInfoQueryOptions(username) {
|
|
3477
|
-
return reactQuery.queryOptions({
|
|
3478
|
-
queryKey: ["assets", "tron", "general-info", username],
|
|
3479
|
-
staleTime: 6e4,
|
|
3480
|
-
refetchInterval: 9e4,
|
|
3481
|
-
queryFn: async () => {
|
|
3482
|
-
const address = await getAddressFromAccount(username, "TRX");
|
|
3483
|
-
await sdk.CONFIG.queryClient.fetchQuery(
|
|
3484
|
-
getTronAssetBalanceQueryOptions(address)
|
|
3485
|
-
);
|
|
3486
|
-
const accountBalance = (sdk.CONFIG.queryClient.getQueryData(
|
|
3487
|
-
getTronAssetBalanceQueryOptions(address).queryKey
|
|
3488
|
-
) ?? 0) / 1e6;
|
|
3489
|
-
await sdk.CONFIG.queryClient.prefetchQuery(
|
|
3490
|
-
getTokenPriceQueryOptions("TRX")
|
|
3491
|
-
);
|
|
3492
|
-
const price = sdk.CONFIG.queryClient.getQueryData(
|
|
3493
|
-
getTokenPriceQueryOptions("TRX").queryKey
|
|
3494
|
-
) ?? 0;
|
|
3495
|
-
return {
|
|
3496
|
-
name: "TRX",
|
|
3497
|
-
title: "Tron",
|
|
3498
|
-
price,
|
|
3499
|
-
accountBalance
|
|
3500
|
-
};
|
|
3501
|
-
}
|
|
3502
|
-
});
|
|
3503
|
-
}
|
|
3504
|
-
|
|
3505
|
-
// src/modules/wallets/queries/get-account-wallet-asset-info-query-options.ts
|
|
3506
|
-
function getAccountWalletAssetInfoQueryOptions(username, asset, options2 = { refetch: false }) {
|
|
3507
|
-
const queryClient = sdk.getQueryClient();
|
|
3508
|
-
const currency = options2.currency ?? "usd";
|
|
3509
|
-
const fetchQuery = async (queryOptions42) => {
|
|
3510
|
-
if (options2.refetch) {
|
|
3511
|
-
await queryClient.fetchQuery(queryOptions42);
|
|
3512
|
-
} else {
|
|
3513
|
-
await queryClient.prefetchQuery(queryOptions42);
|
|
3514
|
-
}
|
|
3515
|
-
return queryClient.getQueryData(queryOptions42.queryKey);
|
|
3516
|
-
};
|
|
3517
|
-
const convertPriceToUserCurrency = async (assetInfo) => {
|
|
3518
|
-
if (!assetInfo || currency === "usd") {
|
|
3519
|
-
return assetInfo;
|
|
3520
|
-
}
|
|
3521
|
-
try {
|
|
3522
|
-
const conversionRate = await sdk.getCurrencyRate(currency);
|
|
3523
|
-
return {
|
|
3524
|
-
...assetInfo,
|
|
3525
|
-
price: assetInfo.price * conversionRate
|
|
3526
|
-
};
|
|
3527
|
-
} catch (error) {
|
|
3528
|
-
console.warn(`Failed to convert price from USD to ${currency}:`, error);
|
|
3529
|
-
return assetInfo;
|
|
3530
|
-
}
|
|
3531
|
-
};
|
|
3532
|
-
const portfolioQuery = getVisionPortfolioQueryOptions(username, currency);
|
|
3533
|
-
const getPortfolioAssetInfo = async () => {
|
|
3534
|
-
try {
|
|
3535
|
-
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
3536
|
-
const assetInfo = portfolio.wallets.find(
|
|
3537
|
-
(assetItem) => assetItem.symbol.toUpperCase() === asset.toUpperCase()
|
|
3538
|
-
);
|
|
3539
|
-
if (!assetInfo) return void 0;
|
|
3540
|
-
const parts = [];
|
|
3541
|
-
if (assetInfo.liquid !== void 0 && assetInfo.liquid !== null) {
|
|
3542
|
-
parts.push({ name: "liquid", balance: assetInfo.liquid });
|
|
3543
|
-
}
|
|
3544
|
-
if (assetInfo.staked !== void 0 && assetInfo.staked !== null && assetInfo.staked > 0) {
|
|
3545
|
-
parts.push({ name: "staked", balance: assetInfo.staked });
|
|
3546
|
-
}
|
|
3547
|
-
if (assetInfo.savings !== void 0 && assetInfo.savings !== null && assetInfo.savings > 0) {
|
|
3548
|
-
parts.push({ name: "savings", balance: assetInfo.savings });
|
|
704
|
+
account = await queryClient.fetchQuery(accountQuery);
|
|
705
|
+
} catch {
|
|
3549
706
|
}
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
const cleanValue = value.replace(/,/g, "");
|
|
3557
|
-
const match = cleanValue.match(/[+-]?\s*(\d+(?:\.\d+)?)/);
|
|
3558
|
-
if (match) {
|
|
3559
|
-
const numValue = Math.abs(Number.parseFloat(match[1]));
|
|
3560
|
-
if (dataKey === "delegated_hive_power") {
|
|
3561
|
-
parts.push({ name: "outgoing_delegations", balance: numValue });
|
|
3562
|
-
} else if (dataKey === "received_hive_power") {
|
|
3563
|
-
parts.push({ name: "incoming_delegations", balance: numValue });
|
|
3564
|
-
} else if (dataKey === "powering_down_hive_power") {
|
|
3565
|
-
parts.push({ name: "pending_power_down", balance: numValue });
|
|
3566
|
-
}
|
|
3567
|
-
}
|
|
3568
|
-
}
|
|
707
|
+
const tokenVisibility = /* @__PURE__ */ new Map();
|
|
708
|
+
const accountTokens = normalizeAccountTokens(account?.profile?.tokens);
|
|
709
|
+
accountTokens.forEach((token) => {
|
|
710
|
+
const symbol = token.symbol?.toUpperCase?.();
|
|
711
|
+
if (!symbol) {
|
|
712
|
+
return;
|
|
3569
713
|
}
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
714
|
+
const showValue = token?.meta?.show;
|
|
715
|
+
if (typeof showValue === "boolean") {
|
|
716
|
+
tokenVisibility.set(symbol, showValue);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
const isTokenVisible = (symbol) => {
|
|
720
|
+
const normalized = symbol?.toUpperCase();
|
|
721
|
+
if (!normalized) {
|
|
722
|
+
return false;
|
|
723
|
+
}
|
|
724
|
+
if (BASIC_TOKENS.includes(normalized)) {
|
|
725
|
+
return true;
|
|
726
|
+
}
|
|
727
|
+
return tokenVisibility.get(normalized) === true;
|
|
3580
728
|
};
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
return reactQuery.queryOptions({
|
|
3586
|
-
queryKey: ["ecency-wallets", "asset-info", username, asset, currency],
|
|
3587
|
-
queryFn: async () => {
|
|
3588
|
-
const portfolioAssetInfo = await getPortfolioAssetInfo();
|
|
3589
|
-
if (portfolioAssetInfo && portfolioAssetInfo.price > 0) {
|
|
3590
|
-
return portfolioAssetInfo;
|
|
3591
|
-
}
|
|
3592
|
-
let assetInfo;
|
|
3593
|
-
if (asset === "HIVE") {
|
|
3594
|
-
assetInfo = await fetchQuery(getHiveAssetGeneralInfoQueryOptions(username));
|
|
3595
|
-
} else if (asset === "HP") {
|
|
3596
|
-
assetInfo = await fetchQuery(getHivePowerAssetGeneralInfoQueryOptions(username));
|
|
3597
|
-
} else if (asset === "HBD") {
|
|
3598
|
-
assetInfo = await fetchQuery(getHbdAssetGeneralInfoQueryOptions(username));
|
|
3599
|
-
} else if (asset === "SPK") {
|
|
3600
|
-
assetInfo = await fetchQuery(getSpkAssetGeneralInfoQueryOptions(username));
|
|
3601
|
-
} else if (asset === "LARYNX") {
|
|
3602
|
-
assetInfo = await fetchQuery(getLarynxAssetGeneralInfoQueryOptions(username));
|
|
3603
|
-
} else if (asset === "LP") {
|
|
3604
|
-
assetInfo = await fetchQuery(getLarynxPowerAssetGeneralInfoQueryOptions(username));
|
|
3605
|
-
} else if (asset === "POINTS") {
|
|
3606
|
-
assetInfo = await fetchQuery(getPointsAssetGeneralInfoQueryOptions(username));
|
|
3607
|
-
} else if (asset === "APT") {
|
|
3608
|
-
assetInfo = await fetchQuery(getAptAssetGeneralInfoQueryOptions(username));
|
|
3609
|
-
} else if (asset === "BNB") {
|
|
3610
|
-
assetInfo = await fetchQuery(getBnbAssetGeneralInfoQueryOptions(username));
|
|
3611
|
-
} else if (asset === "BTC") {
|
|
3612
|
-
assetInfo = await fetchQuery(getBtcAssetGeneralInfoQueryOptions(username));
|
|
3613
|
-
} else if (asset === "ETH") {
|
|
3614
|
-
assetInfo = await fetchQuery(getEthAssetGeneralInfoQueryOptions(username));
|
|
3615
|
-
} else if (asset === "SOL") {
|
|
3616
|
-
assetInfo = await fetchQuery(getSolAssetGeneralInfoQueryOptions(username));
|
|
3617
|
-
} else if (asset === "TON") {
|
|
3618
|
-
assetInfo = await fetchQuery(getTonAssetGeneralInfoQueryOptions(username));
|
|
3619
|
-
} else if (asset === "TRX") {
|
|
3620
|
-
assetInfo = await fetchQuery(getTronAssetGeneralInfoQueryOptions(username));
|
|
3621
|
-
} else {
|
|
3622
|
-
const balances = await queryClient.ensureQueryData(
|
|
3623
|
-
getHiveEngineTokensBalancesQueryOptions(username)
|
|
729
|
+
try {
|
|
730
|
+
const portfolio = await queryClient.fetchQuery(portfolioQuery);
|
|
731
|
+
const tokensFromPortfolio = portfolio.wallets.map(
|
|
732
|
+
(asset) => asset.symbol
|
|
3624
733
|
);
|
|
3625
|
-
if (
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
throw new Error(
|
|
3631
|
-
"[SDK][Wallets] \u2013 has requested unrecognized asset info"
|
|
3632
|
-
);
|
|
734
|
+
if (tokensFromPortfolio.length > 0) {
|
|
735
|
+
const visibleTokens = tokensFromPortfolio.map((token) => token?.toUpperCase?.()).filter((token) => Boolean(token)).filter(isTokenVisible);
|
|
736
|
+
if (visibleTokens.length > 0) {
|
|
737
|
+
return Array.from(new Set(visibleTokens));
|
|
738
|
+
}
|
|
3633
739
|
}
|
|
740
|
+
} catch {
|
|
741
|
+
}
|
|
742
|
+
if (accountTokens.length > 0) {
|
|
743
|
+
const list = [
|
|
744
|
+
...BASIC_TOKENS,
|
|
745
|
+
...accountTokens.map((token) => token.symbol).filter(isTokenVisible)
|
|
746
|
+
];
|
|
747
|
+
return Array.from(new Set(list).values());
|
|
3634
748
|
}
|
|
3635
|
-
return
|
|
749
|
+
return [...BASIC_TOKENS];
|
|
3636
750
|
}
|
|
3637
751
|
});
|
|
3638
752
|
}
|
|
@@ -3647,7 +761,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3647
761
|
}
|
|
3648
762
|
try {
|
|
3649
763
|
const portfolio = await queryClient.fetchQuery(
|
|
3650
|
-
|
|
764
|
+
sdk.getPortfolioQueryOptions(username, currency, true)
|
|
3651
765
|
);
|
|
3652
766
|
const assetEntry = portfolio.wallets.find(
|
|
3653
767
|
(assetItem) => assetItem.symbol.toUpperCase() === normalizedToken
|
|
@@ -3667,69 +781,69 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3667
781
|
const canonical = id.trim().toLowerCase().replace(/[\s_]+/g, "-");
|
|
3668
782
|
const aliasMap = {
|
|
3669
783
|
// Common operations
|
|
3670
|
-
"transfer":
|
|
3671
|
-
"ecency-point-transfer":
|
|
3672
|
-
"spkcc-spk-send":
|
|
784
|
+
"transfer": sdk.AssetOperation.Transfer,
|
|
785
|
+
"ecency-point-transfer": sdk.AssetOperation.Transfer,
|
|
786
|
+
"spkcc-spk-send": sdk.AssetOperation.Transfer,
|
|
3673
787
|
// Savings operations
|
|
3674
|
-
"transfer-to-savings":
|
|
3675
|
-
"transfer-savings":
|
|
3676
|
-
"savings-transfer":
|
|
3677
|
-
"withdraw-from-savings":
|
|
3678
|
-
"transfer-from-savings":
|
|
3679
|
-
"withdraw-savings":
|
|
3680
|
-
"savings-withdraw":
|
|
788
|
+
"transfer-to-savings": sdk.AssetOperation.TransferToSavings,
|
|
789
|
+
"transfer-savings": sdk.AssetOperation.TransferToSavings,
|
|
790
|
+
"savings-transfer": sdk.AssetOperation.TransferToSavings,
|
|
791
|
+
"withdraw-from-savings": sdk.AssetOperation.WithdrawFromSavings,
|
|
792
|
+
"transfer-from-savings": sdk.AssetOperation.WithdrawFromSavings,
|
|
793
|
+
"withdraw-savings": sdk.AssetOperation.WithdrawFromSavings,
|
|
794
|
+
"savings-withdraw": sdk.AssetOperation.WithdrawFromSavings,
|
|
3681
795
|
// Vesting/Power operations
|
|
3682
|
-
"transfer-to-vesting":
|
|
3683
|
-
"powerup":
|
|
3684
|
-
"power-up":
|
|
3685
|
-
"withdraw-vesting":
|
|
3686
|
-
"power-down":
|
|
3687
|
-
"powerdown":
|
|
796
|
+
"transfer-to-vesting": sdk.AssetOperation.PowerUp,
|
|
797
|
+
"powerup": sdk.AssetOperation.PowerUp,
|
|
798
|
+
"power-up": sdk.AssetOperation.PowerUp,
|
|
799
|
+
"withdraw-vesting": sdk.AssetOperation.PowerDown,
|
|
800
|
+
"power-down": sdk.AssetOperation.PowerDown,
|
|
801
|
+
"powerdown": sdk.AssetOperation.PowerDown,
|
|
3688
802
|
// Delegation
|
|
3689
|
-
"delegate":
|
|
3690
|
-
"delegate-vesting-shares":
|
|
3691
|
-
"hp-delegate":
|
|
3692
|
-
"delegate-hp":
|
|
3693
|
-
"delegate-power":
|
|
3694
|
-
"undelegate":
|
|
3695
|
-
"undelegate-power":
|
|
3696
|
-
"undelegate-token":
|
|
803
|
+
"delegate": sdk.AssetOperation.Delegate,
|
|
804
|
+
"delegate-vesting-shares": sdk.AssetOperation.Delegate,
|
|
805
|
+
"hp-delegate": sdk.AssetOperation.Delegate,
|
|
806
|
+
"delegate-hp": sdk.AssetOperation.Delegate,
|
|
807
|
+
"delegate-power": sdk.AssetOperation.Delegate,
|
|
808
|
+
"undelegate": sdk.AssetOperation.Undelegate,
|
|
809
|
+
"undelegate-power": sdk.AssetOperation.Undelegate,
|
|
810
|
+
"undelegate-token": sdk.AssetOperation.Undelegate,
|
|
3697
811
|
// Staking (Layer 2)
|
|
3698
|
-
"stake":
|
|
3699
|
-
"stake-token":
|
|
3700
|
-
"stake-power":
|
|
3701
|
-
"unstake":
|
|
3702
|
-
"unstake-token":
|
|
3703
|
-
"unstake-power":
|
|
812
|
+
"stake": sdk.AssetOperation.Stake,
|
|
813
|
+
"stake-token": sdk.AssetOperation.Stake,
|
|
814
|
+
"stake-power": sdk.AssetOperation.Stake,
|
|
815
|
+
"unstake": sdk.AssetOperation.Unstake,
|
|
816
|
+
"unstake-token": sdk.AssetOperation.Unstake,
|
|
817
|
+
"unstake-power": sdk.AssetOperation.Unstake,
|
|
3704
818
|
// Swap/Convert
|
|
3705
|
-
"swap":
|
|
3706
|
-
"swap-token":
|
|
3707
|
-
"swap-tokens":
|
|
3708
|
-
"convert":
|
|
819
|
+
"swap": sdk.AssetOperation.Swap,
|
|
820
|
+
"swap-token": sdk.AssetOperation.Swap,
|
|
821
|
+
"swap-tokens": sdk.AssetOperation.Swap,
|
|
822
|
+
"convert": sdk.AssetOperation.Convert,
|
|
3709
823
|
// Points operations
|
|
3710
|
-
"promote":
|
|
3711
|
-
"promote-post":
|
|
3712
|
-
"promote-entry":
|
|
3713
|
-
"boost":
|
|
3714
|
-
"gift":
|
|
3715
|
-
"gift-points":
|
|
3716
|
-
"points-gift":
|
|
3717
|
-
"claim":
|
|
3718
|
-
"claim-rewards":
|
|
3719
|
-
"claim-points":
|
|
3720
|
-
"buy":
|
|
3721
|
-
"buy-points":
|
|
824
|
+
"promote": sdk.AssetOperation.Promote,
|
|
825
|
+
"promote-post": sdk.AssetOperation.Promote,
|
|
826
|
+
"promote-entry": sdk.AssetOperation.Promote,
|
|
827
|
+
"boost": sdk.AssetOperation.Promote,
|
|
828
|
+
"gift": sdk.AssetOperation.Gift,
|
|
829
|
+
"gift-points": sdk.AssetOperation.Gift,
|
|
830
|
+
"points-gift": sdk.AssetOperation.Gift,
|
|
831
|
+
"claim": sdk.AssetOperation.Claim,
|
|
832
|
+
"claim-rewards": sdk.AssetOperation.Claim,
|
|
833
|
+
"claim-points": sdk.AssetOperation.Claim,
|
|
834
|
+
"buy": sdk.AssetOperation.Buy,
|
|
835
|
+
"buy-points": sdk.AssetOperation.Buy,
|
|
3722
836
|
// Other
|
|
3723
|
-
"claim-interest":
|
|
3724
|
-
"withdraw-routes":
|
|
3725
|
-
"withdrawroutes":
|
|
3726
|
-
"lock":
|
|
3727
|
-
"lock-liquidity":
|
|
3728
|
-
"lock-liq":
|
|
837
|
+
"claim-interest": sdk.AssetOperation.ClaimInterest,
|
|
838
|
+
"withdraw-routes": sdk.AssetOperation.WithdrawRoutes,
|
|
839
|
+
"withdrawroutes": sdk.AssetOperation.WithdrawRoutes,
|
|
840
|
+
"lock": sdk.AssetOperation.LockLiquidity,
|
|
841
|
+
"lock-liquidity": sdk.AssetOperation.LockLiquidity,
|
|
842
|
+
"lock-liq": sdk.AssetOperation.LockLiquidity
|
|
3729
843
|
};
|
|
3730
844
|
const mapped = aliasMap[canonical];
|
|
3731
845
|
if (mapped) return mapped;
|
|
3732
|
-
const directMatch = Object.values(AssetOperation).find(
|
|
846
|
+
const directMatch = Object.values(sdk.AssetOperation).find(
|
|
3733
847
|
(op) => op.toLowerCase() === canonical
|
|
3734
848
|
);
|
|
3735
849
|
return directMatch;
|
|
@@ -3739,7 +853,7 @@ function getTokenOperationsQueryOptions(token, username, isForOwner = false, cur
|
|
|
3739
853
|
const hasSavings = Number(rawToken.savings ?? 0) > 0;
|
|
3740
854
|
if (isHiveOrHbd && !hasSavings) {
|
|
3741
855
|
return operations.filter(
|
|
3742
|
-
(operation) => operation !==
|
|
856
|
+
(operation) => operation !== sdk.AssetOperation.WithdrawFromSavings
|
|
3743
857
|
);
|
|
3744
858
|
}
|
|
3745
859
|
return operations;
|
|
@@ -4087,149 +1201,193 @@ function useSaveWalletInformationToMetadata(username, auth, options2) {
|
|
|
4087
1201
|
}
|
|
4088
1202
|
});
|
|
4089
1203
|
}
|
|
4090
|
-
var operationToFunctionMap = {
|
|
4091
|
-
HIVE: {
|
|
4092
|
-
["transfer" /* Transfer */]: transferHive,
|
|
4093
|
-
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
4094
|
-
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
4095
|
-
["power-up" /* PowerUp */]: powerUpHive
|
|
4096
|
-
},
|
|
4097
|
-
HBD: {
|
|
4098
|
-
["transfer" /* Transfer */]: transferHive,
|
|
4099
|
-
["transfer-saving" /* TransferToSavings */]: transferToSavingsHive,
|
|
4100
|
-
["withdraw-saving" /* WithdrawFromSavings */]: transferFromSavingsHive,
|
|
4101
|
-
["claim-interest" /* ClaimInterest */]: claimInterestHive,
|
|
4102
|
-
["convert" /* Convert */]: convertHbd
|
|
4103
|
-
},
|
|
4104
|
-
HP: {
|
|
4105
|
-
["power-down" /* PowerDown */]: powerDownHive,
|
|
4106
|
-
["delegate" /* Delegate */]: delegateHive,
|
|
4107
|
-
["withdraw-routes" /* WithdrawRoutes */]: withdrawVestingRouteHive
|
|
4108
|
-
},
|
|
4109
|
-
POINTS: {
|
|
4110
|
-
["transfer" /* Transfer */]: transferPoint,
|
|
4111
|
-
["gift" /* Gift */]: transferPoint
|
|
4112
|
-
},
|
|
4113
|
-
SPK: {
|
|
4114
|
-
["transfer" /* Transfer */]: transferSpk
|
|
4115
|
-
},
|
|
4116
|
-
LARYNX: {
|
|
4117
|
-
["transfer" /* Transfer */]: transferLarynx,
|
|
4118
|
-
["lock" /* LockLiquidity */]: lockLarynx,
|
|
4119
|
-
["power-up" /* PowerUp */]: powerUpLarynx
|
|
4120
|
-
}
|
|
4121
|
-
};
|
|
4122
|
-
var engineOperationToFunctionMap = {
|
|
4123
|
-
["transfer" /* Transfer */]: transferEngineToken,
|
|
4124
|
-
["stake" /* Stake */]: stakeEngineToken,
|
|
4125
|
-
["unstake" /* Unstake */]: unstakeEngineToken,
|
|
4126
|
-
["delegate" /* Delegate */]: delegateEngineToken,
|
|
4127
|
-
["undelegate" /* Undelegate */]: undelegateEngineToken,
|
|
4128
|
-
["claim" /* Claim */]: (payload, auth) => {
|
|
4129
|
-
return claimHiveEngineRewards(
|
|
4130
|
-
{
|
|
4131
|
-
account: payload.from,
|
|
4132
|
-
tokens: [payload.asset],
|
|
4133
|
-
type: payload.type,
|
|
4134
|
-
...payload.type === "key" && payload.key ? { key: payload.key } : {}
|
|
4135
|
-
},
|
|
4136
|
-
auth
|
|
4137
|
-
);
|
|
4138
|
-
}
|
|
4139
|
-
};
|
|
4140
|
-
function useWalletOperation(username, asset, operation, auth) {
|
|
4141
|
-
const { mutateAsync: recordActivity } = sdk.EcencyAnalytics.useRecordActivity(
|
|
4142
|
-
username,
|
|
4143
|
-
operation
|
|
4144
|
-
);
|
|
4145
|
-
return reactQuery.useMutation({
|
|
4146
|
-
mutationKey: ["ecency-wallets", asset, operation],
|
|
4147
|
-
mutationFn: async (payload) => {
|
|
4148
|
-
const operationFn = operationToFunctionMap[asset]?.[operation];
|
|
4149
|
-
if (operationFn) {
|
|
4150
|
-
return operationFn(payload, auth);
|
|
4151
|
-
}
|
|
4152
|
-
const balancesListQuery = getHiveEngineTokensBalancesQueryOptions(username);
|
|
4153
|
-
await sdk.getQueryClient().prefetchQuery(balancesListQuery);
|
|
4154
|
-
const balances = sdk.getQueryClient().getQueryData(
|
|
4155
|
-
balancesListQuery.queryKey
|
|
4156
|
-
);
|
|
4157
|
-
const engineBalances = balances ?? [];
|
|
4158
|
-
if (engineBalances.some((balance) => balance.symbol === asset)) {
|
|
4159
|
-
const operationFn2 = engineOperationToFunctionMap[operation];
|
|
4160
|
-
if (operationFn2) {
|
|
4161
|
-
return operationFn2({ ...payload, asset }, auth);
|
|
4162
|
-
}
|
|
4163
|
-
}
|
|
4164
|
-
throw new Error("[SDK][Wallets] \u2013 no operation for given asset");
|
|
4165
|
-
},
|
|
4166
|
-
onSuccess: () => {
|
|
4167
|
-
recordActivity();
|
|
4168
|
-
const assetsToRefresh = /* @__PURE__ */ new Set([asset]);
|
|
4169
|
-
if (asset === "HIVE") {
|
|
4170
|
-
assetsToRefresh.add("HP");
|
|
4171
|
-
assetsToRefresh.add("HIVE");
|
|
4172
|
-
}
|
|
4173
|
-
if (asset === "HBD") {
|
|
4174
|
-
assetsToRefresh.add("HBD");
|
|
4175
|
-
}
|
|
4176
|
-
if (asset === "LARYNX" && operation === "power-up" /* PowerUp */) {
|
|
4177
|
-
assetsToRefresh.add("LP");
|
|
4178
|
-
assetsToRefresh.add("LARYNX");
|
|
4179
|
-
}
|
|
4180
|
-
assetsToRefresh.forEach((symbol) => {
|
|
4181
|
-
const query = getAccountWalletAssetInfoQueryOptions(username, symbol, {
|
|
4182
|
-
refetch: true
|
|
4183
|
-
});
|
|
4184
|
-
setTimeout(
|
|
4185
|
-
() => sdk.getQueryClient().invalidateQueries({
|
|
4186
|
-
queryKey: query.queryKey
|
|
4187
|
-
}),
|
|
4188
|
-
5e3
|
|
4189
|
-
);
|
|
4190
|
-
});
|
|
4191
|
-
setTimeout(
|
|
4192
|
-
() => sdk.getQueryClient().invalidateQueries({
|
|
4193
|
-
queryKey: ["ecency-wallets", "portfolio", "v2", username]
|
|
4194
|
-
}),
|
|
4195
|
-
4e3
|
|
4196
|
-
);
|
|
4197
|
-
}
|
|
4198
|
-
});
|
|
4199
|
-
}
|
|
4200
1204
|
|
|
4201
1205
|
// src/index.ts
|
|
4202
1206
|
rememberScryptBsvVersion();
|
|
4203
1207
|
|
|
4204
|
-
Object.defineProperty(exports, "
|
|
1208
|
+
Object.defineProperty(exports, "AssetOperation", {
|
|
1209
|
+
enumerable: true,
|
|
1210
|
+
get: function () { return sdk.AssetOperation; }
|
|
1211
|
+
});
|
|
1212
|
+
Object.defineProperty(exports, "HIVE_ACCOUNT_OPERATION_GROUPS", {
|
|
1213
|
+
enumerable: true,
|
|
1214
|
+
get: function () { return sdk.HIVE_ACCOUNT_OPERATION_GROUPS; }
|
|
1215
|
+
});
|
|
1216
|
+
Object.defineProperty(exports, "HIVE_OPERATION_LIST", {
|
|
1217
|
+
enumerable: true,
|
|
1218
|
+
get: function () { return sdk.HIVE_OPERATION_LIST; }
|
|
1219
|
+
});
|
|
1220
|
+
Object.defineProperty(exports, "HIVE_OPERATION_NAME_BY_ID", {
|
|
1221
|
+
enumerable: true,
|
|
1222
|
+
get: function () { return sdk.HIVE_OPERATION_NAME_BY_ID; }
|
|
1223
|
+
});
|
|
1224
|
+
Object.defineProperty(exports, "HIVE_OPERATION_ORDERS", {
|
|
1225
|
+
enumerable: true,
|
|
1226
|
+
get: function () { return sdk.HIVE_OPERATION_ORDERS; }
|
|
1227
|
+
});
|
|
1228
|
+
Object.defineProperty(exports, "HiveEngineToken", {
|
|
1229
|
+
enumerable: true,
|
|
1230
|
+
get: function () { return sdk.HiveEngineToken; }
|
|
1231
|
+
});
|
|
1232
|
+
Object.defineProperty(exports, "NaiMap", {
|
|
1233
|
+
enumerable: true,
|
|
1234
|
+
get: function () { return sdk.NaiMap; }
|
|
1235
|
+
});
|
|
1236
|
+
Object.defineProperty(exports, "PointTransactionType", {
|
|
1237
|
+
enumerable: true,
|
|
1238
|
+
get: function () { return sdk.PointTransactionType; }
|
|
1239
|
+
});
|
|
1240
|
+
Object.defineProperty(exports, "Symbol", {
|
|
1241
|
+
enumerable: true,
|
|
1242
|
+
get: function () { return sdk.Symbol; }
|
|
1243
|
+
});
|
|
1244
|
+
Object.defineProperty(exports, "formattedNumber", {
|
|
1245
|
+
enumerable: true,
|
|
1246
|
+
get: function () { return sdk.formattedNumber; }
|
|
1247
|
+
});
|
|
1248
|
+
Object.defineProperty(exports, "getAccountWalletAssetInfoQueryOptions", {
|
|
1249
|
+
enumerable: true,
|
|
1250
|
+
get: function () { return sdk.getAccountWalletAssetInfoQueryOptions; }
|
|
1251
|
+
});
|
|
1252
|
+
Object.defineProperty(exports, "getAllHiveEngineTokensQueryOptions", {
|
|
1253
|
+
enumerable: true,
|
|
1254
|
+
get: function () { return sdk.getAllHiveEngineTokensQueryOptions; }
|
|
1255
|
+
});
|
|
1256
|
+
Object.defineProperty(exports, "getHbdAssetGeneralInfoQueryOptions", {
|
|
1257
|
+
enumerable: true,
|
|
1258
|
+
get: function () { return sdk.getHbdAssetGeneralInfoQueryOptions; }
|
|
1259
|
+
});
|
|
1260
|
+
Object.defineProperty(exports, "getHbdAssetTransactionsQueryOptions", {
|
|
1261
|
+
enumerable: true,
|
|
1262
|
+
get: function () { return sdk.getHbdAssetTransactionsQueryOptions; }
|
|
1263
|
+
});
|
|
1264
|
+
Object.defineProperty(exports, "getHiveAssetGeneralInfoQueryOptions", {
|
|
1265
|
+
enumerable: true,
|
|
1266
|
+
get: function () { return sdk.getHiveAssetGeneralInfoQueryOptions; }
|
|
1267
|
+
});
|
|
1268
|
+
Object.defineProperty(exports, "getHiveAssetMetricQueryOptions", {
|
|
1269
|
+
enumerable: true,
|
|
1270
|
+
get: function () { return sdk.getHiveAssetMetricQueryOptions; }
|
|
1271
|
+
});
|
|
1272
|
+
Object.defineProperty(exports, "getHiveAssetTransactionsQueryOptions", {
|
|
1273
|
+
enumerable: true,
|
|
1274
|
+
get: function () { return sdk.getHiveAssetTransactionsQueryOptions; }
|
|
1275
|
+
});
|
|
1276
|
+
Object.defineProperty(exports, "getHiveAssetWithdrawalRoutesQueryOptions", {
|
|
1277
|
+
enumerable: true,
|
|
1278
|
+
get: function () { return sdk.getHiveAssetWithdrawalRoutesQueryOptions; }
|
|
1279
|
+
});
|
|
1280
|
+
Object.defineProperty(exports, "getHiveEngineBalancesWithUsdQueryOptions", {
|
|
1281
|
+
enumerable: true,
|
|
1282
|
+
get: function () { return sdk.getHiveEngineBalancesWithUsdQueryOptions; }
|
|
1283
|
+
});
|
|
1284
|
+
Object.defineProperty(exports, "getHiveEngineTokenGeneralInfoQueryOptions", {
|
|
1285
|
+
enumerable: true,
|
|
1286
|
+
get: function () { return sdk.getHiveEngineTokenGeneralInfoQueryOptions; }
|
|
1287
|
+
});
|
|
1288
|
+
Object.defineProperty(exports, "getHiveEngineTokenTransactionsQueryOptions", {
|
|
1289
|
+
enumerable: true,
|
|
1290
|
+
get: function () { return sdk.getHiveEngineTokenTransactionsQueryOptions; }
|
|
1291
|
+
});
|
|
1292
|
+
Object.defineProperty(exports, "getHiveEngineTokensBalancesQueryOptions", {
|
|
1293
|
+
enumerable: true,
|
|
1294
|
+
get: function () { return sdk.getHiveEngineTokensBalancesQueryOptions; }
|
|
1295
|
+
});
|
|
1296
|
+
Object.defineProperty(exports, "getHiveEngineTokensMarketQueryOptions", {
|
|
1297
|
+
enumerable: true,
|
|
1298
|
+
get: function () { return sdk.getHiveEngineTokensMarketQueryOptions; }
|
|
1299
|
+
});
|
|
1300
|
+
Object.defineProperty(exports, "getHiveEngineTokensMetadataQueryOptions", {
|
|
1301
|
+
enumerable: true,
|
|
1302
|
+
get: function () { return sdk.getHiveEngineTokensMetadataQueryOptions; }
|
|
1303
|
+
});
|
|
1304
|
+
Object.defineProperty(exports, "getHiveEngineTokensMetricsQueryOptions", {
|
|
1305
|
+
enumerable: true,
|
|
1306
|
+
get: function () { return sdk.getHiveEngineTokensMetricsQueryOptions; }
|
|
1307
|
+
});
|
|
1308
|
+
Object.defineProperty(exports, "getHiveEngineUnclaimedRewardsQueryOptions", {
|
|
1309
|
+
enumerable: true,
|
|
1310
|
+
get: function () { return sdk.getHiveEngineUnclaimedRewardsQueryOptions; }
|
|
1311
|
+
});
|
|
1312
|
+
Object.defineProperty(exports, "getHivePowerAssetGeneralInfoQueryOptions", {
|
|
1313
|
+
enumerable: true,
|
|
1314
|
+
get: function () { return sdk.getHivePowerAssetGeneralInfoQueryOptions; }
|
|
1315
|
+
});
|
|
1316
|
+
Object.defineProperty(exports, "getHivePowerAssetTransactionsQueryOptions", {
|
|
1317
|
+
enumerable: true,
|
|
1318
|
+
get: function () { return sdk.getHivePowerAssetTransactionsQueryOptions; }
|
|
1319
|
+
});
|
|
1320
|
+
Object.defineProperty(exports, "getHivePowerDelegatesInfiniteQueryOptions", {
|
|
1321
|
+
enumerable: true,
|
|
1322
|
+
get: function () { return sdk.getHivePowerDelegatesInfiniteQueryOptions; }
|
|
1323
|
+
});
|
|
1324
|
+
Object.defineProperty(exports, "getHivePowerDelegatingsQueryOptions", {
|
|
1325
|
+
enumerable: true,
|
|
1326
|
+
get: function () { return sdk.getHivePowerDelegatingsQueryOptions; }
|
|
1327
|
+
});
|
|
1328
|
+
Object.defineProperty(exports, "getLarynxAssetGeneralInfoQueryOptions", {
|
|
1329
|
+
enumerable: true,
|
|
1330
|
+
get: function () { return sdk.getLarynxAssetGeneralInfoQueryOptions; }
|
|
1331
|
+
});
|
|
1332
|
+
Object.defineProperty(exports, "getLarynxPowerAssetGeneralInfoQueryOptions", {
|
|
1333
|
+
enumerable: true,
|
|
1334
|
+
get: function () { return sdk.getLarynxPowerAssetGeneralInfoQueryOptions; }
|
|
1335
|
+
});
|
|
1336
|
+
Object.defineProperty(exports, "getPointsAssetGeneralInfoQueryOptions", {
|
|
1337
|
+
enumerable: true,
|
|
1338
|
+
get: function () { return sdk.getPointsAssetGeneralInfoQueryOptions; }
|
|
1339
|
+
});
|
|
1340
|
+
Object.defineProperty(exports, "getPointsAssetTransactionsQueryOptions", {
|
|
1341
|
+
enumerable: true,
|
|
1342
|
+
get: function () { return sdk.getPointsAssetTransactionsQueryOptions; }
|
|
1343
|
+
});
|
|
1344
|
+
Object.defineProperty(exports, "getPointsQueryOptions", {
|
|
1345
|
+
enumerable: true,
|
|
1346
|
+
get: function () { return sdk.getPointsQueryOptions; }
|
|
1347
|
+
});
|
|
1348
|
+
Object.defineProperty(exports, "getSpkAssetGeneralInfoQueryOptions", {
|
|
1349
|
+
enumerable: true,
|
|
1350
|
+
get: function () { return sdk.getSpkAssetGeneralInfoQueryOptions; }
|
|
1351
|
+
});
|
|
1352
|
+
Object.defineProperty(exports, "getSpkMarketsQueryOptions", {
|
|
1353
|
+
enumerable: true,
|
|
1354
|
+
get: function () { return sdk.getSpkMarketsQueryOptions; }
|
|
1355
|
+
});
|
|
1356
|
+
Object.defineProperty(exports, "getSpkWalletQueryOptions", {
|
|
1357
|
+
enumerable: true,
|
|
1358
|
+
get: function () { return sdk.getSpkWalletQueryOptions; }
|
|
1359
|
+
});
|
|
1360
|
+
Object.defineProperty(exports, "isEmptyDate", {
|
|
1361
|
+
enumerable: true,
|
|
1362
|
+
get: function () { return sdk.isEmptyDate; }
|
|
1363
|
+
});
|
|
1364
|
+
Object.defineProperty(exports, "parseAsset", {
|
|
1365
|
+
enumerable: true,
|
|
1366
|
+
get: function () { return sdk.parseAsset; }
|
|
1367
|
+
});
|
|
1368
|
+
Object.defineProperty(exports, "resolveHiveOperationFilters", {
|
|
1369
|
+
enumerable: true,
|
|
1370
|
+
get: function () { return sdk.resolveHiveOperationFilters; }
|
|
1371
|
+
});
|
|
1372
|
+
Object.defineProperty(exports, "rewardSpk", {
|
|
4205
1373
|
enumerable: true,
|
|
4206
|
-
get: function () { return sdk.
|
|
1374
|
+
get: function () { return sdk.rewardSpk; }
|
|
4207
1375
|
});
|
|
4208
|
-
Object.defineProperty(exports, "
|
|
1376
|
+
Object.defineProperty(exports, "useClaimPoints", {
|
|
4209
1377
|
enumerable: true,
|
|
4210
|
-
get: function () { return sdk.
|
|
1378
|
+
get: function () { return sdk.useClaimPoints; }
|
|
4211
1379
|
});
|
|
4212
|
-
Object.defineProperty(exports, "
|
|
1380
|
+
Object.defineProperty(exports, "useWalletOperation", {
|
|
4213
1381
|
enumerable: true,
|
|
4214
|
-
get: function () { return sdk.
|
|
1382
|
+
get: function () { return sdk.useWalletOperation; }
|
|
4215
1383
|
});
|
|
4216
|
-
Object.defineProperty(exports, "
|
|
1384
|
+
Object.defineProperty(exports, "vestsToHp", {
|
|
4217
1385
|
enumerable: true,
|
|
4218
|
-
get: function () { return sdk.
|
|
1386
|
+
get: function () { return sdk.vestsToHp; }
|
|
4219
1387
|
});
|
|
4220
|
-
exports.AssetOperation = AssetOperation;
|
|
4221
1388
|
exports.EcencyWalletBasicTokens = EcencyWalletBasicTokens;
|
|
4222
1389
|
exports.EcencyWalletCurrency = EcencyWalletCurrency;
|
|
4223
1390
|
exports.EcencyWalletsPrivateApi = private_api_exports;
|
|
4224
|
-
exports.HIVE_ACCOUNT_OPERATION_GROUPS = HIVE_ACCOUNT_OPERATION_GROUPS;
|
|
4225
|
-
exports.HIVE_OPERATION_LIST = HIVE_OPERATION_LIST;
|
|
4226
|
-
exports.HIVE_OPERATION_NAME_BY_ID = HIVE_OPERATION_NAME_BY_ID;
|
|
4227
|
-
exports.HIVE_OPERATION_ORDERS = HIVE_OPERATION_ORDERS;
|
|
4228
|
-
exports.HiveEngineToken = HiveEngineToken;
|
|
4229
|
-
exports.NaiMap = NaiMap;
|
|
4230
|
-
exports.PointTransactionType = PointTransactionType;
|
|
4231
|
-
exports.Symbol = Symbol2;
|
|
4232
|
-
exports.broadcastWithWalletHiveAuth = broadcastWithWalletHiveAuth;
|
|
4233
1391
|
exports.buildAptTx = buildAptTx;
|
|
4234
1392
|
exports.buildEthTx = buildEthTx;
|
|
4235
1393
|
exports.buildExternalTx = buildExternalTx;
|
|
@@ -4237,15 +1395,9 @@ exports.buildPsbt = buildPsbt;
|
|
|
4237
1395
|
exports.buildSolTx = buildSolTx;
|
|
4238
1396
|
exports.buildTonTx = buildTonTx;
|
|
4239
1397
|
exports.buildTronTx = buildTronTx;
|
|
4240
|
-
exports.cancelHiveEngineOrder = cancelHiveEngineOrder;
|
|
4241
|
-
exports.claimHiveEngineRewards = claimHiveEngineRewards;
|
|
4242
|
-
exports.claimInterestHive = claimInterestHive;
|
|
4243
|
-
exports.convertHbd = convertHbd;
|
|
4244
1398
|
exports.decryptMemoWithAccounts = decryptMemoWithAccounts;
|
|
4245
1399
|
exports.decryptMemoWithKeys = decryptMemoWithKeys;
|
|
4246
1400
|
exports.delay = delay;
|
|
4247
|
-
exports.delegateEngineToken = delegateEngineToken;
|
|
4248
|
-
exports.delegateHive = delegateHive;
|
|
4249
1401
|
exports.deriveHiveKey = deriveHiveKey;
|
|
4250
1402
|
exports.deriveHiveKeys = deriveHiveKeys;
|
|
4251
1403
|
exports.deriveHiveMasterPasswordKey = deriveHiveMasterPasswordKey;
|
|
@@ -4253,81 +1405,24 @@ exports.deriveHiveMasterPasswordKeys = deriveHiveMasterPasswordKeys;
|
|
|
4253
1405
|
exports.detectHiveKeyDerivation = detectHiveKeyDerivation;
|
|
4254
1406
|
exports.encryptMemoWithAccounts = encryptMemoWithAccounts;
|
|
4255
1407
|
exports.encryptMemoWithKeys = encryptMemoWithKeys;
|
|
4256
|
-
exports.formattedNumber = formattedNumber;
|
|
4257
|
-
exports.getAccountWalletAssetInfoQueryOptions = getAccountWalletAssetInfoQueryOptions;
|
|
4258
1408
|
exports.getAccountWalletListQueryOptions = getAccountWalletListQueryOptions;
|
|
4259
|
-
exports.getAllHiveEngineTokensQueryOptions = getAllHiveEngineTokensQueryOptions;
|
|
4260
1409
|
exports.getAllTokensListQueryOptions = getAllTokensListQueryOptions;
|
|
4261
1410
|
exports.getBoundFetch = getBoundFetch;
|
|
4262
|
-
exports.getHbdAssetGeneralInfoQueryOptions = getHbdAssetGeneralInfoQueryOptions;
|
|
4263
|
-
exports.getHbdAssetTransactionsQueryOptions = getHbdAssetTransactionsQueryOptions;
|
|
4264
|
-
exports.getHiveAssetGeneralInfoQueryOptions = getHiveAssetGeneralInfoQueryOptions;
|
|
4265
|
-
exports.getHiveAssetMetricQueryOptions = getHiveAssetMetricQueryOptions;
|
|
4266
|
-
exports.getHiveAssetTransactionsQueryOptions = getHiveAssetTransactionsQueryOptions;
|
|
4267
|
-
exports.getHiveAssetWithdrawalRoutesQueryOptions = getHiveAssetWithdrawalRoutesQueryOptions;
|
|
4268
|
-
exports.getHiveEngineBalancesWithUsdQueryOptions = getHiveEngineBalancesWithUsdQueryOptions;
|
|
4269
|
-
exports.getHiveEngineTokenGeneralInfoQueryOptions = getHiveEngineTokenGeneralInfoQueryOptions;
|
|
4270
|
-
exports.getHiveEngineTokenTransactionsQueryOptions = getHiveEngineTokenTransactionsQueryOptions;
|
|
4271
|
-
exports.getHiveEngineTokensBalancesQueryOptions = getHiveEngineTokensBalancesQueryOptions;
|
|
4272
|
-
exports.getHiveEngineTokensMarketQueryOptions = getHiveEngineTokensMarketQueryOptions;
|
|
4273
|
-
exports.getHiveEngineTokensMetadataQueryOptions = getHiveEngineTokensMetadataQueryOptions;
|
|
4274
|
-
exports.getHiveEngineTokensMetricsQueryOptions = getHiveEngineTokensMetricsQueryOptions;
|
|
4275
|
-
exports.getHiveEngineUnclaimedRewardsQueryOptions = getHiveEngineUnclaimedRewardsQueryOptions;
|
|
4276
|
-
exports.getHivePowerAssetGeneralInfoQueryOptions = getHivePowerAssetGeneralInfoQueryOptions;
|
|
4277
|
-
exports.getHivePowerAssetTransactionsQueryOptions = getHivePowerAssetTransactionsQueryOptions;
|
|
4278
|
-
exports.getHivePowerDelegatesInfiniteQueryOptions = getHivePowerDelegatesInfiniteQueryOptions;
|
|
4279
|
-
exports.getHivePowerDelegatingsQueryOptions = getHivePowerDelegatingsQueryOptions;
|
|
4280
|
-
exports.getLarynxAssetGeneralInfoQueryOptions = getLarynxAssetGeneralInfoQueryOptions;
|
|
4281
|
-
exports.getLarynxPowerAssetGeneralInfoQueryOptions = getLarynxPowerAssetGeneralInfoQueryOptions;
|
|
4282
|
-
exports.getPointsAssetGeneralInfoQueryOptions = getPointsAssetGeneralInfoQueryOptions;
|
|
4283
|
-
exports.getPointsAssetTransactionsQueryOptions = getPointsAssetTransactionsQueryOptions;
|
|
4284
|
-
exports.getPointsQueryOptions = getPointsQueryOptions;
|
|
4285
|
-
exports.getSpkAssetGeneralInfoQueryOptions = getSpkAssetGeneralInfoQueryOptions;
|
|
4286
|
-
exports.getSpkMarketsQueryOptions = getSpkMarketsQueryOptions;
|
|
4287
|
-
exports.getSpkWalletQueryOptions = getSpkWalletQueryOptions;
|
|
4288
1411
|
exports.getTokenOperationsQueryOptions = getTokenOperationsQueryOptions;
|
|
4289
1412
|
exports.getTokenPriceQueryOptions = getTokenPriceQueryOptions;
|
|
4290
|
-
exports.getVisionPortfolioQueryOptions = getVisionPortfolioQueryOptions;
|
|
4291
1413
|
exports.getWallet = getWallet;
|
|
4292
|
-
exports.hasWalletHiveAuthBroadcast = hasWalletHiveAuthBroadcast;
|
|
4293
|
-
exports.isEmptyDate = isEmptyDate;
|
|
4294
|
-
exports.lockLarynx = lockLarynx;
|
|
4295
1414
|
exports.mnemonicToSeedBip39 = mnemonicToSeedBip39;
|
|
4296
|
-
exports.parseAsset = parseAsset;
|
|
4297
|
-
exports.placeHiveEngineBuyOrder = placeHiveEngineBuyOrder;
|
|
4298
|
-
exports.placeHiveEngineSellOrder = placeHiveEngineSellOrder;
|
|
4299
|
-
exports.powerDownHive = powerDownHive;
|
|
4300
|
-
exports.powerUpHive = powerUpHive;
|
|
4301
|
-
exports.powerUpLarynx = powerUpLarynx;
|
|
4302
|
-
exports.registerWalletHiveAuthBroadcast = registerWalletHiveAuthBroadcast;
|
|
4303
|
-
exports.resolveHiveOperationFilters = resolveHiveOperationFilters;
|
|
4304
|
-
exports.rewardSpk = rewardSpk;
|
|
4305
1415
|
exports.signDigest = signDigest;
|
|
4306
1416
|
exports.signExternalTx = signExternalTx;
|
|
4307
1417
|
exports.signExternalTxAndBroadcast = signExternalTxAndBroadcast;
|
|
4308
1418
|
exports.signTx = signTx;
|
|
4309
1419
|
exports.signTxAndBroadcast = signTxAndBroadcast;
|
|
4310
|
-
exports.stakeEngineToken = stakeEngineToken;
|
|
4311
|
-
exports.transferEngineToken = transferEngineToken;
|
|
4312
|
-
exports.transferFromSavingsHive = transferFromSavingsHive;
|
|
4313
|
-
exports.transferHive = transferHive;
|
|
4314
|
-
exports.transferLarynx = transferLarynx;
|
|
4315
|
-
exports.transferPoint = transferPoint;
|
|
4316
|
-
exports.transferSpk = transferSpk;
|
|
4317
|
-
exports.transferToSavingsHive = transferToSavingsHive;
|
|
4318
|
-
exports.undelegateEngineToken = undelegateEngineToken;
|
|
4319
|
-
exports.unstakeEngineToken = unstakeEngineToken;
|
|
4320
|
-
exports.useClaimPoints = useClaimPoints;
|
|
4321
|
-
exports.useClaimRewards = useClaimRewards;
|
|
4322
1420
|
exports.useGetExternalWalletBalanceQuery = useGetExternalWalletBalanceQuery;
|
|
4323
1421
|
exports.useHiveKeysQuery = useHiveKeysQuery;
|
|
4324
1422
|
exports.useImportWallet = useImportWallet;
|
|
4325
1423
|
exports.useSaveWalletInformationToMetadata = useSaveWalletInformationToMetadata;
|
|
4326
1424
|
exports.useSeedPhrase = useSeedPhrase;
|
|
4327
1425
|
exports.useWalletCreate = useWalletCreate;
|
|
4328
|
-
exports.useWalletOperation = useWalletOperation;
|
|
4329
1426
|
exports.useWalletsCacheQuery = useWalletsCacheQuery;
|
|
4330
|
-
exports.vestsToHp = vestsToHp;
|
|
4331
|
-
exports.withdrawVestingRouteHive = withdrawVestingRouteHive;
|
|
4332
1427
|
//# sourceMappingURL=index.cjs.map
|
|
4333
1428
|
//# sourceMappingURL=index.cjs.map
|