@primuslabs/fund-js-sdk 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +384 -133
- package/dist/index.mjs +384 -133
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -617,7 +617,11 @@ var abi_default = [
|
|
|
617
617
|
type: "function",
|
|
618
618
|
name: "addBatchIdSource",
|
|
619
619
|
inputs: [
|
|
620
|
-
{
|
|
620
|
+
{
|
|
621
|
+
name: "sourceName_",
|
|
622
|
+
type: "string[]",
|
|
623
|
+
internalType: "string[]"
|
|
624
|
+
},
|
|
621
625
|
{ name: "url_", type: "string[]", internalType: "string[]" },
|
|
622
626
|
{ name: "jsonPath_", type: "string[]", internalType: "string[]" }
|
|
623
627
|
],
|
|
@@ -634,15 +638,27 @@ var abi_default = [
|
|
|
634
638
|
type: "tuple[]",
|
|
635
639
|
internalType: "struct Attestation[]",
|
|
636
640
|
components: [
|
|
637
|
-
{
|
|
641
|
+
{
|
|
642
|
+
name: "recipient",
|
|
643
|
+
type: "address",
|
|
644
|
+
internalType: "address"
|
|
645
|
+
},
|
|
638
646
|
{
|
|
639
647
|
name: "request",
|
|
640
648
|
type: "tuple",
|
|
641
649
|
internalType: "struct AttNetworkRequest",
|
|
642
650
|
components: [
|
|
643
651
|
{ name: "url", type: "string", internalType: "string" },
|
|
644
|
-
{
|
|
645
|
-
|
|
652
|
+
{
|
|
653
|
+
name: "header",
|
|
654
|
+
type: "string",
|
|
655
|
+
internalType: "string"
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
name: "method",
|
|
659
|
+
type: "string",
|
|
660
|
+
internalType: "string"
|
|
661
|
+
},
|
|
646
662
|
{ name: "body", type: "string", internalType: "string" }
|
|
647
663
|
]
|
|
648
664
|
},
|
|
@@ -651,7 +667,11 @@ var abi_default = [
|
|
|
651
667
|
type: "tuple[]",
|
|
652
668
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
653
669
|
components: [
|
|
654
|
-
{
|
|
670
|
+
{
|
|
671
|
+
name: "keyName",
|
|
672
|
+
type: "string",
|
|
673
|
+
internalType: "string"
|
|
674
|
+
},
|
|
655
675
|
{
|
|
656
676
|
name: "parseType",
|
|
657
677
|
type: "string",
|
|
@@ -689,7 +709,11 @@ var abi_default = [
|
|
|
689
709
|
{ name: "url", type: "string", internalType: "string" }
|
|
690
710
|
]
|
|
691
711
|
},
|
|
692
|
-
{
|
|
712
|
+
{
|
|
713
|
+
name: "signatures",
|
|
714
|
+
type: "bytes[]",
|
|
715
|
+
internalType: "bytes[]"
|
|
716
|
+
}
|
|
693
717
|
]
|
|
694
718
|
}
|
|
695
719
|
],
|
|
@@ -706,15 +730,27 @@ var abi_default = [
|
|
|
706
730
|
type: "tuple",
|
|
707
731
|
internalType: "struct Attestation",
|
|
708
732
|
components: [
|
|
709
|
-
{
|
|
733
|
+
{
|
|
734
|
+
name: "recipient",
|
|
735
|
+
type: "address",
|
|
736
|
+
internalType: "address"
|
|
737
|
+
},
|
|
710
738
|
{
|
|
711
739
|
name: "request",
|
|
712
740
|
type: "tuple",
|
|
713
741
|
internalType: "struct AttNetworkRequest",
|
|
714
742
|
components: [
|
|
715
743
|
{ name: "url", type: "string", internalType: "string" },
|
|
716
|
-
{
|
|
717
|
-
|
|
744
|
+
{
|
|
745
|
+
name: "header",
|
|
746
|
+
type: "string",
|
|
747
|
+
internalType: "string"
|
|
748
|
+
},
|
|
749
|
+
{
|
|
750
|
+
name: "method",
|
|
751
|
+
type: "string",
|
|
752
|
+
internalType: "string"
|
|
753
|
+
},
|
|
718
754
|
{ name: "body", type: "string", internalType: "string" }
|
|
719
755
|
]
|
|
720
756
|
},
|
|
@@ -723,7 +759,11 @@ var abi_default = [
|
|
|
723
759
|
type: "tuple[]",
|
|
724
760
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
725
761
|
components: [
|
|
726
|
-
{
|
|
762
|
+
{
|
|
763
|
+
name: "keyName",
|
|
764
|
+
type: "string",
|
|
765
|
+
internalType: "string"
|
|
766
|
+
},
|
|
727
767
|
{
|
|
728
768
|
name: "parseType",
|
|
729
769
|
type: "string",
|
|
@@ -761,7 +801,11 @@ var abi_default = [
|
|
|
761
801
|
{ name: "url", type: "string", internalType: "string" }
|
|
762
802
|
]
|
|
763
803
|
},
|
|
764
|
-
{
|
|
804
|
+
{
|
|
805
|
+
name: "signatures",
|
|
806
|
+
type: "bytes[]",
|
|
807
|
+
internalType: "bytes[]"
|
|
808
|
+
}
|
|
765
809
|
]
|
|
766
810
|
}
|
|
767
811
|
],
|
|
@@ -770,94 +814,105 @@ var abi_default = [
|
|
|
770
814
|
},
|
|
771
815
|
{
|
|
772
816
|
type: "function",
|
|
773
|
-
name: "
|
|
817
|
+
name: "claimFee",
|
|
818
|
+
inputs: [],
|
|
819
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
820
|
+
stateMutability: "view"
|
|
821
|
+
},
|
|
822
|
+
{
|
|
823
|
+
type: "function",
|
|
824
|
+
name: "feeRecipient",
|
|
825
|
+
inputs: [],
|
|
826
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
827
|
+
stateMutability: "view"
|
|
828
|
+
},
|
|
829
|
+
{
|
|
830
|
+
type: "function",
|
|
831
|
+
name: "getTipRecords",
|
|
774
832
|
inputs: [
|
|
775
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
776
833
|
{
|
|
777
|
-
name: "
|
|
834
|
+
name: "tipRecipient",
|
|
778
835
|
type: "tuple",
|
|
779
|
-
internalType: "struct
|
|
836
|
+
internalType: "struct TipRecipient",
|
|
780
837
|
components: [
|
|
781
|
-
{ name: "
|
|
838
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
839
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
840
|
+
]
|
|
841
|
+
}
|
|
842
|
+
],
|
|
843
|
+
outputs: [
|
|
844
|
+
{
|
|
845
|
+
name: "",
|
|
846
|
+
type: "tuple[]",
|
|
847
|
+
internalType: "struct TipRecord[]",
|
|
848
|
+
components: [
|
|
849
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
782
850
|
{
|
|
783
|
-
name: "
|
|
851
|
+
name: "tipToken",
|
|
784
852
|
type: "tuple",
|
|
785
|
-
internalType: "struct
|
|
786
|
-
components: [
|
|
787
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
788
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
789
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
790
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
791
|
-
]
|
|
792
|
-
},
|
|
793
|
-
{
|
|
794
|
-
name: "reponseResolve",
|
|
795
|
-
type: "tuple[]",
|
|
796
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
853
|
+
internalType: "struct TipToken",
|
|
797
854
|
components: [
|
|
798
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
799
855
|
{
|
|
800
|
-
name: "
|
|
801
|
-
type: "
|
|
802
|
-
internalType: "
|
|
856
|
+
name: "tokenType",
|
|
857
|
+
type: "uint32",
|
|
858
|
+
internalType: "uint32"
|
|
803
859
|
},
|
|
804
860
|
{
|
|
805
|
-
name: "
|
|
806
|
-
type: "
|
|
807
|
-
internalType: "
|
|
861
|
+
name: "tokenAddress",
|
|
862
|
+
type: "address",
|
|
863
|
+
internalType: "address"
|
|
808
864
|
}
|
|
809
865
|
]
|
|
810
866
|
},
|
|
811
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
812
|
-
{
|
|
813
|
-
name: "attConditions",
|
|
814
|
-
type: "string",
|
|
815
|
-
internalType: "string"
|
|
816
|
-
},
|
|
817
867
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
868
|
+
{ name: "tipper", type: "address", internalType: "address" },
|
|
818
869
|
{
|
|
819
|
-
name: "
|
|
820
|
-
type: "
|
|
821
|
-
internalType: "
|
|
822
|
-
}
|
|
823
|
-
{
|
|
824
|
-
name: "attestors",
|
|
825
|
-
type: "tuple[]",
|
|
826
|
-
internalType: "struct Attestor[]",
|
|
827
|
-
components: [
|
|
828
|
-
{
|
|
829
|
-
name: "attestorAddr",
|
|
830
|
-
type: "address",
|
|
831
|
-
internalType: "address"
|
|
832
|
-
},
|
|
833
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
834
|
-
]
|
|
835
|
-
},
|
|
836
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
870
|
+
name: "nftIds",
|
|
871
|
+
type: "uint256[]",
|
|
872
|
+
internalType: "uint256[]"
|
|
873
|
+
}
|
|
837
874
|
]
|
|
838
|
-
}
|
|
839
|
-
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
875
|
+
}
|
|
840
876
|
],
|
|
841
|
-
|
|
842
|
-
stateMutability: "payable"
|
|
877
|
+
stateMutability: "view"
|
|
843
878
|
},
|
|
844
879
|
{
|
|
845
880
|
type: "function",
|
|
846
|
-
name: "
|
|
847
|
-
inputs: [
|
|
881
|
+
name: "getTipRecordsLength",
|
|
882
|
+
inputs: [
|
|
883
|
+
{
|
|
884
|
+
name: "tipRecipient",
|
|
885
|
+
type: "tuple",
|
|
886
|
+
internalType: "struct TipRecipient",
|
|
887
|
+
components: [
|
|
888
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
889
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
890
|
+
]
|
|
891
|
+
}
|
|
892
|
+
],
|
|
848
893
|
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
849
894
|
stateMutability: "view"
|
|
850
895
|
},
|
|
851
896
|
{
|
|
852
897
|
type: "function",
|
|
853
|
-
name: "
|
|
854
|
-
inputs: [
|
|
855
|
-
|
|
898
|
+
name: "getTipRecordsNativeAmount",
|
|
899
|
+
inputs: [
|
|
900
|
+
{
|
|
901
|
+
name: "tipRecipient",
|
|
902
|
+
type: "tuple",
|
|
903
|
+
internalType: "struct TipRecipient",
|
|
904
|
+
components: [
|
|
905
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
906
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
907
|
+
]
|
|
908
|
+
}
|
|
909
|
+
],
|
|
910
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
856
911
|
stateMutability: "view"
|
|
857
912
|
},
|
|
858
913
|
{
|
|
859
914
|
type: "function",
|
|
860
|
-
name: "
|
|
915
|
+
name: "getTipRecordsPaginated",
|
|
861
916
|
inputs: [
|
|
862
917
|
{
|
|
863
918
|
name: "tipRecipient",
|
|
@@ -867,7 +922,9 @@ var abi_default = [
|
|
|
867
922
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
868
923
|
{ name: "id", type: "string", internalType: "string" }
|
|
869
924
|
]
|
|
870
|
-
}
|
|
925
|
+
},
|
|
926
|
+
{ name: "offset", type: "uint256", internalType: "uint256" },
|
|
927
|
+
{ name: "limit", type: "uint256", internalType: "uint256" }
|
|
871
928
|
],
|
|
872
929
|
outputs: [
|
|
873
930
|
{
|
|
@@ -895,7 +952,11 @@ var abi_default = [
|
|
|
895
952
|
},
|
|
896
953
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
897
954
|
{ name: "tipper", type: "address", internalType: "address" },
|
|
898
|
-
{
|
|
955
|
+
{
|
|
956
|
+
name: "nftIds",
|
|
957
|
+
type: "uint256[]",
|
|
958
|
+
internalType: "uint256[]"
|
|
959
|
+
}
|
|
899
960
|
]
|
|
900
961
|
}
|
|
901
962
|
],
|
|
@@ -921,7 +982,11 @@ var abi_default = [
|
|
|
921
982
|
type: "address",
|
|
922
983
|
internalType: "contract IPrimusZKTLS"
|
|
923
984
|
},
|
|
924
|
-
{
|
|
985
|
+
{
|
|
986
|
+
name: "feeRecipient_",
|
|
987
|
+
type: "address",
|
|
988
|
+
internalType: "address"
|
|
989
|
+
},
|
|
925
990
|
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
926
991
|
],
|
|
927
992
|
outputs: [],
|
|
@@ -939,7 +1004,11 @@ var abi_default = [
|
|
|
939
1004
|
name: "primusZKTLS",
|
|
940
1005
|
inputs: [],
|
|
941
1006
|
outputs: [
|
|
942
|
-
{
|
|
1007
|
+
{
|
|
1008
|
+
name: "",
|
|
1009
|
+
type: "address",
|
|
1010
|
+
internalType: "contract IPrimusZKTLS"
|
|
1011
|
+
}
|
|
943
1012
|
],
|
|
944
1013
|
stateMutability: "view"
|
|
945
1014
|
},
|
|
@@ -963,7 +1032,11 @@ var abi_default = [
|
|
|
963
1032
|
type: "function",
|
|
964
1033
|
name: "setFeeRecipient",
|
|
965
1034
|
inputs: [
|
|
966
|
-
{
|
|
1035
|
+
{
|
|
1036
|
+
name: "feeRecipient_",
|
|
1037
|
+
type: "address",
|
|
1038
|
+
internalType: "address"
|
|
1039
|
+
}
|
|
967
1040
|
],
|
|
968
1041
|
outputs: [],
|
|
969
1042
|
stateMutability: "nonpayable"
|
|
@@ -1015,7 +1088,11 @@ var abi_default = [
|
|
|
1015
1088
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1016
1089
|
{ name: "id", type: "string", internalType: "string" },
|
|
1017
1090
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1018
|
-
{
|
|
1091
|
+
{
|
|
1092
|
+
name: "nftIds",
|
|
1093
|
+
type: "uint256[]",
|
|
1094
|
+
internalType: "uint256[]"
|
|
1095
|
+
}
|
|
1019
1096
|
]
|
|
1020
1097
|
}
|
|
1021
1098
|
],
|
|
@@ -1047,7 +1124,11 @@ var abi_default = [
|
|
|
1047
1124
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1048
1125
|
{ name: "id", type: "string", internalType: "string" },
|
|
1049
1126
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1050
|
-
{
|
|
1127
|
+
{
|
|
1128
|
+
name: "nftIds",
|
|
1129
|
+
type: "uint256[]",
|
|
1130
|
+
internalType: "uint256[]"
|
|
1131
|
+
}
|
|
1051
1132
|
]
|
|
1052
1133
|
}
|
|
1053
1134
|
],
|
|
@@ -1065,7 +1146,11 @@ var abi_default = [
|
|
|
1065
1146
|
components: [
|
|
1066
1147
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1067
1148
|
{ name: "id", type: "string", internalType: "string" },
|
|
1068
|
-
{
|
|
1149
|
+
{
|
|
1150
|
+
name: "tipTimestamp",
|
|
1151
|
+
type: "uint64",
|
|
1152
|
+
internalType: "uint64"
|
|
1153
|
+
}
|
|
1069
1154
|
]
|
|
1070
1155
|
}
|
|
1071
1156
|
],
|
|
@@ -1139,6 +1224,18 @@ var abi_default = [
|
|
|
1139
1224
|
type: "uint64",
|
|
1140
1225
|
indexed: false,
|
|
1141
1226
|
internalType: "uint64"
|
|
1227
|
+
},
|
|
1228
|
+
{
|
|
1229
|
+
name: "tokenType",
|
|
1230
|
+
type: "uint32",
|
|
1231
|
+
indexed: false,
|
|
1232
|
+
internalType: "uint32"
|
|
1233
|
+
},
|
|
1234
|
+
{
|
|
1235
|
+
name: "nftIds",
|
|
1236
|
+
type: "uint256[]",
|
|
1237
|
+
indexed: false,
|
|
1238
|
+
internalType: "uint256[]"
|
|
1142
1239
|
}
|
|
1143
1240
|
],
|
|
1144
1241
|
anonymous: false
|
|
@@ -1214,6 +1311,18 @@ var abi_default = [
|
|
|
1214
1311
|
type: "uint64",
|
|
1215
1312
|
indexed: false,
|
|
1216
1313
|
internalType: "uint64"
|
|
1314
|
+
},
|
|
1315
|
+
{
|
|
1316
|
+
name: "tokenType",
|
|
1317
|
+
type: "uint32",
|
|
1318
|
+
indexed: false,
|
|
1319
|
+
internalType: "uint32"
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
name: "nftIds",
|
|
1323
|
+
type: "uint256[]",
|
|
1324
|
+
indexed: false,
|
|
1325
|
+
internalType: "uint256[]"
|
|
1217
1326
|
}
|
|
1218
1327
|
],
|
|
1219
1328
|
anonymous: false
|
|
@@ -1263,6 +1372,18 @@ var abi_default = [
|
|
|
1263
1372
|
type: "uint64",
|
|
1264
1373
|
indexed: false,
|
|
1265
1374
|
internalType: "uint64"
|
|
1375
|
+
},
|
|
1376
|
+
{
|
|
1377
|
+
name: "tokenType",
|
|
1378
|
+
type: "uint32",
|
|
1379
|
+
indexed: false,
|
|
1380
|
+
internalType: "uint32"
|
|
1381
|
+
},
|
|
1382
|
+
{
|
|
1383
|
+
name: "nftIds",
|
|
1384
|
+
type: "uint256[]",
|
|
1385
|
+
indexed: false,
|
|
1386
|
+
internalType: "uint256[]"
|
|
1266
1387
|
}
|
|
1267
1388
|
],
|
|
1268
1389
|
anonymous: false
|
|
@@ -1471,6 +1592,7 @@ var Erc721Contract = class {
|
|
|
1471
1592
|
var Erc721Contract_default = Erc721Contract;
|
|
1472
1593
|
|
|
1473
1594
|
// src/classes/Fund.ts
|
|
1595
|
+
var defaultDecimals = 18;
|
|
1474
1596
|
var { parseUnits: parseUnits2, formatUnits: formatUnits2 } = import_ethers3.ethers.utils;
|
|
1475
1597
|
var Fund = class {
|
|
1476
1598
|
fundContract;
|
|
@@ -1500,7 +1622,7 @@ var Fund = class {
|
|
|
1500
1622
|
try {
|
|
1501
1623
|
const recipientInfos = [];
|
|
1502
1624
|
recipientInfos[0] = recipientInfo;
|
|
1503
|
-
let decimals =
|
|
1625
|
+
let decimals = defaultDecimals;
|
|
1504
1626
|
let params = [];
|
|
1505
1627
|
if (tokenInfo.tokenType === 0) {
|
|
1506
1628
|
await this.approve(tokenInfo, recipientInfos);
|
|
@@ -1541,7 +1663,7 @@ var Fund = class {
|
|
|
1541
1663
|
try {
|
|
1542
1664
|
const recipientInfos = [];
|
|
1543
1665
|
recipientInfos[0] = recipientInfo;
|
|
1544
|
-
let decimals =
|
|
1666
|
+
let decimals = defaultDecimals;
|
|
1545
1667
|
let params = [];
|
|
1546
1668
|
if (tokenInfo.tokenType === 0) {
|
|
1547
1669
|
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
@@ -1602,7 +1724,7 @@ var Fund = class {
|
|
|
1602
1724
|
async fundBatch(tokenInfo, recipientInfoList) {
|
|
1603
1725
|
return new Promise(async (resolve, reject) => {
|
|
1604
1726
|
try {
|
|
1605
|
-
let decimals =
|
|
1727
|
+
let decimals = defaultDecimals;
|
|
1606
1728
|
let params = [];
|
|
1607
1729
|
if (tokenInfo.tokenType === 0) {
|
|
1608
1730
|
await this.approve(tokenInfo, recipientInfoList);
|
|
@@ -1753,6 +1875,51 @@ var Fund = class {
|
|
|
1753
1875
|
}
|
|
1754
1876
|
});
|
|
1755
1877
|
}
|
|
1878
|
+
async _formatTipRecords(fundRecords) {
|
|
1879
|
+
console.log("fundRecords", fundRecords);
|
|
1880
|
+
let formatRecords = [];
|
|
1881
|
+
for (const record of fundRecords) {
|
|
1882
|
+
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1883
|
+
let decimals = defaultDecimals;
|
|
1884
|
+
let symbol = "";
|
|
1885
|
+
let tokenId = null;
|
|
1886
|
+
let nftInfo = null;
|
|
1887
|
+
if (tokenType === 0) {
|
|
1888
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenAddress);
|
|
1889
|
+
decimals = await tokenContract.decimals();
|
|
1890
|
+
symbol = await tokenContract.symbol();
|
|
1891
|
+
} else if (tokenType === 1) {
|
|
1892
|
+
symbol = NATIVETOKENS[this.chainId];
|
|
1893
|
+
} else if (tokenType === 2) {
|
|
1894
|
+
decimals = 0;
|
|
1895
|
+
tokenId = parseInt(nftIds[0]);
|
|
1896
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1897
|
+
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1898
|
+
}
|
|
1899
|
+
let fundToken = {
|
|
1900
|
+
tokenType,
|
|
1901
|
+
// tokenAmount: formatUnits(amount, decimals),
|
|
1902
|
+
decimals,
|
|
1903
|
+
symbol,
|
|
1904
|
+
chainName: CHAINNAMES[this.chainId],
|
|
1905
|
+
chainId: this.chainId
|
|
1906
|
+
};
|
|
1907
|
+
if (tokenType === 0) {
|
|
1908
|
+
fundToken.tokenAddress = tokenAddress;
|
|
1909
|
+
}
|
|
1910
|
+
if (tokenType === 2) {
|
|
1911
|
+
Object.assign(fundToken, nftInfo ?? {});
|
|
1912
|
+
}
|
|
1913
|
+
formatRecords.push({
|
|
1914
|
+
funder: tipper,
|
|
1915
|
+
fundToken,
|
|
1916
|
+
amount: formatUnits2(amount, decimals),
|
|
1917
|
+
timestamp: timestamp.toNumber()
|
|
1918
|
+
});
|
|
1919
|
+
}
|
|
1920
|
+
console.log("formatRecords", formatRecords);
|
|
1921
|
+
return formatRecords;
|
|
1922
|
+
}
|
|
1756
1923
|
async getTipRecords(getFundRecordsParams) {
|
|
1757
1924
|
return new Promise(async (resolve, reject) => {
|
|
1758
1925
|
try {
|
|
@@ -1763,48 +1930,62 @@ var Fund = class {
|
|
|
1763
1930
|
};
|
|
1764
1931
|
});
|
|
1765
1932
|
const fundRecords = await this.fundContract.callMethod("getTipRecords", formatGetFundRecordsParams);
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
} else if (tokenType === 2) {
|
|
1781
|
-
decimals = 0;
|
|
1782
|
-
tokenId = parseInt(nftIds[0]);
|
|
1783
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1784
|
-
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1785
|
-
}
|
|
1786
|
-
let fundToken = {
|
|
1787
|
-
tokenType,
|
|
1788
|
-
// tokenAmount: formatUnits(amount, decimals),
|
|
1789
|
-
decimals,
|
|
1790
|
-
symbol,
|
|
1791
|
-
chainName: CHAINNAMES[this.chainId],
|
|
1792
|
-
chainId: this.chainId
|
|
1933
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
1934
|
+
return resolve(formatRecords);
|
|
1935
|
+
} catch (error) {
|
|
1936
|
+
return reject(error);
|
|
1937
|
+
}
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
async getTipRecordsNativeAmount(getFundRecordsParams) {
|
|
1941
|
+
return new Promise(async (resolve, reject) => {
|
|
1942
|
+
try {
|
|
1943
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1944
|
+
return {
|
|
1945
|
+
idSource: item.socialPlatform,
|
|
1946
|
+
id: item.userIdentifier
|
|
1793
1947
|
};
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1948
|
+
});
|
|
1949
|
+
const fundNativeTokenAmount = await this.fundContract.callMethod("getTipRecordsNativeAmount", formatGetFundRecordsParams);
|
|
1950
|
+
const amount = formatUnits2(fundNativeTokenAmount, defaultDecimals);
|
|
1951
|
+
console.log("fundNativeTokenAmount", amount);
|
|
1952
|
+
return resolve(amount);
|
|
1953
|
+
} catch (error) {
|
|
1954
|
+
return reject(error);
|
|
1955
|
+
}
|
|
1956
|
+
});
|
|
1957
|
+
}
|
|
1958
|
+
async getTipRecordsLength(getFundRecordsParams) {
|
|
1959
|
+
return new Promise(async (resolve, reject) => {
|
|
1960
|
+
try {
|
|
1961
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1962
|
+
return {
|
|
1963
|
+
idSource: item.socialPlatform,
|
|
1964
|
+
id: item.userIdentifier
|
|
1965
|
+
};
|
|
1966
|
+
});
|
|
1967
|
+
const fundRecordsLen = await this.fundContract.callMethod("getTipRecordsLength", formatGetFundRecordsParams);
|
|
1968
|
+
const len = fundRecordsLen.toNumber();
|
|
1969
|
+
console.log("fundRecordsLength", len);
|
|
1970
|
+
return resolve(len);
|
|
1971
|
+
} catch (error) {
|
|
1972
|
+
return reject(error);
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
}
|
|
1976
|
+
async getTipRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
1977
|
+
return new Promise(async (resolve, reject) => {
|
|
1978
|
+
try {
|
|
1979
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1980
|
+
return {
|
|
1981
|
+
idSource: item.socialPlatform,
|
|
1982
|
+
id: item.userIdentifier
|
|
1983
|
+
};
|
|
1984
|
+
});
|
|
1985
|
+
let params = [...formatGetFundRecordsParams, pageNum, pageSize];
|
|
1986
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecordsPaginated", params);
|
|
1987
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
1988
|
+
console.log("fundRecordsPaginated", formatRecords);
|
|
1808
1989
|
return resolve(formatRecords);
|
|
1809
1990
|
} catch (error) {
|
|
1810
1991
|
return reject(error);
|
|
@@ -2682,6 +2863,7 @@ var ZktlsSdk = class {
|
|
|
2682
2863
|
};
|
|
2683
2864
|
|
|
2684
2865
|
// src/index.ts
|
|
2866
|
+
console.log("SUPPORTEDCHAINIDS", SUPPORTEDCHAINIDS);
|
|
2685
2867
|
var PrimusFund = class {
|
|
2686
2868
|
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
2687
2869
|
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
@@ -2902,25 +3084,31 @@ var PrimusFund = class {
|
|
|
2902
3084
|
}
|
|
2903
3085
|
});
|
|
2904
3086
|
}
|
|
3087
|
+
_formatGetFundRecordsParams(queryList) {
|
|
3088
|
+
const socialPlatforms = [];
|
|
3089
|
+
const userIdentifiers = [];
|
|
3090
|
+
for (let i = 0; i < queryList.length; i++) {
|
|
3091
|
+
socialPlatforms[i] = queryList[i].socialPlatform.toLowerCase();
|
|
3092
|
+
userIdentifiers[i] = queryList[i].userIdentifier;
|
|
3093
|
+
if (socialPlatforms[i] === "x" && userIdentifiers[i].startsWith("@")) {
|
|
3094
|
+
queryList[i].userIdentifier = queryList[i].userIdentifier.slice(1);
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
return queryList;
|
|
3098
|
+
}
|
|
2905
3099
|
async getFundRecords(getFundRecordsParams) {
|
|
2906
|
-
|
|
3100
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3101
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3102
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
2907
3103
|
return new Promise(async (resolve, reject) => {
|
|
2908
3104
|
if (!queryList || queryList?.length === 0) {
|
|
2909
3105
|
const error = new Error("getFundRecordsParams is empty");
|
|
2910
3106
|
return reject(error);
|
|
2911
3107
|
}
|
|
2912
|
-
|
|
2913
|
-
const userIdentifiers = [];
|
|
2914
|
-
for (let i = 0; i < queryList.length; i++) {
|
|
2915
|
-
socialPlatforms[i] = queryList[i].socialPlatform.toLowerCase();
|
|
2916
|
-
userIdentifiers[i] = queryList[i].userIdentifier;
|
|
2917
|
-
if (socialPlatforms[i] === "x" && userIdentifiers[i].startsWith("@")) {
|
|
2918
|
-
queryList[i].userIdentifier = queryList[i].userIdentifier.slice(1);
|
|
2919
|
-
}
|
|
2920
|
-
}
|
|
2921
|
-
if (socialPlatforms.length !== userIdentifiers.length) {
|
|
3108
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
2922
3109
|
return reject(`getFundRecordsParams is wrong`);
|
|
2923
3110
|
}
|
|
3111
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
2924
3112
|
try {
|
|
2925
3113
|
const result = await this._fund?.getTipRecords(queryList);
|
|
2926
3114
|
resolve(result);
|
|
@@ -2929,6 +3117,69 @@ var PrimusFund = class {
|
|
|
2929
3117
|
}
|
|
2930
3118
|
});
|
|
2931
3119
|
}
|
|
3120
|
+
async getFundRecordsNativeAmount(getFundRecordsParams) {
|
|
3121
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3122
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3123
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3124
|
+
return new Promise(async (resolve, reject) => {
|
|
3125
|
+
if (!queryList || queryList?.length === 0) {
|
|
3126
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3127
|
+
return reject(error);
|
|
3128
|
+
}
|
|
3129
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3130
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3131
|
+
}
|
|
3132
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3133
|
+
try {
|
|
3134
|
+
const result = await this._fund?.getTipRecordsNativeAmount(queryList);
|
|
3135
|
+
resolve(result);
|
|
3136
|
+
} catch (error) {
|
|
3137
|
+
return reject(error);
|
|
3138
|
+
}
|
|
3139
|
+
});
|
|
3140
|
+
}
|
|
3141
|
+
async getFundRecordsLen(getFundRecordsParams) {
|
|
3142
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3143
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3144
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3145
|
+
return new Promise(async (resolve, reject) => {
|
|
3146
|
+
if (!queryList || queryList?.length === 0) {
|
|
3147
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3148
|
+
return reject(error);
|
|
3149
|
+
}
|
|
3150
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3151
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3152
|
+
}
|
|
3153
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3154
|
+
try {
|
|
3155
|
+
const result = await this._fund?.getTipRecordsLength(queryList);
|
|
3156
|
+
resolve(result);
|
|
3157
|
+
} catch (error) {
|
|
3158
|
+
return reject(error);
|
|
3159
|
+
}
|
|
3160
|
+
});
|
|
3161
|
+
}
|
|
3162
|
+
async getFundRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
3163
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3164
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3165
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3166
|
+
return new Promise(async (resolve, reject) => {
|
|
3167
|
+
if (!queryList || queryList?.length === 0) {
|
|
3168
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3169
|
+
return reject(error);
|
|
3170
|
+
}
|
|
3171
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3172
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3173
|
+
}
|
|
3174
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3175
|
+
try {
|
|
3176
|
+
const result = await this._fund?.getTipRecordsPaginated(queryList, pageNum, pageSize);
|
|
3177
|
+
resolve(result);
|
|
3178
|
+
} catch (error) {
|
|
3179
|
+
return reject(error);
|
|
3180
|
+
}
|
|
3181
|
+
});
|
|
3182
|
+
}
|
|
2932
3183
|
async fundForRedPacket(fundParam) {
|
|
2933
3184
|
return new Promise(async (resolve, reject) => {
|
|
2934
3185
|
try {
|