@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.mjs
CHANGED
|
@@ -593,7 +593,11 @@ var abi_default = [
|
|
|
593
593
|
type: "function",
|
|
594
594
|
name: "addBatchIdSource",
|
|
595
595
|
inputs: [
|
|
596
|
-
{
|
|
596
|
+
{
|
|
597
|
+
name: "sourceName_",
|
|
598
|
+
type: "string[]",
|
|
599
|
+
internalType: "string[]"
|
|
600
|
+
},
|
|
597
601
|
{ name: "url_", type: "string[]", internalType: "string[]" },
|
|
598
602
|
{ name: "jsonPath_", type: "string[]", internalType: "string[]" }
|
|
599
603
|
],
|
|
@@ -610,15 +614,27 @@ var abi_default = [
|
|
|
610
614
|
type: "tuple[]",
|
|
611
615
|
internalType: "struct Attestation[]",
|
|
612
616
|
components: [
|
|
613
|
-
{
|
|
617
|
+
{
|
|
618
|
+
name: "recipient",
|
|
619
|
+
type: "address",
|
|
620
|
+
internalType: "address"
|
|
621
|
+
},
|
|
614
622
|
{
|
|
615
623
|
name: "request",
|
|
616
624
|
type: "tuple",
|
|
617
625
|
internalType: "struct AttNetworkRequest",
|
|
618
626
|
components: [
|
|
619
627
|
{ name: "url", type: "string", internalType: "string" },
|
|
620
|
-
{
|
|
621
|
-
|
|
628
|
+
{
|
|
629
|
+
name: "header",
|
|
630
|
+
type: "string",
|
|
631
|
+
internalType: "string"
|
|
632
|
+
},
|
|
633
|
+
{
|
|
634
|
+
name: "method",
|
|
635
|
+
type: "string",
|
|
636
|
+
internalType: "string"
|
|
637
|
+
},
|
|
622
638
|
{ name: "body", type: "string", internalType: "string" }
|
|
623
639
|
]
|
|
624
640
|
},
|
|
@@ -627,7 +643,11 @@ var abi_default = [
|
|
|
627
643
|
type: "tuple[]",
|
|
628
644
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
629
645
|
components: [
|
|
630
|
-
{
|
|
646
|
+
{
|
|
647
|
+
name: "keyName",
|
|
648
|
+
type: "string",
|
|
649
|
+
internalType: "string"
|
|
650
|
+
},
|
|
631
651
|
{
|
|
632
652
|
name: "parseType",
|
|
633
653
|
type: "string",
|
|
@@ -665,7 +685,11 @@ var abi_default = [
|
|
|
665
685
|
{ name: "url", type: "string", internalType: "string" }
|
|
666
686
|
]
|
|
667
687
|
},
|
|
668
|
-
{
|
|
688
|
+
{
|
|
689
|
+
name: "signatures",
|
|
690
|
+
type: "bytes[]",
|
|
691
|
+
internalType: "bytes[]"
|
|
692
|
+
}
|
|
669
693
|
]
|
|
670
694
|
}
|
|
671
695
|
],
|
|
@@ -682,15 +706,27 @@ var abi_default = [
|
|
|
682
706
|
type: "tuple",
|
|
683
707
|
internalType: "struct Attestation",
|
|
684
708
|
components: [
|
|
685
|
-
{
|
|
709
|
+
{
|
|
710
|
+
name: "recipient",
|
|
711
|
+
type: "address",
|
|
712
|
+
internalType: "address"
|
|
713
|
+
},
|
|
686
714
|
{
|
|
687
715
|
name: "request",
|
|
688
716
|
type: "tuple",
|
|
689
717
|
internalType: "struct AttNetworkRequest",
|
|
690
718
|
components: [
|
|
691
719
|
{ name: "url", type: "string", internalType: "string" },
|
|
692
|
-
{
|
|
693
|
-
|
|
720
|
+
{
|
|
721
|
+
name: "header",
|
|
722
|
+
type: "string",
|
|
723
|
+
internalType: "string"
|
|
724
|
+
},
|
|
725
|
+
{
|
|
726
|
+
name: "method",
|
|
727
|
+
type: "string",
|
|
728
|
+
internalType: "string"
|
|
729
|
+
},
|
|
694
730
|
{ name: "body", type: "string", internalType: "string" }
|
|
695
731
|
]
|
|
696
732
|
},
|
|
@@ -699,7 +735,11 @@ var abi_default = [
|
|
|
699
735
|
type: "tuple[]",
|
|
700
736
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
701
737
|
components: [
|
|
702
|
-
{
|
|
738
|
+
{
|
|
739
|
+
name: "keyName",
|
|
740
|
+
type: "string",
|
|
741
|
+
internalType: "string"
|
|
742
|
+
},
|
|
703
743
|
{
|
|
704
744
|
name: "parseType",
|
|
705
745
|
type: "string",
|
|
@@ -737,7 +777,11 @@ var abi_default = [
|
|
|
737
777
|
{ name: "url", type: "string", internalType: "string" }
|
|
738
778
|
]
|
|
739
779
|
},
|
|
740
|
-
{
|
|
780
|
+
{
|
|
781
|
+
name: "signatures",
|
|
782
|
+
type: "bytes[]",
|
|
783
|
+
internalType: "bytes[]"
|
|
784
|
+
}
|
|
741
785
|
]
|
|
742
786
|
}
|
|
743
787
|
],
|
|
@@ -746,94 +790,105 @@ var abi_default = [
|
|
|
746
790
|
},
|
|
747
791
|
{
|
|
748
792
|
type: "function",
|
|
749
|
-
name: "
|
|
793
|
+
name: "claimFee",
|
|
794
|
+
inputs: [],
|
|
795
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
796
|
+
stateMutability: "view"
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
type: "function",
|
|
800
|
+
name: "feeRecipient",
|
|
801
|
+
inputs: [],
|
|
802
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
803
|
+
stateMutability: "view"
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
type: "function",
|
|
807
|
+
name: "getTipRecords",
|
|
750
808
|
inputs: [
|
|
751
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
752
809
|
{
|
|
753
|
-
name: "
|
|
810
|
+
name: "tipRecipient",
|
|
754
811
|
type: "tuple",
|
|
755
|
-
internalType: "struct
|
|
812
|
+
internalType: "struct TipRecipient",
|
|
756
813
|
components: [
|
|
757
|
-
{ name: "
|
|
814
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
815
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
816
|
+
]
|
|
817
|
+
}
|
|
818
|
+
],
|
|
819
|
+
outputs: [
|
|
820
|
+
{
|
|
821
|
+
name: "",
|
|
822
|
+
type: "tuple[]",
|
|
823
|
+
internalType: "struct TipRecord[]",
|
|
824
|
+
components: [
|
|
825
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
758
826
|
{
|
|
759
|
-
name: "
|
|
827
|
+
name: "tipToken",
|
|
760
828
|
type: "tuple",
|
|
761
|
-
internalType: "struct
|
|
762
|
-
components: [
|
|
763
|
-
{ name: "url", type: "string", internalType: "string" },
|
|
764
|
-
{ name: "header", type: "string", internalType: "string" },
|
|
765
|
-
{ name: "method", type: "string", internalType: "string" },
|
|
766
|
-
{ name: "body", type: "string", internalType: "string" }
|
|
767
|
-
]
|
|
768
|
-
},
|
|
769
|
-
{
|
|
770
|
-
name: "reponseResolve",
|
|
771
|
-
type: "tuple[]",
|
|
772
|
-
internalType: "struct AttNetworkResponseResolve[]",
|
|
829
|
+
internalType: "struct TipToken",
|
|
773
830
|
components: [
|
|
774
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
775
831
|
{
|
|
776
|
-
name: "
|
|
777
|
-
type: "
|
|
778
|
-
internalType: "
|
|
832
|
+
name: "tokenType",
|
|
833
|
+
type: "uint32",
|
|
834
|
+
internalType: "uint32"
|
|
779
835
|
},
|
|
780
836
|
{
|
|
781
|
-
name: "
|
|
782
|
-
type: "
|
|
783
|
-
internalType: "
|
|
837
|
+
name: "tokenAddress",
|
|
838
|
+
type: "address",
|
|
839
|
+
internalType: "address"
|
|
784
840
|
}
|
|
785
841
|
]
|
|
786
842
|
},
|
|
787
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
788
|
-
{
|
|
789
|
-
name: "attConditions",
|
|
790
|
-
type: "string",
|
|
791
|
-
internalType: "string"
|
|
792
|
-
},
|
|
793
843
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
844
|
+
{ name: "tipper", type: "address", internalType: "address" },
|
|
794
845
|
{
|
|
795
|
-
name: "
|
|
796
|
-
type: "
|
|
797
|
-
internalType: "
|
|
798
|
-
}
|
|
799
|
-
{
|
|
800
|
-
name: "attestors",
|
|
801
|
-
type: "tuple[]",
|
|
802
|
-
internalType: "struct Attestor[]",
|
|
803
|
-
components: [
|
|
804
|
-
{
|
|
805
|
-
name: "attestorAddr",
|
|
806
|
-
type: "address",
|
|
807
|
-
internalType: "address"
|
|
808
|
-
},
|
|
809
|
-
{ name: "url", type: "string", internalType: "string" }
|
|
810
|
-
]
|
|
811
|
-
},
|
|
812
|
-
{ name: "signatures", type: "bytes[]", internalType: "bytes[]" }
|
|
846
|
+
name: "nftIds",
|
|
847
|
+
type: "uint256[]",
|
|
848
|
+
internalType: "uint256[]"
|
|
849
|
+
}
|
|
813
850
|
]
|
|
814
|
-
}
|
|
815
|
-
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
851
|
+
}
|
|
816
852
|
],
|
|
817
|
-
|
|
818
|
-
stateMutability: "payable"
|
|
853
|
+
stateMutability: "view"
|
|
819
854
|
},
|
|
820
855
|
{
|
|
821
856
|
type: "function",
|
|
822
|
-
name: "
|
|
823
|
-
inputs: [
|
|
857
|
+
name: "getTipRecordsLength",
|
|
858
|
+
inputs: [
|
|
859
|
+
{
|
|
860
|
+
name: "tipRecipient",
|
|
861
|
+
type: "tuple",
|
|
862
|
+
internalType: "struct TipRecipient",
|
|
863
|
+
components: [
|
|
864
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
865
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
866
|
+
]
|
|
867
|
+
}
|
|
868
|
+
],
|
|
824
869
|
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
825
870
|
stateMutability: "view"
|
|
826
871
|
},
|
|
827
872
|
{
|
|
828
873
|
type: "function",
|
|
829
|
-
name: "
|
|
830
|
-
inputs: [
|
|
831
|
-
|
|
874
|
+
name: "getTipRecordsNativeAmount",
|
|
875
|
+
inputs: [
|
|
876
|
+
{
|
|
877
|
+
name: "tipRecipient",
|
|
878
|
+
type: "tuple",
|
|
879
|
+
internalType: "struct TipRecipient",
|
|
880
|
+
components: [
|
|
881
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
882
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
883
|
+
]
|
|
884
|
+
}
|
|
885
|
+
],
|
|
886
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
832
887
|
stateMutability: "view"
|
|
833
888
|
},
|
|
834
889
|
{
|
|
835
890
|
type: "function",
|
|
836
|
-
name: "
|
|
891
|
+
name: "getTipRecordsPaginated",
|
|
837
892
|
inputs: [
|
|
838
893
|
{
|
|
839
894
|
name: "tipRecipient",
|
|
@@ -843,7 +898,9 @@ var abi_default = [
|
|
|
843
898
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
844
899
|
{ name: "id", type: "string", internalType: "string" }
|
|
845
900
|
]
|
|
846
|
-
}
|
|
901
|
+
},
|
|
902
|
+
{ name: "offset", type: "uint256", internalType: "uint256" },
|
|
903
|
+
{ name: "limit", type: "uint256", internalType: "uint256" }
|
|
847
904
|
],
|
|
848
905
|
outputs: [
|
|
849
906
|
{
|
|
@@ -871,7 +928,11 @@ var abi_default = [
|
|
|
871
928
|
},
|
|
872
929
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
873
930
|
{ name: "tipper", type: "address", internalType: "address" },
|
|
874
|
-
{
|
|
931
|
+
{
|
|
932
|
+
name: "nftIds",
|
|
933
|
+
type: "uint256[]",
|
|
934
|
+
internalType: "uint256[]"
|
|
935
|
+
}
|
|
875
936
|
]
|
|
876
937
|
}
|
|
877
938
|
],
|
|
@@ -897,7 +958,11 @@ var abi_default = [
|
|
|
897
958
|
type: "address",
|
|
898
959
|
internalType: "contract IPrimusZKTLS"
|
|
899
960
|
},
|
|
900
|
-
{
|
|
961
|
+
{
|
|
962
|
+
name: "feeRecipient_",
|
|
963
|
+
type: "address",
|
|
964
|
+
internalType: "address"
|
|
965
|
+
},
|
|
901
966
|
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
902
967
|
],
|
|
903
968
|
outputs: [],
|
|
@@ -915,7 +980,11 @@ var abi_default = [
|
|
|
915
980
|
name: "primusZKTLS",
|
|
916
981
|
inputs: [],
|
|
917
982
|
outputs: [
|
|
918
|
-
{
|
|
983
|
+
{
|
|
984
|
+
name: "",
|
|
985
|
+
type: "address",
|
|
986
|
+
internalType: "contract IPrimusZKTLS"
|
|
987
|
+
}
|
|
919
988
|
],
|
|
920
989
|
stateMutability: "view"
|
|
921
990
|
},
|
|
@@ -939,7 +1008,11 @@ var abi_default = [
|
|
|
939
1008
|
type: "function",
|
|
940
1009
|
name: "setFeeRecipient",
|
|
941
1010
|
inputs: [
|
|
942
|
-
{
|
|
1011
|
+
{
|
|
1012
|
+
name: "feeRecipient_",
|
|
1013
|
+
type: "address",
|
|
1014
|
+
internalType: "address"
|
|
1015
|
+
}
|
|
943
1016
|
],
|
|
944
1017
|
outputs: [],
|
|
945
1018
|
stateMutability: "nonpayable"
|
|
@@ -991,7 +1064,11 @@ var abi_default = [
|
|
|
991
1064
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
992
1065
|
{ name: "id", type: "string", internalType: "string" },
|
|
993
1066
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
994
|
-
{
|
|
1067
|
+
{
|
|
1068
|
+
name: "nftIds",
|
|
1069
|
+
type: "uint256[]",
|
|
1070
|
+
internalType: "uint256[]"
|
|
1071
|
+
}
|
|
995
1072
|
]
|
|
996
1073
|
}
|
|
997
1074
|
],
|
|
@@ -1023,7 +1100,11 @@ var abi_default = [
|
|
|
1023
1100
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1024
1101
|
{ name: "id", type: "string", internalType: "string" },
|
|
1025
1102
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1026
|
-
{
|
|
1103
|
+
{
|
|
1104
|
+
name: "nftIds",
|
|
1105
|
+
type: "uint256[]",
|
|
1106
|
+
internalType: "uint256[]"
|
|
1107
|
+
}
|
|
1027
1108
|
]
|
|
1028
1109
|
}
|
|
1029
1110
|
],
|
|
@@ -1041,7 +1122,11 @@ var abi_default = [
|
|
|
1041
1122
|
components: [
|
|
1042
1123
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1043
1124
|
{ name: "id", type: "string", internalType: "string" },
|
|
1044
|
-
{
|
|
1125
|
+
{
|
|
1126
|
+
name: "tipTimestamp",
|
|
1127
|
+
type: "uint64",
|
|
1128
|
+
internalType: "uint64"
|
|
1129
|
+
}
|
|
1045
1130
|
]
|
|
1046
1131
|
}
|
|
1047
1132
|
],
|
|
@@ -1115,6 +1200,18 @@ var abi_default = [
|
|
|
1115
1200
|
type: "uint64",
|
|
1116
1201
|
indexed: false,
|
|
1117
1202
|
internalType: "uint64"
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
name: "tokenType",
|
|
1206
|
+
type: "uint32",
|
|
1207
|
+
indexed: false,
|
|
1208
|
+
internalType: "uint32"
|
|
1209
|
+
},
|
|
1210
|
+
{
|
|
1211
|
+
name: "nftIds",
|
|
1212
|
+
type: "uint256[]",
|
|
1213
|
+
indexed: false,
|
|
1214
|
+
internalType: "uint256[]"
|
|
1118
1215
|
}
|
|
1119
1216
|
],
|
|
1120
1217
|
anonymous: false
|
|
@@ -1190,6 +1287,18 @@ var abi_default = [
|
|
|
1190
1287
|
type: "uint64",
|
|
1191
1288
|
indexed: false,
|
|
1192
1289
|
internalType: "uint64"
|
|
1290
|
+
},
|
|
1291
|
+
{
|
|
1292
|
+
name: "tokenType",
|
|
1293
|
+
type: "uint32",
|
|
1294
|
+
indexed: false,
|
|
1295
|
+
internalType: "uint32"
|
|
1296
|
+
},
|
|
1297
|
+
{
|
|
1298
|
+
name: "nftIds",
|
|
1299
|
+
type: "uint256[]",
|
|
1300
|
+
indexed: false,
|
|
1301
|
+
internalType: "uint256[]"
|
|
1193
1302
|
}
|
|
1194
1303
|
],
|
|
1195
1304
|
anonymous: false
|
|
@@ -1239,6 +1348,18 @@ var abi_default = [
|
|
|
1239
1348
|
type: "uint64",
|
|
1240
1349
|
indexed: false,
|
|
1241
1350
|
internalType: "uint64"
|
|
1351
|
+
},
|
|
1352
|
+
{
|
|
1353
|
+
name: "tokenType",
|
|
1354
|
+
type: "uint32",
|
|
1355
|
+
indexed: false,
|
|
1356
|
+
internalType: "uint32"
|
|
1357
|
+
},
|
|
1358
|
+
{
|
|
1359
|
+
name: "nftIds",
|
|
1360
|
+
type: "uint256[]",
|
|
1361
|
+
indexed: false,
|
|
1362
|
+
internalType: "uint256[]"
|
|
1242
1363
|
}
|
|
1243
1364
|
],
|
|
1244
1365
|
anonymous: false
|
|
@@ -1447,6 +1568,7 @@ var Erc721Contract = class {
|
|
|
1447
1568
|
var Erc721Contract_default = Erc721Contract;
|
|
1448
1569
|
|
|
1449
1570
|
// src/classes/Fund.ts
|
|
1571
|
+
var defaultDecimals = 18;
|
|
1450
1572
|
var { parseUnits: parseUnits2, formatUnits: formatUnits2 } = ethers3.utils;
|
|
1451
1573
|
var Fund = class {
|
|
1452
1574
|
fundContract;
|
|
@@ -1476,7 +1598,7 @@ var Fund = class {
|
|
|
1476
1598
|
try {
|
|
1477
1599
|
const recipientInfos = [];
|
|
1478
1600
|
recipientInfos[0] = recipientInfo;
|
|
1479
|
-
let decimals =
|
|
1601
|
+
let decimals = defaultDecimals;
|
|
1480
1602
|
let params = [];
|
|
1481
1603
|
if (tokenInfo.tokenType === 0) {
|
|
1482
1604
|
await this.approve(tokenInfo, recipientInfos);
|
|
@@ -1517,7 +1639,7 @@ var Fund = class {
|
|
|
1517
1639
|
try {
|
|
1518
1640
|
const recipientInfos = [];
|
|
1519
1641
|
recipientInfos[0] = recipientInfo;
|
|
1520
|
-
let decimals =
|
|
1642
|
+
let decimals = defaultDecimals;
|
|
1521
1643
|
let params = [];
|
|
1522
1644
|
if (tokenInfo.tokenType === 0) {
|
|
1523
1645
|
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
@@ -1578,7 +1700,7 @@ var Fund = class {
|
|
|
1578
1700
|
async fundBatch(tokenInfo, recipientInfoList) {
|
|
1579
1701
|
return new Promise(async (resolve, reject) => {
|
|
1580
1702
|
try {
|
|
1581
|
-
let decimals =
|
|
1703
|
+
let decimals = defaultDecimals;
|
|
1582
1704
|
let params = [];
|
|
1583
1705
|
if (tokenInfo.tokenType === 0) {
|
|
1584
1706
|
await this.approve(tokenInfo, recipientInfoList);
|
|
@@ -1729,6 +1851,51 @@ var Fund = class {
|
|
|
1729
1851
|
}
|
|
1730
1852
|
});
|
|
1731
1853
|
}
|
|
1854
|
+
async _formatTipRecords(fundRecords) {
|
|
1855
|
+
console.log("fundRecords", fundRecords);
|
|
1856
|
+
let formatRecords = [];
|
|
1857
|
+
for (const record of fundRecords) {
|
|
1858
|
+
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1859
|
+
let decimals = defaultDecimals;
|
|
1860
|
+
let symbol = "";
|
|
1861
|
+
let tokenId = null;
|
|
1862
|
+
let nftInfo = null;
|
|
1863
|
+
if (tokenType === 0) {
|
|
1864
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenAddress);
|
|
1865
|
+
decimals = await tokenContract.decimals();
|
|
1866
|
+
symbol = await tokenContract.symbol();
|
|
1867
|
+
} else if (tokenType === 1) {
|
|
1868
|
+
symbol = NATIVETOKENS[this.chainId];
|
|
1869
|
+
} else if (tokenType === 2) {
|
|
1870
|
+
decimals = 0;
|
|
1871
|
+
tokenId = parseInt(nftIds[0]);
|
|
1872
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1873
|
+
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1874
|
+
}
|
|
1875
|
+
let fundToken = {
|
|
1876
|
+
tokenType,
|
|
1877
|
+
// tokenAmount: formatUnits(amount, decimals),
|
|
1878
|
+
decimals,
|
|
1879
|
+
symbol,
|
|
1880
|
+
chainName: CHAINNAMES[this.chainId],
|
|
1881
|
+
chainId: this.chainId
|
|
1882
|
+
};
|
|
1883
|
+
if (tokenType === 0) {
|
|
1884
|
+
fundToken.tokenAddress = tokenAddress;
|
|
1885
|
+
}
|
|
1886
|
+
if (tokenType === 2) {
|
|
1887
|
+
Object.assign(fundToken, nftInfo ?? {});
|
|
1888
|
+
}
|
|
1889
|
+
formatRecords.push({
|
|
1890
|
+
funder: tipper,
|
|
1891
|
+
fundToken,
|
|
1892
|
+
amount: formatUnits2(amount, decimals),
|
|
1893
|
+
timestamp: timestamp.toNumber()
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
console.log("formatRecords", formatRecords);
|
|
1897
|
+
return formatRecords;
|
|
1898
|
+
}
|
|
1732
1899
|
async getTipRecords(getFundRecordsParams) {
|
|
1733
1900
|
return new Promise(async (resolve, reject) => {
|
|
1734
1901
|
try {
|
|
@@ -1739,48 +1906,62 @@ var Fund = class {
|
|
|
1739
1906
|
};
|
|
1740
1907
|
});
|
|
1741
1908
|
const fundRecords = await this.fundContract.callMethod("getTipRecords", formatGetFundRecordsParams);
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
} else if (tokenType === 2) {
|
|
1757
|
-
decimals = 0;
|
|
1758
|
-
tokenId = parseInt(nftIds[0]);
|
|
1759
|
-
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1760
|
-
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1761
|
-
}
|
|
1762
|
-
let fundToken = {
|
|
1763
|
-
tokenType,
|
|
1764
|
-
// tokenAmount: formatUnits(amount, decimals),
|
|
1765
|
-
decimals,
|
|
1766
|
-
symbol,
|
|
1767
|
-
chainName: CHAINNAMES[this.chainId],
|
|
1768
|
-
chainId: this.chainId
|
|
1909
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
1910
|
+
return resolve(formatRecords);
|
|
1911
|
+
} catch (error) {
|
|
1912
|
+
return reject(error);
|
|
1913
|
+
}
|
|
1914
|
+
});
|
|
1915
|
+
}
|
|
1916
|
+
async getTipRecordsNativeAmount(getFundRecordsParams) {
|
|
1917
|
+
return new Promise(async (resolve, reject) => {
|
|
1918
|
+
try {
|
|
1919
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1920
|
+
return {
|
|
1921
|
+
idSource: item.socialPlatform,
|
|
1922
|
+
id: item.userIdentifier
|
|
1769
1923
|
};
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1924
|
+
});
|
|
1925
|
+
const fundNativeTokenAmount = await this.fundContract.callMethod("getTipRecordsNativeAmount", formatGetFundRecordsParams);
|
|
1926
|
+
const amount = formatUnits2(fundNativeTokenAmount, defaultDecimals);
|
|
1927
|
+
console.log("fundNativeTokenAmount", amount);
|
|
1928
|
+
return resolve(amount);
|
|
1929
|
+
} catch (error) {
|
|
1930
|
+
return reject(error);
|
|
1931
|
+
}
|
|
1932
|
+
});
|
|
1933
|
+
}
|
|
1934
|
+
async getTipRecordsLength(getFundRecordsParams) {
|
|
1935
|
+
return new Promise(async (resolve, reject) => {
|
|
1936
|
+
try {
|
|
1937
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1938
|
+
return {
|
|
1939
|
+
idSource: item.socialPlatform,
|
|
1940
|
+
id: item.userIdentifier
|
|
1941
|
+
};
|
|
1942
|
+
});
|
|
1943
|
+
const fundRecordsLen = await this.fundContract.callMethod("getTipRecordsLength", formatGetFundRecordsParams);
|
|
1944
|
+
const len = fundRecordsLen.toNumber();
|
|
1945
|
+
console.log("fundRecordsLength", len);
|
|
1946
|
+
return resolve(len);
|
|
1947
|
+
} catch (error) {
|
|
1948
|
+
return reject(error);
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
async getTipRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
1953
|
+
return new Promise(async (resolve, reject) => {
|
|
1954
|
+
try {
|
|
1955
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1956
|
+
return {
|
|
1957
|
+
idSource: item.socialPlatform,
|
|
1958
|
+
id: item.userIdentifier
|
|
1959
|
+
};
|
|
1960
|
+
});
|
|
1961
|
+
let params = [...formatGetFundRecordsParams, pageNum, pageSize];
|
|
1962
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecordsPaginated", params);
|
|
1963
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
1964
|
+
console.log("fundRecordsPaginated", formatRecords);
|
|
1784
1965
|
return resolve(formatRecords);
|
|
1785
1966
|
} catch (error) {
|
|
1786
1967
|
return reject(error);
|
|
@@ -2658,6 +2839,7 @@ var ZktlsSdk = class {
|
|
|
2658
2839
|
};
|
|
2659
2840
|
|
|
2660
2841
|
// src/index.ts
|
|
2842
|
+
console.log("SUPPORTEDCHAINIDS", SUPPORTEDCHAINIDS);
|
|
2661
2843
|
var PrimusFund = class {
|
|
2662
2844
|
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
2663
2845
|
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
@@ -2878,25 +3060,31 @@ var PrimusFund = class {
|
|
|
2878
3060
|
}
|
|
2879
3061
|
});
|
|
2880
3062
|
}
|
|
3063
|
+
_formatGetFundRecordsParams(queryList) {
|
|
3064
|
+
const socialPlatforms = [];
|
|
3065
|
+
const userIdentifiers = [];
|
|
3066
|
+
for (let i = 0; i < queryList.length; i++) {
|
|
3067
|
+
socialPlatforms[i] = queryList[i].socialPlatform.toLowerCase();
|
|
3068
|
+
userIdentifiers[i] = queryList[i].userIdentifier;
|
|
3069
|
+
if (socialPlatforms[i] === "x" && userIdentifiers[i].startsWith("@")) {
|
|
3070
|
+
queryList[i].userIdentifier = queryList[i].userIdentifier.slice(1);
|
|
3071
|
+
}
|
|
3072
|
+
}
|
|
3073
|
+
return queryList;
|
|
3074
|
+
}
|
|
2881
3075
|
async getFundRecords(getFundRecordsParams) {
|
|
2882
|
-
|
|
3076
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3077
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3078
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
2883
3079
|
return new Promise(async (resolve, reject) => {
|
|
2884
3080
|
if (!queryList || queryList?.length === 0) {
|
|
2885
3081
|
const error = new Error("getFundRecordsParams is empty");
|
|
2886
3082
|
return reject(error);
|
|
2887
3083
|
}
|
|
2888
|
-
|
|
2889
|
-
const userIdentifiers = [];
|
|
2890
|
-
for (let i = 0; i < queryList.length; i++) {
|
|
2891
|
-
socialPlatforms[i] = queryList[i].socialPlatform.toLowerCase();
|
|
2892
|
-
userIdentifiers[i] = queryList[i].userIdentifier;
|
|
2893
|
-
if (socialPlatforms[i] === "x" && userIdentifiers[i].startsWith("@")) {
|
|
2894
|
-
queryList[i].userIdentifier = queryList[i].userIdentifier.slice(1);
|
|
2895
|
-
}
|
|
2896
|
-
}
|
|
2897
|
-
if (socialPlatforms.length !== userIdentifiers.length) {
|
|
3084
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
2898
3085
|
return reject(`getFundRecordsParams is wrong`);
|
|
2899
3086
|
}
|
|
3087
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
2900
3088
|
try {
|
|
2901
3089
|
const result = await this._fund?.getTipRecords(queryList);
|
|
2902
3090
|
resolve(result);
|
|
@@ -2905,6 +3093,69 @@ var PrimusFund = class {
|
|
|
2905
3093
|
}
|
|
2906
3094
|
});
|
|
2907
3095
|
}
|
|
3096
|
+
async getFundRecordsNativeAmount(getFundRecordsParams) {
|
|
3097
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3098
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3099
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3100
|
+
return new Promise(async (resolve, reject) => {
|
|
3101
|
+
if (!queryList || queryList?.length === 0) {
|
|
3102
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3103
|
+
return reject(error);
|
|
3104
|
+
}
|
|
3105
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3106
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3107
|
+
}
|
|
3108
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3109
|
+
try {
|
|
3110
|
+
const result = await this._fund?.getTipRecordsNativeAmount(queryList);
|
|
3111
|
+
resolve(result);
|
|
3112
|
+
} catch (error) {
|
|
3113
|
+
return reject(error);
|
|
3114
|
+
}
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
async getFundRecordsLen(getFundRecordsParams) {
|
|
3118
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3119
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3120
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3121
|
+
return new Promise(async (resolve, reject) => {
|
|
3122
|
+
if (!queryList || queryList?.length === 0) {
|
|
3123
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3124
|
+
return reject(error);
|
|
3125
|
+
}
|
|
3126
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3127
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3128
|
+
}
|
|
3129
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3130
|
+
try {
|
|
3131
|
+
const result = await this._fund?.getTipRecordsLength(queryList);
|
|
3132
|
+
resolve(result);
|
|
3133
|
+
} catch (error) {
|
|
3134
|
+
return reject(error);
|
|
3135
|
+
}
|
|
3136
|
+
});
|
|
3137
|
+
}
|
|
3138
|
+
async getFundRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
3139
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
3140
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
3141
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
3142
|
+
return new Promise(async (resolve, reject) => {
|
|
3143
|
+
if (!queryList || queryList?.length === 0) {
|
|
3144
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
3145
|
+
return reject(error);
|
|
3146
|
+
}
|
|
3147
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
3148
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
3149
|
+
}
|
|
3150
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
3151
|
+
try {
|
|
3152
|
+
const result = await this._fund?.getTipRecordsPaginated(queryList, pageNum, pageSize);
|
|
3153
|
+
resolve(result);
|
|
3154
|
+
} catch (error) {
|
|
3155
|
+
return reject(error);
|
|
3156
|
+
}
|
|
3157
|
+
});
|
|
3158
|
+
}
|
|
2908
3159
|
async fundForRedPacket(fundParam) {
|
|
2909
3160
|
return new Promise(async (resolve, reject) => {
|
|
2910
3161
|
try {
|