@primuslabs/fund-js-sdk 0.1.14 → 0.1.16
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.d.mts +30 -10
- package/dist/index.d.ts +30 -10
- package/dist/index.js +4195 -324
- package/dist/index.mjs +4192 -324
- package/package.json +9 -3
package/dist/index.mjs
CHANGED
|
@@ -112,6 +112,7 @@ var Fund_CONTRACTS = Object.values(SUPPORTEDCHAINIDSMAP).reduce((prev, curr) =>
|
|
|
112
112
|
};
|
|
113
113
|
}, {});
|
|
114
114
|
var SUPPORTEDCHAINIDS = Object.keys(Fund_CONTRACTS).map((i) => Number(i));
|
|
115
|
+
var SUPPORTEDSOLANACHAINIDS = ["EtWTRABZaYq6iMfeYKouRu166VU2xqa1", "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"];
|
|
115
116
|
var FundForRedPacket_CONTRACTS = Object.values(SUPPORTEDCHAINIDSMAP).filter(
|
|
116
117
|
(item) => {
|
|
117
118
|
return item.redPacketContractAddress;
|
|
@@ -134,6 +135,41 @@ var hasErrorFlagFn = (curErrorArr, targetErrorStrArr) => {
|
|
|
134
135
|
return f;
|
|
135
136
|
});
|
|
136
137
|
};
|
|
138
|
+
var getErrArrFn = (error) => {
|
|
139
|
+
const errorMsg1 = typeof error === "string" ? error : error instanceof Error ? error.message : typeof error.message === "string" ? error.message : JSON.stringify(error);
|
|
140
|
+
const errorMsg2 = typeof error === "object" ? JSON.stringify(error) : error?.toString();
|
|
141
|
+
const curErrorStrArr = [errorMsg1, errorMsg2];
|
|
142
|
+
return curErrorStrArr;
|
|
143
|
+
};
|
|
144
|
+
var formatErrFn = (error) => {
|
|
145
|
+
let formatError = error;
|
|
146
|
+
const curErrorStrArr = getErrArrFn(error);
|
|
147
|
+
const userRejectErrStrArr = ["user rejected", "approval denied"];
|
|
148
|
+
const isUserRejected = hasErrorFlagFn(curErrorStrArr, userRejectErrStrArr);
|
|
149
|
+
if (error?.code === "ACTION_REJECTED" || isUserRejected) {
|
|
150
|
+
formatError = "user rejected transaction";
|
|
151
|
+
}
|
|
152
|
+
const isNoPendingWithdrawals = hasErrorFlagFn(curErrorStrArr, ["no pending withdrawals"]);
|
|
153
|
+
if (isNoPendingWithdrawals) {
|
|
154
|
+
formatError = "no pending withdrawals";
|
|
155
|
+
}
|
|
156
|
+
const insufficientBalanceErrStrArr = ["insufficient balance", "INSUFFICIENT_FUNDS", "The caller does not have enough funds for value transfer."];
|
|
157
|
+
const isInsufficientBalance = hasErrorFlagFn(curErrorStrArr, insufficientBalanceErrStrArr);
|
|
158
|
+
if (isInsufficientBalance) {
|
|
159
|
+
formatError = "insufficient balance";
|
|
160
|
+
}
|
|
161
|
+
const alreadyClaimedErrStrArr = ["Already claimed"];
|
|
162
|
+
const isAlreadyClaimed = hasErrorFlagFn(curErrorStrArr, alreadyClaimedErrStrArr);
|
|
163
|
+
if (isAlreadyClaimed) {
|
|
164
|
+
formatError = "already claimed";
|
|
165
|
+
}
|
|
166
|
+
const allClaimedErrStrArr = ["All claimed"];
|
|
167
|
+
const isAllClaimed = hasErrorFlagFn(curErrorStrArr, allClaimedErrStrArr);
|
|
168
|
+
if (isAllClaimed) {
|
|
169
|
+
formatError = "all claimed";
|
|
170
|
+
}
|
|
171
|
+
return formatError;
|
|
172
|
+
};
|
|
137
173
|
|
|
138
174
|
// src/classes/Contract.ts
|
|
139
175
|
var Contract = class {
|
|
@@ -593,7 +629,11 @@ var abi_default = [
|
|
|
593
629
|
type: "function",
|
|
594
630
|
name: "addBatchIdSource",
|
|
595
631
|
inputs: [
|
|
596
|
-
{
|
|
632
|
+
{
|
|
633
|
+
name: "sourceName_",
|
|
634
|
+
type: "string[]",
|
|
635
|
+
internalType: "string[]"
|
|
636
|
+
},
|
|
597
637
|
{ name: "url_", type: "string[]", internalType: "string[]" },
|
|
598
638
|
{ name: "jsonPath_", type: "string[]", internalType: "string[]" }
|
|
599
639
|
],
|
|
@@ -610,15 +650,27 @@ var abi_default = [
|
|
|
610
650
|
type: "tuple[]",
|
|
611
651
|
internalType: "struct Attestation[]",
|
|
612
652
|
components: [
|
|
613
|
-
{
|
|
653
|
+
{
|
|
654
|
+
name: "recipient",
|
|
655
|
+
type: "address",
|
|
656
|
+
internalType: "address"
|
|
657
|
+
},
|
|
614
658
|
{
|
|
615
659
|
name: "request",
|
|
616
660
|
type: "tuple",
|
|
617
661
|
internalType: "struct AttNetworkRequest",
|
|
618
662
|
components: [
|
|
619
663
|
{ name: "url", type: "string", internalType: "string" },
|
|
620
|
-
{
|
|
621
|
-
|
|
664
|
+
{
|
|
665
|
+
name: "header",
|
|
666
|
+
type: "string",
|
|
667
|
+
internalType: "string"
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
name: "method",
|
|
671
|
+
type: "string",
|
|
672
|
+
internalType: "string"
|
|
673
|
+
},
|
|
622
674
|
{ name: "body", type: "string", internalType: "string" }
|
|
623
675
|
]
|
|
624
676
|
},
|
|
@@ -627,7 +679,11 @@ var abi_default = [
|
|
|
627
679
|
type: "tuple[]",
|
|
628
680
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
629
681
|
components: [
|
|
630
|
-
{
|
|
682
|
+
{
|
|
683
|
+
name: "keyName",
|
|
684
|
+
type: "string",
|
|
685
|
+
internalType: "string"
|
|
686
|
+
},
|
|
631
687
|
{
|
|
632
688
|
name: "parseType",
|
|
633
689
|
type: "string",
|
|
@@ -665,7 +721,11 @@ var abi_default = [
|
|
|
665
721
|
{ name: "url", type: "string", internalType: "string" }
|
|
666
722
|
]
|
|
667
723
|
},
|
|
668
|
-
{
|
|
724
|
+
{
|
|
725
|
+
name: "signatures",
|
|
726
|
+
type: "bytes[]",
|
|
727
|
+
internalType: "bytes[]"
|
|
728
|
+
}
|
|
669
729
|
]
|
|
670
730
|
}
|
|
671
731
|
],
|
|
@@ -682,15 +742,27 @@ var abi_default = [
|
|
|
682
742
|
type: "tuple",
|
|
683
743
|
internalType: "struct Attestation",
|
|
684
744
|
components: [
|
|
685
|
-
{
|
|
745
|
+
{
|
|
746
|
+
name: "recipient",
|
|
747
|
+
type: "address",
|
|
748
|
+
internalType: "address"
|
|
749
|
+
},
|
|
686
750
|
{
|
|
687
751
|
name: "request",
|
|
688
752
|
type: "tuple",
|
|
689
753
|
internalType: "struct AttNetworkRequest",
|
|
690
754
|
components: [
|
|
691
755
|
{ name: "url", type: "string", internalType: "string" },
|
|
692
|
-
{
|
|
693
|
-
|
|
756
|
+
{
|
|
757
|
+
name: "header",
|
|
758
|
+
type: "string",
|
|
759
|
+
internalType: "string"
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
name: "method",
|
|
763
|
+
type: "string",
|
|
764
|
+
internalType: "string"
|
|
765
|
+
},
|
|
694
766
|
{ name: "body", type: "string", internalType: "string" }
|
|
695
767
|
]
|
|
696
768
|
},
|
|
@@ -699,7 +771,11 @@ var abi_default = [
|
|
|
699
771
|
type: "tuple[]",
|
|
700
772
|
internalType: "struct AttNetworkResponseResolve[]",
|
|
701
773
|
components: [
|
|
702
|
-
{
|
|
774
|
+
{
|
|
775
|
+
name: "keyName",
|
|
776
|
+
type: "string",
|
|
777
|
+
internalType: "string"
|
|
778
|
+
},
|
|
703
779
|
{
|
|
704
780
|
name: "parseType",
|
|
705
781
|
type: "string",
|
|
@@ -737,7 +813,11 @@ var abi_default = [
|
|
|
737
813
|
{ name: "url", type: "string", internalType: "string" }
|
|
738
814
|
]
|
|
739
815
|
},
|
|
740
|
-
{
|
|
816
|
+
{
|
|
817
|
+
name: "signatures",
|
|
818
|
+
type: "bytes[]",
|
|
819
|
+
internalType: "bytes[]"
|
|
820
|
+
}
|
|
741
821
|
]
|
|
742
822
|
}
|
|
743
823
|
],
|
|
@@ -746,94 +826,105 @@ var abi_default = [
|
|
|
746
826
|
},
|
|
747
827
|
{
|
|
748
828
|
type: "function",
|
|
749
|
-
name: "
|
|
829
|
+
name: "claimFee",
|
|
830
|
+
inputs: [],
|
|
831
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
832
|
+
stateMutability: "view"
|
|
833
|
+
},
|
|
834
|
+
{
|
|
835
|
+
type: "function",
|
|
836
|
+
name: "feeRecipient",
|
|
837
|
+
inputs: [],
|
|
838
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
839
|
+
stateMutability: "view"
|
|
840
|
+
},
|
|
841
|
+
{
|
|
842
|
+
type: "function",
|
|
843
|
+
name: "getTipRecords",
|
|
750
844
|
inputs: [
|
|
751
|
-
{ name: "idSource", type: "string", internalType: "string" },
|
|
752
845
|
{
|
|
753
|
-
name: "
|
|
846
|
+
name: "tipRecipient",
|
|
754
847
|
type: "tuple",
|
|
755
|
-
internalType: "struct
|
|
848
|
+
internalType: "struct TipRecipient",
|
|
756
849
|
components: [
|
|
757
|
-
{ name: "
|
|
850
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
851
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
852
|
+
]
|
|
853
|
+
}
|
|
854
|
+
],
|
|
855
|
+
outputs: [
|
|
856
|
+
{
|
|
857
|
+
name: "",
|
|
858
|
+
type: "tuple[]",
|
|
859
|
+
internalType: "struct TipRecord[]",
|
|
860
|
+
components: [
|
|
861
|
+
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
758
862
|
{
|
|
759
|
-
name: "
|
|
863
|
+
name: "tipToken",
|
|
760
864
|
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[]",
|
|
865
|
+
internalType: "struct TipToken",
|
|
773
866
|
components: [
|
|
774
|
-
{ name: "keyName", type: "string", internalType: "string" },
|
|
775
867
|
{
|
|
776
|
-
name: "
|
|
777
|
-
type: "
|
|
778
|
-
internalType: "
|
|
868
|
+
name: "tokenType",
|
|
869
|
+
type: "uint32",
|
|
870
|
+
internalType: "uint32"
|
|
779
871
|
},
|
|
780
872
|
{
|
|
781
|
-
name: "
|
|
782
|
-
type: "
|
|
783
|
-
internalType: "
|
|
873
|
+
name: "tokenAddress",
|
|
874
|
+
type: "address",
|
|
875
|
+
internalType: "address"
|
|
784
876
|
}
|
|
785
877
|
]
|
|
786
878
|
},
|
|
787
|
-
{ name: "data", type: "string", internalType: "string" },
|
|
788
|
-
{
|
|
789
|
-
name: "attConditions",
|
|
790
|
-
type: "string",
|
|
791
|
-
internalType: "string"
|
|
792
|
-
},
|
|
793
879
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
880
|
+
{ name: "tipper", type: "address", internalType: "address" },
|
|
794
881
|
{
|
|
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[]" }
|
|
882
|
+
name: "nftIds",
|
|
883
|
+
type: "uint256[]",
|
|
884
|
+
internalType: "uint256[]"
|
|
885
|
+
}
|
|
813
886
|
]
|
|
814
|
-
}
|
|
815
|
-
{ name: "index", type: "uint32", internalType: "uint32" }
|
|
887
|
+
}
|
|
816
888
|
],
|
|
817
|
-
|
|
818
|
-
stateMutability: "payable"
|
|
889
|
+
stateMutability: "view"
|
|
819
890
|
},
|
|
820
891
|
{
|
|
821
892
|
type: "function",
|
|
822
|
-
name: "
|
|
823
|
-
inputs: [
|
|
893
|
+
name: "getTipRecordsLength",
|
|
894
|
+
inputs: [
|
|
895
|
+
{
|
|
896
|
+
name: "tipRecipient",
|
|
897
|
+
type: "tuple",
|
|
898
|
+
internalType: "struct TipRecipient",
|
|
899
|
+
components: [
|
|
900
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
901
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
902
|
+
]
|
|
903
|
+
}
|
|
904
|
+
],
|
|
824
905
|
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
825
906
|
stateMutability: "view"
|
|
826
907
|
},
|
|
827
908
|
{
|
|
828
909
|
type: "function",
|
|
829
|
-
name: "
|
|
830
|
-
inputs: [
|
|
831
|
-
|
|
910
|
+
name: "getTipRecordsNativeAmount",
|
|
911
|
+
inputs: [
|
|
912
|
+
{
|
|
913
|
+
name: "tipRecipient",
|
|
914
|
+
type: "tuple",
|
|
915
|
+
internalType: "struct TipRecipient",
|
|
916
|
+
components: [
|
|
917
|
+
{ name: "idSource", type: "string", internalType: "string" },
|
|
918
|
+
{ name: "id", type: "string", internalType: "string" }
|
|
919
|
+
]
|
|
920
|
+
}
|
|
921
|
+
],
|
|
922
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
832
923
|
stateMutability: "view"
|
|
833
924
|
},
|
|
834
925
|
{
|
|
835
926
|
type: "function",
|
|
836
|
-
name: "
|
|
927
|
+
name: "getTipRecordsPaginated",
|
|
837
928
|
inputs: [
|
|
838
929
|
{
|
|
839
930
|
name: "tipRecipient",
|
|
@@ -843,7 +934,9 @@ var abi_default = [
|
|
|
843
934
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
844
935
|
{ name: "id", type: "string", internalType: "string" }
|
|
845
936
|
]
|
|
846
|
-
}
|
|
937
|
+
},
|
|
938
|
+
{ name: "offset", type: "uint256", internalType: "uint256" },
|
|
939
|
+
{ name: "limit", type: "uint256", internalType: "uint256" }
|
|
847
940
|
],
|
|
848
941
|
outputs: [
|
|
849
942
|
{
|
|
@@ -871,7 +964,11 @@ var abi_default = [
|
|
|
871
964
|
},
|
|
872
965
|
{ name: "timestamp", type: "uint64", internalType: "uint64" },
|
|
873
966
|
{ name: "tipper", type: "address", internalType: "address" },
|
|
874
|
-
{
|
|
967
|
+
{
|
|
968
|
+
name: "nftIds",
|
|
969
|
+
type: "uint256[]",
|
|
970
|
+
internalType: "uint256[]"
|
|
971
|
+
}
|
|
875
972
|
]
|
|
876
973
|
}
|
|
877
974
|
],
|
|
@@ -897,7 +994,11 @@ var abi_default = [
|
|
|
897
994
|
type: "address",
|
|
898
995
|
internalType: "contract IPrimusZKTLS"
|
|
899
996
|
},
|
|
900
|
-
{
|
|
997
|
+
{
|
|
998
|
+
name: "feeRecipient_",
|
|
999
|
+
type: "address",
|
|
1000
|
+
internalType: "address"
|
|
1001
|
+
},
|
|
901
1002
|
{ name: "claimFee_", type: "uint256", internalType: "uint256" }
|
|
902
1003
|
],
|
|
903
1004
|
outputs: [],
|
|
@@ -915,7 +1016,11 @@ var abi_default = [
|
|
|
915
1016
|
name: "primusZKTLS",
|
|
916
1017
|
inputs: [],
|
|
917
1018
|
outputs: [
|
|
918
|
-
{
|
|
1019
|
+
{
|
|
1020
|
+
name: "",
|
|
1021
|
+
type: "address",
|
|
1022
|
+
internalType: "contract IPrimusZKTLS"
|
|
1023
|
+
}
|
|
919
1024
|
],
|
|
920
1025
|
stateMutability: "view"
|
|
921
1026
|
},
|
|
@@ -939,7 +1044,11 @@ var abi_default = [
|
|
|
939
1044
|
type: "function",
|
|
940
1045
|
name: "setFeeRecipient",
|
|
941
1046
|
inputs: [
|
|
942
|
-
{
|
|
1047
|
+
{
|
|
1048
|
+
name: "feeRecipient_",
|
|
1049
|
+
type: "address",
|
|
1050
|
+
internalType: "address"
|
|
1051
|
+
}
|
|
943
1052
|
],
|
|
944
1053
|
outputs: [],
|
|
945
1054
|
stateMutability: "nonpayable"
|
|
@@ -991,7 +1100,11 @@ var abi_default = [
|
|
|
991
1100
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
992
1101
|
{ name: "id", type: "string", internalType: "string" },
|
|
993
1102
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
994
|
-
{
|
|
1103
|
+
{
|
|
1104
|
+
name: "nftIds",
|
|
1105
|
+
type: "uint256[]",
|
|
1106
|
+
internalType: "uint256[]"
|
|
1107
|
+
}
|
|
995
1108
|
]
|
|
996
1109
|
}
|
|
997
1110
|
],
|
|
@@ -1023,7 +1136,11 @@ var abi_default = [
|
|
|
1023
1136
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1024
1137
|
{ name: "id", type: "string", internalType: "string" },
|
|
1025
1138
|
{ name: "amount", type: "uint256", internalType: "uint256" },
|
|
1026
|
-
{
|
|
1139
|
+
{
|
|
1140
|
+
name: "nftIds",
|
|
1141
|
+
type: "uint256[]",
|
|
1142
|
+
internalType: "uint256[]"
|
|
1143
|
+
}
|
|
1027
1144
|
]
|
|
1028
1145
|
}
|
|
1029
1146
|
],
|
|
@@ -1041,7 +1158,11 @@ var abi_default = [
|
|
|
1041
1158
|
components: [
|
|
1042
1159
|
{ name: "idSource", type: "string", internalType: "string" },
|
|
1043
1160
|
{ name: "id", type: "string", internalType: "string" },
|
|
1044
|
-
{
|
|
1161
|
+
{
|
|
1162
|
+
name: "tipTimestamp",
|
|
1163
|
+
type: "uint64",
|
|
1164
|
+
internalType: "uint64"
|
|
1165
|
+
}
|
|
1045
1166
|
]
|
|
1046
1167
|
}
|
|
1047
1168
|
],
|
|
@@ -1115,6 +1236,18 @@ var abi_default = [
|
|
|
1115
1236
|
type: "uint64",
|
|
1116
1237
|
indexed: false,
|
|
1117
1238
|
internalType: "uint64"
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
name: "tokenType",
|
|
1242
|
+
type: "uint32",
|
|
1243
|
+
indexed: false,
|
|
1244
|
+
internalType: "uint32"
|
|
1245
|
+
},
|
|
1246
|
+
{
|
|
1247
|
+
name: "nftIds",
|
|
1248
|
+
type: "uint256[]",
|
|
1249
|
+
indexed: false,
|
|
1250
|
+
internalType: "uint256[]"
|
|
1118
1251
|
}
|
|
1119
1252
|
],
|
|
1120
1253
|
anonymous: false
|
|
@@ -1190,6 +1323,18 @@ var abi_default = [
|
|
|
1190
1323
|
type: "uint64",
|
|
1191
1324
|
indexed: false,
|
|
1192
1325
|
internalType: "uint64"
|
|
1326
|
+
},
|
|
1327
|
+
{
|
|
1328
|
+
name: "tokenType",
|
|
1329
|
+
type: "uint32",
|
|
1330
|
+
indexed: false,
|
|
1331
|
+
internalType: "uint32"
|
|
1332
|
+
},
|
|
1333
|
+
{
|
|
1334
|
+
name: "nftIds",
|
|
1335
|
+
type: "uint256[]",
|
|
1336
|
+
indexed: false,
|
|
1337
|
+
internalType: "uint256[]"
|
|
1193
1338
|
}
|
|
1194
1339
|
],
|
|
1195
1340
|
anonymous: false
|
|
@@ -1239,6 +1384,18 @@ var abi_default = [
|
|
|
1239
1384
|
type: "uint64",
|
|
1240
1385
|
indexed: false,
|
|
1241
1386
|
internalType: "uint64"
|
|
1387
|
+
},
|
|
1388
|
+
{
|
|
1389
|
+
name: "tokenType",
|
|
1390
|
+
type: "uint32",
|
|
1391
|
+
indexed: false,
|
|
1392
|
+
internalType: "uint32"
|
|
1393
|
+
},
|
|
1394
|
+
{
|
|
1395
|
+
name: "nftIds",
|
|
1396
|
+
type: "uint256[]",
|
|
1397
|
+
indexed: false,
|
|
1398
|
+
internalType: "uint256[]"
|
|
1242
1399
|
}
|
|
1243
1400
|
],
|
|
1244
1401
|
anonymous: false
|
|
@@ -1447,6 +1604,7 @@ var Erc721Contract = class {
|
|
|
1447
1604
|
var Erc721Contract_default = Erc721Contract;
|
|
1448
1605
|
|
|
1449
1606
|
// src/classes/Fund.ts
|
|
1607
|
+
var defaultDecimals = 18;
|
|
1450
1608
|
var { parseUnits: parseUnits2, formatUnits: formatUnits2 } = ethers3.utils;
|
|
1451
1609
|
var Fund = class {
|
|
1452
1610
|
fundContract;
|
|
@@ -1476,7 +1634,7 @@ var Fund = class {
|
|
|
1476
1634
|
try {
|
|
1477
1635
|
const recipientInfos = [];
|
|
1478
1636
|
recipientInfos[0] = recipientInfo;
|
|
1479
|
-
let decimals =
|
|
1637
|
+
let decimals = defaultDecimals;
|
|
1480
1638
|
let params = [];
|
|
1481
1639
|
if (tokenInfo.tokenType === 0) {
|
|
1482
1640
|
await this.approve(tokenInfo, recipientInfos);
|
|
@@ -1517,7 +1675,7 @@ var Fund = class {
|
|
|
1517
1675
|
try {
|
|
1518
1676
|
const recipientInfos = [];
|
|
1519
1677
|
recipientInfos[0] = recipientInfo;
|
|
1520
|
-
let decimals =
|
|
1678
|
+
let decimals = defaultDecimals;
|
|
1521
1679
|
let params = [];
|
|
1522
1680
|
if (tokenInfo.tokenType === 0) {
|
|
1523
1681
|
const tokenContract = new Erc20Contract_default(this.provider, tokenInfo.tokenAddress);
|
|
@@ -1578,7 +1736,7 @@ var Fund = class {
|
|
|
1578
1736
|
async fundBatch(tokenInfo, recipientInfoList) {
|
|
1579
1737
|
return new Promise(async (resolve, reject) => {
|
|
1580
1738
|
try {
|
|
1581
|
-
let decimals =
|
|
1739
|
+
let decimals = defaultDecimals;
|
|
1582
1740
|
let params = [];
|
|
1583
1741
|
if (tokenInfo.tokenType === 0) {
|
|
1584
1742
|
await this.approve(tokenInfo, recipientInfoList);
|
|
@@ -1729,6 +1887,51 @@ var Fund = class {
|
|
|
1729
1887
|
}
|
|
1730
1888
|
});
|
|
1731
1889
|
}
|
|
1890
|
+
async _formatTipRecords(fundRecords) {
|
|
1891
|
+
console.log("fundRecords", fundRecords);
|
|
1892
|
+
let formatRecords = [];
|
|
1893
|
+
for (const record of fundRecords) {
|
|
1894
|
+
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1895
|
+
let decimals = defaultDecimals;
|
|
1896
|
+
let symbol = "";
|
|
1897
|
+
let tokenId = null;
|
|
1898
|
+
let nftInfo = null;
|
|
1899
|
+
if (tokenType === 0) {
|
|
1900
|
+
const tokenContract = new Erc20Contract_default(this.provider, tokenAddress);
|
|
1901
|
+
decimals = await tokenContract.decimals();
|
|
1902
|
+
symbol = await tokenContract.symbol();
|
|
1903
|
+
} else if (tokenType === 1) {
|
|
1904
|
+
symbol = NATIVETOKENS[this.chainId];
|
|
1905
|
+
} else if (tokenType === 2) {
|
|
1906
|
+
decimals = 0;
|
|
1907
|
+
tokenId = parseInt(nftIds[0]);
|
|
1908
|
+
const erc721ContractInstance = new Erc721Contract_default(this.provider, tokenAddress);
|
|
1909
|
+
nftInfo = await erc721ContractInstance.fetchMetaData(tokenAddress, tokenId);
|
|
1910
|
+
}
|
|
1911
|
+
let fundToken = {
|
|
1912
|
+
tokenType,
|
|
1913
|
+
// tokenAmount: formatUnits(amount, decimals),
|
|
1914
|
+
decimals,
|
|
1915
|
+
symbol,
|
|
1916
|
+
chainName: CHAINNAMES[this.chainId],
|
|
1917
|
+
chainId: this.chainId
|
|
1918
|
+
};
|
|
1919
|
+
if (tokenType === 0) {
|
|
1920
|
+
fundToken.tokenAddress = tokenAddress;
|
|
1921
|
+
}
|
|
1922
|
+
if (tokenType === 2) {
|
|
1923
|
+
Object.assign(fundToken, nftInfo ?? {});
|
|
1924
|
+
}
|
|
1925
|
+
formatRecords.push({
|
|
1926
|
+
funder: tipper,
|
|
1927
|
+
fundToken,
|
|
1928
|
+
amount: formatUnits2(amount, decimals),
|
|
1929
|
+
timestamp: timestamp.toNumber()
|
|
1930
|
+
});
|
|
1931
|
+
}
|
|
1932
|
+
console.log("formatRecords", formatRecords);
|
|
1933
|
+
return formatRecords;
|
|
1934
|
+
}
|
|
1732
1935
|
async getTipRecords(getFundRecordsParams) {
|
|
1733
1936
|
return new Promise(async (resolve, reject) => {
|
|
1734
1937
|
try {
|
|
@@ -1739,67 +1942,81 @@ var Fund = class {
|
|
|
1739
1942
|
};
|
|
1740
1943
|
});
|
|
1741
1944
|
const fundRecords = await this.fundContract.callMethod("getTipRecords", formatGetFundRecordsParams);
|
|
1742
|
-
|
|
1743
|
-
let formatRecords = [];
|
|
1744
|
-
for (const record of fundRecords) {
|
|
1745
|
-
const { tipper, timestamp, tipToken: [tokenType, tokenAddress], amount, nftIds } = record;
|
|
1746
|
-
let decimals = 18;
|
|
1747
|
-
let symbol = "";
|
|
1748
|
-
let tokenId = null;
|
|
1749
|
-
let nftInfo = null;
|
|
1750
|
-
if (tokenType === 0) {
|
|
1751
|
-
const tokenContract = new Erc20Contract_default(this.provider, tokenAddress);
|
|
1752
|
-
decimals = await tokenContract.decimals();
|
|
1753
|
-
symbol = await tokenContract.symbol();
|
|
1754
|
-
} else if (tokenType === 1) {
|
|
1755
|
-
symbol = NATIVETOKENS[this.chainId];
|
|
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
|
|
1769
|
-
};
|
|
1770
|
-
if (tokenType === 0) {
|
|
1771
|
-
fundToken.tokenAddress = tokenAddress;
|
|
1772
|
-
}
|
|
1773
|
-
if (tokenType === 2) {
|
|
1774
|
-
Object.assign(fundToken, nftInfo ?? {});
|
|
1775
|
-
}
|
|
1776
|
-
formatRecords.push({
|
|
1777
|
-
funder: tipper,
|
|
1778
|
-
fundToken,
|
|
1779
|
-
amount: formatUnits2(amount, decimals),
|
|
1780
|
-
timestamp: timestamp.toNumber()
|
|
1781
|
-
});
|
|
1782
|
-
}
|
|
1783
|
-
console.log("formatRecords", formatRecords);
|
|
1945
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
1784
1946
|
return resolve(formatRecords);
|
|
1785
1947
|
} catch (error) {
|
|
1786
1948
|
return reject(error);
|
|
1787
1949
|
}
|
|
1788
1950
|
});
|
|
1789
1951
|
}
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1952
|
+
async getTipRecordsNativeAmount(getFundRecordsParams) {
|
|
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
|
+
const fundNativeTokenAmount = await this.fundContract.callMethod("getTipRecordsNativeAmount", formatGetFundRecordsParams);
|
|
1962
|
+
const amount = formatUnits2(fundNativeTokenAmount, defaultDecimals);
|
|
1963
|
+
console.log("fundNativeTokenAmount", amount);
|
|
1964
|
+
return resolve(amount);
|
|
1965
|
+
} catch (error) {
|
|
1966
|
+
return reject(error);
|
|
1967
|
+
}
|
|
1968
|
+
});
|
|
1969
|
+
}
|
|
1970
|
+
async getTipRecordsLength(getFundRecordsParams) {
|
|
1971
|
+
return new Promise(async (resolve, reject) => {
|
|
1972
|
+
try {
|
|
1973
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1974
|
+
return {
|
|
1975
|
+
idSource: item.socialPlatform,
|
|
1976
|
+
id: item.userIdentifier
|
|
1977
|
+
};
|
|
1978
|
+
});
|
|
1979
|
+
const fundRecordsLen = await this.fundContract.callMethod("getTipRecordsLength", formatGetFundRecordsParams);
|
|
1980
|
+
const len = fundRecordsLen.toNumber();
|
|
1981
|
+
console.log("fundRecordsLength", len);
|
|
1982
|
+
return resolve(len);
|
|
1983
|
+
} catch (error) {
|
|
1984
|
+
return reject(error);
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
}
|
|
1988
|
+
async getTipRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
1989
|
+
return new Promise(async (resolve, reject) => {
|
|
1990
|
+
try {
|
|
1991
|
+
const formatGetFundRecordsParams = getFundRecordsParams.map((item) => {
|
|
1992
|
+
return {
|
|
1993
|
+
idSource: item.socialPlatform,
|
|
1994
|
+
id: item.userIdentifier
|
|
1995
|
+
};
|
|
1996
|
+
});
|
|
1997
|
+
let params = [...formatGetFundRecordsParams, pageNum, pageSize];
|
|
1998
|
+
const fundRecords = await this.fundContract.callMethod("getTipRecordsPaginated", params);
|
|
1999
|
+
let formatRecords = await this._formatTipRecords(fundRecords);
|
|
2000
|
+
console.log("fundRecordsPaginated", formatRecords);
|
|
2001
|
+
return resolve(formatRecords);
|
|
2002
|
+
} catch (error) {
|
|
2003
|
+
return reject(error);
|
|
2004
|
+
}
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
};
|
|
2008
|
+
|
|
2009
|
+
// src/classes/FundForRedPacket.ts
|
|
2010
|
+
import { ethers as ethers4 } from "ethers";
|
|
2011
|
+
|
|
2012
|
+
// src/config/abiForRedPacket.json
|
|
2013
|
+
var abiForRedPacket_default = [
|
|
2014
|
+
{
|
|
2015
|
+
type: "function",
|
|
2016
|
+
name: "claimFee",
|
|
2017
|
+
inputs: [],
|
|
2018
|
+
outputs: [{ name: "", type: "uint256", internalType: "uint256" }],
|
|
2019
|
+
stateMutability: "view"
|
|
1803
2020
|
},
|
|
1804
2021
|
{
|
|
1805
2022
|
type: "function",
|
|
@@ -2536,193 +2753,3724 @@ var FundForRedPacket = class {
|
|
|
2536
2753
|
}
|
|
2537
2754
|
};
|
|
2538
2755
|
|
|
2539
|
-
// src/classes/
|
|
2540
|
-
import
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2756
|
+
// src/classes/FundOnSolanaForRedPacket.ts
|
|
2757
|
+
import * as anchor3 from "@coral-xyz/anchor";
|
|
2758
|
+
|
|
2759
|
+
// src/classes/solana/program.ts
|
|
2760
|
+
import { Program } from "@coral-xyz/anchor";
|
|
2761
|
+
import * as anchor from "@coral-xyz/anchor";
|
|
2762
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2763
|
+
import { getMint } from "@solana/spl-token";
|
|
2764
|
+
import { encode as encodeBase58 } from "micro-base58";
|
|
2765
|
+
import * as borsh from "borsh";
|
|
2766
|
+
var { deserialize } = borsh;
|
|
2767
|
+
var BN2 = anchor.BN;
|
|
2768
|
+
var getProgram = (idl, anchorProvider) => {
|
|
2769
|
+
return new Program(idl, anchorProvider);
|
|
2770
|
+
};
|
|
2771
|
+
var toTokenAmount = (amount, decimals) => {
|
|
2772
|
+
const [integerPart, fractionalPart = ""] = String(amount).split(".");
|
|
2773
|
+
const fractionalPadded = fractionalPart.padEnd(decimals, "0").slice(0, decimals);
|
|
2774
|
+
const raw = integerPart + fractionalPadded;
|
|
2775
|
+
const cleaned = raw.replace(/^0+/, "") || "0";
|
|
2776
|
+
return new BN2(cleaned);
|
|
2777
|
+
};
|
|
2778
|
+
async function getTokenDecimals(mintAddress, connection) {
|
|
2779
|
+
const mintPubkey = new PublicKey(mintAddress);
|
|
2780
|
+
const mintInfo = await getMint(connection, mintPubkey);
|
|
2781
|
+
return mintInfo.decimals;
|
|
2782
|
+
}
|
|
2783
|
+
var hexToUint8Array = (hex) => {
|
|
2784
|
+
let hexStr = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
2785
|
+
return Buffer.from(hexStr.toLowerCase(), "hex");
|
|
2786
|
+
};
|
|
2787
|
+
function formatAttestation(attestation) {
|
|
2788
|
+
const {
|
|
2789
|
+
additionParams,
|
|
2790
|
+
attConditions,
|
|
2791
|
+
attestors,
|
|
2792
|
+
data,
|
|
2793
|
+
recipient,
|
|
2794
|
+
responseResolve,
|
|
2795
|
+
request,
|
|
2796
|
+
signatures,
|
|
2797
|
+
timestamp
|
|
2798
|
+
} = attestation;
|
|
2799
|
+
const formatAttestors = attestors.map(({ attestorAddr, url }) => {
|
|
2800
|
+
return {
|
|
2801
|
+
attestorAddr: hexToUint8Array(attestorAddr),
|
|
2802
|
+
url
|
|
2803
|
+
};
|
|
2804
|
+
});
|
|
2805
|
+
const formatSignatures = signatures.map((s) => hexToUint8Array(s));
|
|
2806
|
+
const formatAtt = {
|
|
2807
|
+
additionParams,
|
|
2808
|
+
attConditions,
|
|
2809
|
+
attestors: formatAttestors,
|
|
2810
|
+
data,
|
|
2811
|
+
recipient: new PublicKey(recipient).toBytes(),
|
|
2812
|
+
responseResolve,
|
|
2813
|
+
request,
|
|
2814
|
+
signatures: formatSignatures,
|
|
2815
|
+
timestamp: new anchor.BN(timestamp)
|
|
2816
|
+
};
|
|
2817
|
+
return formatAtt;
|
|
2818
|
+
}
|
|
2819
|
+
async function decodeReSendEvent(eventData) {
|
|
2820
|
+
const eventBuffer = Buffer.from(eventData, "base64");
|
|
2821
|
+
const raw = eventBuffer.slice(8);
|
|
2822
|
+
console.log("eventBuffer first 8 bytes:", Array.from(eventBuffer.slice(0, 8)));
|
|
2823
|
+
class CheckParams {
|
|
2824
|
+
check_type;
|
|
2825
|
+
params;
|
|
2826
|
+
constructor(fields) {
|
|
2827
|
+
this.check_type = fields.check_type;
|
|
2828
|
+
this.params = fields.params;
|
|
2829
|
+
}
|
|
2544
2830
|
}
|
|
2545
|
-
|
|
2546
|
-
|
|
2831
|
+
class RESendEvent {
|
|
2832
|
+
id;
|
|
2833
|
+
re_sender;
|
|
2834
|
+
token_type;
|
|
2835
|
+
token_address;
|
|
2836
|
+
amount;
|
|
2837
|
+
re_type;
|
|
2838
|
+
number;
|
|
2839
|
+
timestamp;
|
|
2840
|
+
check_params;
|
|
2841
|
+
empty_ratio;
|
|
2842
|
+
constructor(fields) {
|
|
2843
|
+
this.id = fields.id;
|
|
2844
|
+
this.re_sender = fields.re_sender;
|
|
2845
|
+
this.token_type = fields.token_type;
|
|
2846
|
+
this.token_address = fields.token_address;
|
|
2847
|
+
this.amount = fields.amount;
|
|
2848
|
+
this.re_type = fields.re_type;
|
|
2849
|
+
this.number = fields.number;
|
|
2850
|
+
this.timestamp = fields.timestamp;
|
|
2851
|
+
this.check_params = new CheckParams(fields.check_params);
|
|
2852
|
+
this.empty_ratio = fields.empty_ratio;
|
|
2853
|
+
}
|
|
2547
2854
|
}
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2855
|
+
const CheckParamsJson = {
|
|
2856
|
+
"kind": "struct",
|
|
2857
|
+
"fields": [
|
|
2858
|
+
["check_type", "u32"],
|
|
2859
|
+
["params", "string"]
|
|
2860
|
+
]
|
|
2861
|
+
};
|
|
2862
|
+
const RESendEventJson = {
|
|
2863
|
+
"kind": "struct",
|
|
2864
|
+
"fields": [
|
|
2865
|
+
["id", [32]],
|
|
2866
|
+
["re_sender", [32]],
|
|
2867
|
+
["token_type", "u32"],
|
|
2868
|
+
["token_address", [32]],
|
|
2869
|
+
["amount", "u64"],
|
|
2870
|
+
["re_type", "u32"],
|
|
2871
|
+
["number", "u32"],
|
|
2872
|
+
["timestamp", "u64"],
|
|
2873
|
+
["check_params", CheckParams],
|
|
2874
|
+
["empty_ratio", "u8"]
|
|
2875
|
+
]
|
|
2876
|
+
};
|
|
2877
|
+
const schema2 = /* @__PURE__ */ new Map([
|
|
2878
|
+
[CheckParams, CheckParamsJson],
|
|
2879
|
+
[RESendEvent, RESendEventJson]
|
|
2880
|
+
]);
|
|
2881
|
+
const res = deserialize(schema2, RESendEvent, raw);
|
|
2882
|
+
console.log("decodeReSendEvent=", res);
|
|
2883
|
+
return res;
|
|
2884
|
+
}
|
|
2885
|
+
async function decodeClaimEvent(eventData) {
|
|
2886
|
+
const eventBuffer = Buffer.from(eventData, "base64");
|
|
2887
|
+
const raw = eventBuffer.slice(8);
|
|
2888
|
+
console.log("eventBuffer first 8 bytes:", Array.from(eventBuffer.slice(0, 8)));
|
|
2889
|
+
class REClaimEvent {
|
|
2890
|
+
id;
|
|
2891
|
+
user;
|
|
2892
|
+
user_id;
|
|
2893
|
+
amount;
|
|
2894
|
+
index;
|
|
2895
|
+
timestamp;
|
|
2896
|
+
token_address;
|
|
2897
|
+
constructor(fields) {
|
|
2898
|
+
this.id = fields.id;
|
|
2899
|
+
this.user = fields.user;
|
|
2900
|
+
this.user_id = fields.user_id;
|
|
2901
|
+
this.amount = fields.amount;
|
|
2902
|
+
this.index = fields.index;
|
|
2903
|
+
this.timestamp = fields.timestamp;
|
|
2904
|
+
this.token_address = fields.token_address;
|
|
2905
|
+
}
|
|
2574
2906
|
}
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
return reject(`appSignature is empty!`);
|
|
2601
|
-
}
|
|
2602
|
-
try {
|
|
2603
|
-
const formatAttestParams = {
|
|
2604
|
-
attRequest: {
|
|
2605
|
-
...JSON.parse(signParams)
|
|
2606
|
-
},
|
|
2607
|
-
appSignature: signature
|
|
2608
|
-
};
|
|
2609
|
-
const attestation = await this.zkTlsSdk.startAttestation(
|
|
2610
|
-
JSON.stringify(formatAttestParams)
|
|
2611
|
-
);
|
|
2612
|
-
return resolve(attestation);
|
|
2613
|
-
} catch (error) {
|
|
2614
|
-
return reject(error);
|
|
2615
|
-
}
|
|
2616
|
-
});
|
|
2907
|
+
const REClaimEventJson = {
|
|
2908
|
+
"kind": "struct",
|
|
2909
|
+
"fields": [
|
|
2910
|
+
["id", [32]],
|
|
2911
|
+
["user", [32]],
|
|
2912
|
+
["user_id", "string"],
|
|
2913
|
+
["amount", "u64"],
|
|
2914
|
+
["index", "u32"],
|
|
2915
|
+
["timestamp", "u64"],
|
|
2916
|
+
["token_address", [32]]
|
|
2917
|
+
]
|
|
2918
|
+
};
|
|
2919
|
+
const schema2 = /* @__PURE__ */ new Map([
|
|
2920
|
+
[REClaimEvent, REClaimEventJson]
|
|
2921
|
+
]);
|
|
2922
|
+
const res = deserialize(schema2, REClaimEvent, raw);
|
|
2923
|
+
console.log("res=", res);
|
|
2924
|
+
console.log("res=", new PublicKey(res.user).toBase58());
|
|
2925
|
+
return res;
|
|
2926
|
+
}
|
|
2927
|
+
var getTxSigStrFromTx = (signedTx) => {
|
|
2928
|
+
if (signedTx?.signatures[0] && signedTx?.signatures[0].signature) {
|
|
2929
|
+
const signatureBytes = signedTx.signatures[0].signature;
|
|
2930
|
+
const signatureStr = encodeBase58(signatureBytes);
|
|
2931
|
+
return signatureStr;
|
|
2617
2932
|
}
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
}
|
|
2629
|
-
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
2630
|
-
if (conditions) {
|
|
2631
|
-
attRequest.setAttConditions(conditions);
|
|
2632
|
-
}
|
|
2633
|
-
if (additionParams) {
|
|
2634
|
-
console.log("setAdditionParams--", additionParams);
|
|
2635
|
-
attRequest.setAdditionParams(additionParams);
|
|
2636
|
-
}
|
|
2637
|
-
const signParams = attRequest.toJsonString();
|
|
2638
|
-
const signature = await signFn(signParams);
|
|
2639
|
-
if (!signature) {
|
|
2640
|
-
return reject(`appSignature is empty!`);
|
|
2641
|
-
}
|
|
2642
|
-
try {
|
|
2643
|
-
const formatAttestParams = {
|
|
2644
|
-
attRequest: {
|
|
2645
|
-
...JSON.parse(signParams)
|
|
2646
|
-
},
|
|
2647
|
-
appSignature: signature
|
|
2648
|
-
};
|
|
2649
|
-
const attestation = await this.zkTlsSdk.startAttestation(
|
|
2650
|
-
JSON.stringify(formatAttestParams)
|
|
2651
|
-
);
|
|
2652
|
-
return resolve(attestation);
|
|
2653
|
-
} catch (error) {
|
|
2654
|
-
return reject(error);
|
|
2655
|
-
}
|
|
2656
|
-
});
|
|
2933
|
+
return "";
|
|
2934
|
+
};
|
|
2935
|
+
var getTxIsOnChain = async (signatureStr, connection) => {
|
|
2936
|
+
if (signatureStr) {
|
|
2937
|
+
const { value } = await connection.getSignatureStatus(signatureStr);
|
|
2938
|
+
if (value && value.confirmationStatus) {
|
|
2939
|
+
return true;
|
|
2940
|
+
} else {
|
|
2941
|
+
return false;
|
|
2942
|
+
}
|
|
2657
2943
|
}
|
|
2944
|
+
return false;
|
|
2945
|
+
};
|
|
2946
|
+
var getTxIsOnProcess = (err) => {
|
|
2947
|
+
const strArr = ["This transaction has already been processed"];
|
|
2948
|
+
const curErrorStrArr = getErrArrFn(err);
|
|
2949
|
+
const isOnProcess = hasErrorFlagFn(curErrorStrArr, strArr);
|
|
2950
|
+
return isOnProcess;
|
|
2658
2951
|
};
|
|
2659
2952
|
|
|
2660
|
-
// src/
|
|
2661
|
-
var
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2953
|
+
// src/config/redPacketIdl.json
|
|
2954
|
+
var redPacketIdl_default = {
|
|
2955
|
+
address: "EmK8RSeeHBxb1iZUipon2QqvatcuJyJZM4cpTtSAYzud",
|
|
2956
|
+
metadata: {
|
|
2957
|
+
name: "primus_red_envelope",
|
|
2958
|
+
version: "0.1.0",
|
|
2959
|
+
spec: "0.1.0",
|
|
2960
|
+
description: "Created with Anchor"
|
|
2961
|
+
},
|
|
2962
|
+
instructions: [
|
|
2963
|
+
{
|
|
2964
|
+
name: "initialize",
|
|
2965
|
+
discriminator: [
|
|
2966
|
+
175,
|
|
2967
|
+
175,
|
|
2968
|
+
109,
|
|
2969
|
+
31,
|
|
2970
|
+
13,
|
|
2971
|
+
152,
|
|
2972
|
+
155,
|
|
2973
|
+
237
|
|
2974
|
+
],
|
|
2975
|
+
accounts: [
|
|
2976
|
+
{
|
|
2977
|
+
name: "state",
|
|
2978
|
+
writable: true,
|
|
2979
|
+
pda: {
|
|
2980
|
+
seeds: [
|
|
2981
|
+
{
|
|
2982
|
+
kind: "const",
|
|
2983
|
+
value: [
|
|
2984
|
+
114,
|
|
2985
|
+
101,
|
|
2986
|
+
100,
|
|
2987
|
+
95,
|
|
2988
|
+
101,
|
|
2989
|
+
110,
|
|
2990
|
+
118,
|
|
2991
|
+
101,
|
|
2992
|
+
108,
|
|
2993
|
+
111,
|
|
2994
|
+
112,
|
|
2995
|
+
101
|
|
2996
|
+
]
|
|
2997
|
+
}
|
|
2998
|
+
]
|
|
2999
|
+
}
|
|
3000
|
+
},
|
|
3001
|
+
{
|
|
3002
|
+
name: "owner",
|
|
3003
|
+
writable: true,
|
|
3004
|
+
signer: true
|
|
3005
|
+
},
|
|
3006
|
+
{
|
|
3007
|
+
name: "system_program",
|
|
3008
|
+
address: "11111111111111111111111111111111"
|
|
2673
3009
|
}
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
if (providerChainId !== chainId) {
|
|
2688
|
-
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
2689
|
-
}
|
|
2690
|
-
this.provider = signer ?? formatProvider;
|
|
2691
|
-
this._fund = new Fund();
|
|
2692
|
-
const result = await this._fund.init(this.provider, chainId);
|
|
2693
|
-
this._fundForRedPacket = new FundForRedPacket();
|
|
2694
|
-
await this._fundForRedPacket.init(this.provider, chainId);
|
|
2695
|
-
if (appId) {
|
|
2696
|
-
this._zkTlsSdk = new ZktlsSdk();
|
|
2697
|
-
await this._zkTlsSdk.init(appId);
|
|
3010
|
+
],
|
|
3011
|
+
args: [
|
|
3012
|
+
{
|
|
3013
|
+
name: "primus_zktls",
|
|
3014
|
+
type: "pubkey"
|
|
3015
|
+
},
|
|
3016
|
+
{
|
|
3017
|
+
name: "fee_recipient",
|
|
3018
|
+
type: "pubkey"
|
|
3019
|
+
},
|
|
3020
|
+
{
|
|
3021
|
+
name: "claim_fee",
|
|
3022
|
+
type: "u64"
|
|
2698
3023
|
}
|
|
2699
|
-
|
|
2700
|
-
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
3024
|
+
]
|
|
3025
|
+
},
|
|
3026
|
+
{
|
|
3027
|
+
name: "re_claim",
|
|
3028
|
+
discriminator: [
|
|
3029
|
+
105,
|
|
3030
|
+
179,
|
|
3031
|
+
220,
|
|
3032
|
+
94,
|
|
3033
|
+
121,
|
|
3034
|
+
140,
|
|
3035
|
+
144,
|
|
3036
|
+
24
|
|
3037
|
+
],
|
|
3038
|
+
accounts: [
|
|
3039
|
+
{
|
|
3040
|
+
name: "state",
|
|
3041
|
+
writable: true
|
|
3042
|
+
},
|
|
3043
|
+
{
|
|
3044
|
+
name: "re_record",
|
|
3045
|
+
writable: true,
|
|
3046
|
+
pda: {
|
|
3047
|
+
seeds: [
|
|
3048
|
+
{
|
|
3049
|
+
kind: "const",
|
|
3050
|
+
value: [
|
|
3051
|
+
114,
|
|
3052
|
+
101,
|
|
3053
|
+
95,
|
|
3054
|
+
114,
|
|
3055
|
+
101,
|
|
3056
|
+
99,
|
|
3057
|
+
111,
|
|
3058
|
+
114,
|
|
3059
|
+
100
|
|
3060
|
+
]
|
|
3061
|
+
},
|
|
3062
|
+
{
|
|
3063
|
+
kind: "arg",
|
|
3064
|
+
path: "re_id"
|
|
3065
|
+
}
|
|
3066
|
+
]
|
|
3067
|
+
}
|
|
3068
|
+
},
|
|
3069
|
+
{
|
|
3070
|
+
name: "re_record_data",
|
|
3071
|
+
writable: true
|
|
3072
|
+
},
|
|
3073
|
+
{
|
|
3074
|
+
name: "claimer",
|
|
3075
|
+
writable: true,
|
|
3076
|
+
signer: true
|
|
3077
|
+
},
|
|
3078
|
+
{
|
|
3079
|
+
name: "system_program",
|
|
3080
|
+
address: "11111111111111111111111111111111"
|
|
3081
|
+
},
|
|
3082
|
+
{
|
|
3083
|
+
name: "primus_zktls_state",
|
|
3084
|
+
writable: true
|
|
3085
|
+
},
|
|
3086
|
+
{
|
|
3087
|
+
name: "primus_zktls_program",
|
|
3088
|
+
address: "3qG9pUbAHfizoqnvj9GxnTPaVgkyb7Ry6Q5vozMYdVAA"
|
|
3089
|
+
},
|
|
3090
|
+
{
|
|
3091
|
+
name: "fee_recipient",
|
|
3092
|
+
writable: true
|
|
3093
|
+
},
|
|
3094
|
+
{
|
|
3095
|
+
name: "att_recipient",
|
|
3096
|
+
writable: true
|
|
3097
|
+
},
|
|
3098
|
+
{
|
|
3099
|
+
name: "data_buffer",
|
|
3100
|
+
writable: true,
|
|
3101
|
+
optional: true
|
|
3102
|
+
},
|
|
3103
|
+
{
|
|
3104
|
+
name: "from_token_account",
|
|
3105
|
+
writable: true,
|
|
3106
|
+
optional: true,
|
|
3107
|
+
pda: {
|
|
3108
|
+
seeds: [
|
|
3109
|
+
{
|
|
3110
|
+
kind: "account",
|
|
3111
|
+
path: "state"
|
|
3112
|
+
},
|
|
3113
|
+
{
|
|
3114
|
+
kind: "const",
|
|
3115
|
+
value: [
|
|
3116
|
+
6,
|
|
3117
|
+
221,
|
|
3118
|
+
246,
|
|
3119
|
+
225,
|
|
3120
|
+
215,
|
|
3121
|
+
101,
|
|
3122
|
+
161,
|
|
3123
|
+
147,
|
|
3124
|
+
217,
|
|
3125
|
+
203,
|
|
3126
|
+
225,
|
|
3127
|
+
70,
|
|
3128
|
+
206,
|
|
3129
|
+
235,
|
|
3130
|
+
121,
|
|
3131
|
+
172,
|
|
3132
|
+
28,
|
|
3133
|
+
180,
|
|
3134
|
+
133,
|
|
3135
|
+
237,
|
|
3136
|
+
95,
|
|
3137
|
+
91,
|
|
3138
|
+
55,
|
|
3139
|
+
145,
|
|
3140
|
+
58,
|
|
3141
|
+
140,
|
|
3142
|
+
245,
|
|
3143
|
+
133,
|
|
3144
|
+
126,
|
|
3145
|
+
255,
|
|
3146
|
+
0,
|
|
3147
|
+
169
|
|
3148
|
+
]
|
|
3149
|
+
},
|
|
3150
|
+
{
|
|
3151
|
+
kind: "account",
|
|
3152
|
+
path: "mint"
|
|
3153
|
+
}
|
|
3154
|
+
],
|
|
3155
|
+
program: {
|
|
3156
|
+
kind: "const",
|
|
3157
|
+
value: [
|
|
3158
|
+
140,
|
|
3159
|
+
151,
|
|
3160
|
+
37,
|
|
3161
|
+
143,
|
|
3162
|
+
78,
|
|
3163
|
+
36,
|
|
3164
|
+
137,
|
|
3165
|
+
241,
|
|
3166
|
+
187,
|
|
3167
|
+
61,
|
|
3168
|
+
16,
|
|
3169
|
+
41,
|
|
3170
|
+
20,
|
|
3171
|
+
142,
|
|
3172
|
+
13,
|
|
3173
|
+
131,
|
|
3174
|
+
11,
|
|
3175
|
+
90,
|
|
3176
|
+
19,
|
|
3177
|
+
153,
|
|
3178
|
+
218,
|
|
3179
|
+
255,
|
|
3180
|
+
16,
|
|
3181
|
+
132,
|
|
3182
|
+
4,
|
|
3183
|
+
142,
|
|
3184
|
+
123,
|
|
3185
|
+
216,
|
|
3186
|
+
219,
|
|
3187
|
+
233,
|
|
3188
|
+
248,
|
|
3189
|
+
89
|
|
3190
|
+
]
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
},
|
|
3194
|
+
{
|
|
3195
|
+
name: "to_token_account",
|
|
3196
|
+
writable: true,
|
|
3197
|
+
optional: true,
|
|
3198
|
+
pda: {
|
|
3199
|
+
seeds: [
|
|
3200
|
+
{
|
|
3201
|
+
kind: "account",
|
|
3202
|
+
path: "att_recipient"
|
|
3203
|
+
},
|
|
3204
|
+
{
|
|
3205
|
+
kind: "const",
|
|
3206
|
+
value: [
|
|
3207
|
+
6,
|
|
3208
|
+
221,
|
|
3209
|
+
246,
|
|
3210
|
+
225,
|
|
3211
|
+
215,
|
|
3212
|
+
101,
|
|
3213
|
+
161,
|
|
3214
|
+
147,
|
|
3215
|
+
217,
|
|
3216
|
+
203,
|
|
3217
|
+
225,
|
|
3218
|
+
70,
|
|
3219
|
+
206,
|
|
3220
|
+
235,
|
|
3221
|
+
121,
|
|
3222
|
+
172,
|
|
3223
|
+
28,
|
|
3224
|
+
180,
|
|
3225
|
+
133,
|
|
3226
|
+
237,
|
|
3227
|
+
95,
|
|
3228
|
+
91,
|
|
3229
|
+
55,
|
|
3230
|
+
145,
|
|
3231
|
+
58,
|
|
3232
|
+
140,
|
|
3233
|
+
245,
|
|
3234
|
+
133,
|
|
3235
|
+
126,
|
|
3236
|
+
255,
|
|
3237
|
+
0,
|
|
3238
|
+
169
|
|
3239
|
+
]
|
|
3240
|
+
},
|
|
3241
|
+
{
|
|
3242
|
+
kind: "account",
|
|
3243
|
+
path: "mint"
|
|
3244
|
+
}
|
|
3245
|
+
],
|
|
3246
|
+
program: {
|
|
3247
|
+
kind: "const",
|
|
3248
|
+
value: [
|
|
3249
|
+
140,
|
|
3250
|
+
151,
|
|
3251
|
+
37,
|
|
3252
|
+
143,
|
|
3253
|
+
78,
|
|
3254
|
+
36,
|
|
3255
|
+
137,
|
|
3256
|
+
241,
|
|
3257
|
+
187,
|
|
3258
|
+
61,
|
|
3259
|
+
16,
|
|
3260
|
+
41,
|
|
3261
|
+
20,
|
|
3262
|
+
142,
|
|
3263
|
+
13,
|
|
3264
|
+
131,
|
|
3265
|
+
11,
|
|
3266
|
+
90,
|
|
3267
|
+
19,
|
|
3268
|
+
153,
|
|
3269
|
+
218,
|
|
3270
|
+
255,
|
|
3271
|
+
16,
|
|
3272
|
+
132,
|
|
3273
|
+
4,
|
|
3274
|
+
142,
|
|
3275
|
+
123,
|
|
3276
|
+
216,
|
|
3277
|
+
219,
|
|
3278
|
+
233,
|
|
3279
|
+
248,
|
|
3280
|
+
89
|
|
3281
|
+
]
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
},
|
|
3285
|
+
{
|
|
3286
|
+
name: "mint",
|
|
3287
|
+
optional: true
|
|
3288
|
+
},
|
|
3289
|
+
{
|
|
3290
|
+
name: "token_program",
|
|
3291
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
3292
|
+
},
|
|
3293
|
+
{
|
|
3294
|
+
name: "associated_token_program",
|
|
3295
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
2711
3296
|
}
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
3297
|
+
],
|
|
3298
|
+
args: [
|
|
3299
|
+
{
|
|
3300
|
+
name: "_re_id",
|
|
3301
|
+
type: {
|
|
3302
|
+
array: [
|
|
3303
|
+
"u8",
|
|
3304
|
+
32
|
|
3305
|
+
]
|
|
3306
|
+
}
|
|
3307
|
+
},
|
|
3308
|
+
{
|
|
3309
|
+
name: "_att",
|
|
3310
|
+
type: {
|
|
3311
|
+
option: {
|
|
3312
|
+
defined: {
|
|
3313
|
+
name: "Attestation"
|
|
3314
|
+
}
|
|
3315
|
+
}
|
|
3316
|
+
}
|
|
2715
3317
|
}
|
|
2716
|
-
|
|
2717
|
-
|
|
3318
|
+
]
|
|
3319
|
+
},
|
|
3320
|
+
{
|
|
3321
|
+
name: "re_record_data_init",
|
|
3322
|
+
discriminator: [
|
|
3323
|
+
211,
|
|
3324
|
+
91,
|
|
3325
|
+
95,
|
|
3326
|
+
249,
|
|
3327
|
+
111,
|
|
3328
|
+
81,
|
|
3329
|
+
103,
|
|
3330
|
+
124
|
|
3331
|
+
],
|
|
3332
|
+
accounts: [
|
|
3333
|
+
{
|
|
3334
|
+
name: "re_record_data",
|
|
3335
|
+
writable: true
|
|
3336
|
+
},
|
|
3337
|
+
{
|
|
3338
|
+
name: "sender",
|
|
3339
|
+
writable: true,
|
|
3340
|
+
signer: true
|
|
3341
|
+
},
|
|
3342
|
+
{
|
|
3343
|
+
name: "system_program",
|
|
3344
|
+
address: "11111111111111111111111111111111"
|
|
2718
3345
|
}
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
3346
|
+
],
|
|
3347
|
+
args: []
|
|
3348
|
+
},
|
|
3349
|
+
{
|
|
3350
|
+
name: "re_send",
|
|
3351
|
+
discriminator: [
|
|
3352
|
+
31,
|
|
3353
|
+
123,
|
|
3354
|
+
130,
|
|
3355
|
+
212,
|
|
3356
|
+
113,
|
|
3357
|
+
174,
|
|
3358
|
+
167,
|
|
3359
|
+
63
|
|
3360
|
+
],
|
|
3361
|
+
accounts: [
|
|
3362
|
+
{
|
|
3363
|
+
name: "state",
|
|
3364
|
+
writable: true,
|
|
3365
|
+
pda: {
|
|
3366
|
+
seeds: [
|
|
3367
|
+
{
|
|
3368
|
+
kind: "const",
|
|
3369
|
+
value: [
|
|
3370
|
+
114,
|
|
3371
|
+
101,
|
|
3372
|
+
100,
|
|
3373
|
+
95,
|
|
3374
|
+
101,
|
|
3375
|
+
110,
|
|
3376
|
+
118,
|
|
3377
|
+
101,
|
|
3378
|
+
108,
|
|
3379
|
+
111,
|
|
3380
|
+
112,
|
|
3381
|
+
101
|
|
3382
|
+
]
|
|
3383
|
+
}
|
|
3384
|
+
]
|
|
3385
|
+
}
|
|
3386
|
+
},
|
|
3387
|
+
{
|
|
3388
|
+
name: "re_record",
|
|
3389
|
+
writable: true,
|
|
3390
|
+
pda: {
|
|
3391
|
+
seeds: [
|
|
3392
|
+
{
|
|
3393
|
+
kind: "const",
|
|
3394
|
+
value: [
|
|
3395
|
+
114,
|
|
3396
|
+
101,
|
|
3397
|
+
95,
|
|
3398
|
+
114,
|
|
3399
|
+
101,
|
|
3400
|
+
99,
|
|
3401
|
+
111,
|
|
3402
|
+
114,
|
|
3403
|
+
100
|
|
3404
|
+
]
|
|
3405
|
+
},
|
|
3406
|
+
{
|
|
3407
|
+
kind: "arg",
|
|
3408
|
+
path: "re_id"
|
|
3409
|
+
}
|
|
3410
|
+
]
|
|
3411
|
+
}
|
|
3412
|
+
},
|
|
3413
|
+
{
|
|
3414
|
+
name: "re_record_data",
|
|
3415
|
+
writable: true
|
|
3416
|
+
},
|
|
3417
|
+
{
|
|
3418
|
+
name: "sender",
|
|
3419
|
+
writable: true,
|
|
3420
|
+
signer: true
|
|
3421
|
+
},
|
|
3422
|
+
{
|
|
3423
|
+
name: "system_program",
|
|
3424
|
+
address: "11111111111111111111111111111111"
|
|
3425
|
+
},
|
|
3426
|
+
{
|
|
3427
|
+
name: "from_token_account",
|
|
3428
|
+
writable: true,
|
|
3429
|
+
optional: true,
|
|
3430
|
+
pda: {
|
|
3431
|
+
seeds: [
|
|
3432
|
+
{
|
|
3433
|
+
kind: "account",
|
|
3434
|
+
path: "sender"
|
|
3435
|
+
},
|
|
3436
|
+
{
|
|
3437
|
+
kind: "const",
|
|
3438
|
+
value: [
|
|
3439
|
+
6,
|
|
3440
|
+
221,
|
|
3441
|
+
246,
|
|
3442
|
+
225,
|
|
3443
|
+
215,
|
|
3444
|
+
101,
|
|
3445
|
+
161,
|
|
3446
|
+
147,
|
|
3447
|
+
217,
|
|
3448
|
+
203,
|
|
3449
|
+
225,
|
|
3450
|
+
70,
|
|
3451
|
+
206,
|
|
3452
|
+
235,
|
|
3453
|
+
121,
|
|
3454
|
+
172,
|
|
3455
|
+
28,
|
|
3456
|
+
180,
|
|
3457
|
+
133,
|
|
3458
|
+
237,
|
|
3459
|
+
95,
|
|
3460
|
+
91,
|
|
3461
|
+
55,
|
|
3462
|
+
145,
|
|
3463
|
+
58,
|
|
3464
|
+
140,
|
|
3465
|
+
245,
|
|
3466
|
+
133,
|
|
3467
|
+
126,
|
|
3468
|
+
255,
|
|
3469
|
+
0,
|
|
3470
|
+
169
|
|
3471
|
+
]
|
|
3472
|
+
},
|
|
3473
|
+
{
|
|
3474
|
+
kind: "account",
|
|
3475
|
+
path: "mint"
|
|
3476
|
+
}
|
|
3477
|
+
],
|
|
3478
|
+
program: {
|
|
3479
|
+
kind: "const",
|
|
3480
|
+
value: [
|
|
3481
|
+
140,
|
|
3482
|
+
151,
|
|
3483
|
+
37,
|
|
3484
|
+
143,
|
|
3485
|
+
78,
|
|
3486
|
+
36,
|
|
3487
|
+
137,
|
|
3488
|
+
241,
|
|
3489
|
+
187,
|
|
3490
|
+
61,
|
|
3491
|
+
16,
|
|
3492
|
+
41,
|
|
3493
|
+
20,
|
|
3494
|
+
142,
|
|
3495
|
+
13,
|
|
3496
|
+
131,
|
|
3497
|
+
11,
|
|
3498
|
+
90,
|
|
3499
|
+
19,
|
|
3500
|
+
153,
|
|
3501
|
+
218,
|
|
3502
|
+
255,
|
|
3503
|
+
16,
|
|
3504
|
+
132,
|
|
3505
|
+
4,
|
|
3506
|
+
142,
|
|
3507
|
+
123,
|
|
3508
|
+
216,
|
|
3509
|
+
219,
|
|
3510
|
+
233,
|
|
3511
|
+
248,
|
|
3512
|
+
89
|
|
3513
|
+
]
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
},
|
|
3517
|
+
{
|
|
3518
|
+
name: "to_token_account",
|
|
3519
|
+
writable: true,
|
|
3520
|
+
optional: true,
|
|
3521
|
+
pda: {
|
|
3522
|
+
seeds: [
|
|
3523
|
+
{
|
|
3524
|
+
kind: "account",
|
|
3525
|
+
path: "state"
|
|
3526
|
+
},
|
|
3527
|
+
{
|
|
3528
|
+
kind: "const",
|
|
3529
|
+
value: [
|
|
3530
|
+
6,
|
|
3531
|
+
221,
|
|
3532
|
+
246,
|
|
3533
|
+
225,
|
|
3534
|
+
215,
|
|
3535
|
+
101,
|
|
3536
|
+
161,
|
|
3537
|
+
147,
|
|
3538
|
+
217,
|
|
3539
|
+
203,
|
|
3540
|
+
225,
|
|
3541
|
+
70,
|
|
3542
|
+
206,
|
|
3543
|
+
235,
|
|
3544
|
+
121,
|
|
3545
|
+
172,
|
|
3546
|
+
28,
|
|
3547
|
+
180,
|
|
3548
|
+
133,
|
|
3549
|
+
237,
|
|
3550
|
+
95,
|
|
3551
|
+
91,
|
|
3552
|
+
55,
|
|
3553
|
+
145,
|
|
3554
|
+
58,
|
|
3555
|
+
140,
|
|
3556
|
+
245,
|
|
3557
|
+
133,
|
|
3558
|
+
126,
|
|
3559
|
+
255,
|
|
3560
|
+
0,
|
|
3561
|
+
169
|
|
3562
|
+
]
|
|
3563
|
+
},
|
|
3564
|
+
{
|
|
3565
|
+
kind: "account",
|
|
3566
|
+
path: "mint"
|
|
3567
|
+
}
|
|
3568
|
+
],
|
|
3569
|
+
program: {
|
|
3570
|
+
kind: "const",
|
|
3571
|
+
value: [
|
|
3572
|
+
140,
|
|
3573
|
+
151,
|
|
3574
|
+
37,
|
|
3575
|
+
143,
|
|
3576
|
+
78,
|
|
3577
|
+
36,
|
|
3578
|
+
137,
|
|
3579
|
+
241,
|
|
3580
|
+
187,
|
|
3581
|
+
61,
|
|
3582
|
+
16,
|
|
3583
|
+
41,
|
|
3584
|
+
20,
|
|
3585
|
+
142,
|
|
3586
|
+
13,
|
|
3587
|
+
131,
|
|
3588
|
+
11,
|
|
3589
|
+
90,
|
|
3590
|
+
19,
|
|
3591
|
+
153,
|
|
3592
|
+
218,
|
|
3593
|
+
255,
|
|
3594
|
+
16,
|
|
3595
|
+
132,
|
|
3596
|
+
4,
|
|
3597
|
+
142,
|
|
3598
|
+
123,
|
|
3599
|
+
216,
|
|
3600
|
+
219,
|
|
3601
|
+
233,
|
|
3602
|
+
248,
|
|
3603
|
+
89
|
|
3604
|
+
]
|
|
3605
|
+
}
|
|
3606
|
+
}
|
|
3607
|
+
},
|
|
3608
|
+
{
|
|
3609
|
+
name: "mint",
|
|
3610
|
+
optional: true
|
|
3611
|
+
},
|
|
3612
|
+
{
|
|
3613
|
+
name: "token_program",
|
|
3614
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
3615
|
+
},
|
|
3616
|
+
{
|
|
3617
|
+
name: "associated_token_program",
|
|
3618
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3619
|
+
}
|
|
3620
|
+
],
|
|
3621
|
+
args: [
|
|
3622
|
+
{
|
|
3623
|
+
name: "re_id",
|
|
3624
|
+
type: {
|
|
3625
|
+
array: [
|
|
3626
|
+
"u8",
|
|
3627
|
+
32
|
|
3628
|
+
]
|
|
3629
|
+
}
|
|
3630
|
+
},
|
|
3631
|
+
{
|
|
3632
|
+
name: "token",
|
|
3633
|
+
type: {
|
|
3634
|
+
defined: {
|
|
3635
|
+
name: "TipToken"
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
name: "send_param",
|
|
3641
|
+
type: {
|
|
3642
|
+
defined: {
|
|
3643
|
+
name: "RESendParam"
|
|
3644
|
+
}
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
]
|
|
3648
|
+
},
|
|
3649
|
+
{
|
|
3650
|
+
name: "re_sender_withdraw",
|
|
3651
|
+
discriminator: [
|
|
3652
|
+
231,
|
|
3653
|
+
140,
|
|
3654
|
+
27,
|
|
3655
|
+
36,
|
|
3656
|
+
175,
|
|
3657
|
+
206,
|
|
3658
|
+
105,
|
|
3659
|
+
68
|
|
3660
|
+
],
|
|
3661
|
+
accounts: [
|
|
3662
|
+
{
|
|
3663
|
+
name: "state",
|
|
3664
|
+
writable: true
|
|
3665
|
+
},
|
|
3666
|
+
{
|
|
3667
|
+
name: "re_record",
|
|
3668
|
+
writable: true,
|
|
3669
|
+
pda: {
|
|
3670
|
+
seeds: [
|
|
3671
|
+
{
|
|
3672
|
+
kind: "const",
|
|
3673
|
+
value: [
|
|
3674
|
+
114,
|
|
3675
|
+
101,
|
|
3676
|
+
95,
|
|
3677
|
+
114,
|
|
3678
|
+
101,
|
|
3679
|
+
99,
|
|
3680
|
+
111,
|
|
3681
|
+
114,
|
|
3682
|
+
100
|
|
3683
|
+
]
|
|
3684
|
+
},
|
|
3685
|
+
{
|
|
3686
|
+
kind: "arg",
|
|
3687
|
+
path: "re_id"
|
|
3688
|
+
}
|
|
3689
|
+
]
|
|
3690
|
+
}
|
|
3691
|
+
},
|
|
3692
|
+
{
|
|
3693
|
+
name: "re_sender",
|
|
3694
|
+
writable: true,
|
|
3695
|
+
signer: true,
|
|
3696
|
+
relations: [
|
|
3697
|
+
"re_record"
|
|
3698
|
+
]
|
|
3699
|
+
},
|
|
3700
|
+
{
|
|
3701
|
+
name: "system_program",
|
|
3702
|
+
address: "11111111111111111111111111111111"
|
|
3703
|
+
},
|
|
3704
|
+
{
|
|
3705
|
+
name: "from_token_account",
|
|
3706
|
+
writable: true,
|
|
3707
|
+
optional: true,
|
|
3708
|
+
pda: {
|
|
3709
|
+
seeds: [
|
|
3710
|
+
{
|
|
3711
|
+
kind: "account",
|
|
3712
|
+
path: "state"
|
|
3713
|
+
},
|
|
3714
|
+
{
|
|
3715
|
+
kind: "const",
|
|
3716
|
+
value: [
|
|
3717
|
+
6,
|
|
3718
|
+
221,
|
|
3719
|
+
246,
|
|
3720
|
+
225,
|
|
3721
|
+
215,
|
|
3722
|
+
101,
|
|
3723
|
+
161,
|
|
3724
|
+
147,
|
|
3725
|
+
217,
|
|
3726
|
+
203,
|
|
3727
|
+
225,
|
|
3728
|
+
70,
|
|
3729
|
+
206,
|
|
3730
|
+
235,
|
|
3731
|
+
121,
|
|
3732
|
+
172,
|
|
3733
|
+
28,
|
|
3734
|
+
180,
|
|
3735
|
+
133,
|
|
3736
|
+
237,
|
|
3737
|
+
95,
|
|
3738
|
+
91,
|
|
3739
|
+
55,
|
|
3740
|
+
145,
|
|
3741
|
+
58,
|
|
3742
|
+
140,
|
|
3743
|
+
245,
|
|
3744
|
+
133,
|
|
3745
|
+
126,
|
|
3746
|
+
255,
|
|
3747
|
+
0,
|
|
3748
|
+
169
|
|
3749
|
+
]
|
|
3750
|
+
},
|
|
3751
|
+
{
|
|
3752
|
+
kind: "account",
|
|
3753
|
+
path: "mint"
|
|
3754
|
+
}
|
|
3755
|
+
],
|
|
3756
|
+
program: {
|
|
3757
|
+
kind: "const",
|
|
3758
|
+
value: [
|
|
3759
|
+
140,
|
|
3760
|
+
151,
|
|
3761
|
+
37,
|
|
3762
|
+
143,
|
|
3763
|
+
78,
|
|
3764
|
+
36,
|
|
3765
|
+
137,
|
|
3766
|
+
241,
|
|
3767
|
+
187,
|
|
3768
|
+
61,
|
|
3769
|
+
16,
|
|
3770
|
+
41,
|
|
3771
|
+
20,
|
|
3772
|
+
142,
|
|
3773
|
+
13,
|
|
3774
|
+
131,
|
|
3775
|
+
11,
|
|
3776
|
+
90,
|
|
3777
|
+
19,
|
|
3778
|
+
153,
|
|
3779
|
+
218,
|
|
3780
|
+
255,
|
|
3781
|
+
16,
|
|
3782
|
+
132,
|
|
3783
|
+
4,
|
|
3784
|
+
142,
|
|
3785
|
+
123,
|
|
3786
|
+
216,
|
|
3787
|
+
219,
|
|
3788
|
+
233,
|
|
3789
|
+
248,
|
|
3790
|
+
89
|
|
3791
|
+
]
|
|
3792
|
+
}
|
|
3793
|
+
}
|
|
3794
|
+
},
|
|
3795
|
+
{
|
|
3796
|
+
name: "to_token_account",
|
|
3797
|
+
writable: true,
|
|
3798
|
+
optional: true,
|
|
3799
|
+
pda: {
|
|
3800
|
+
seeds: [
|
|
3801
|
+
{
|
|
3802
|
+
kind: "account",
|
|
3803
|
+
path: "re_sender"
|
|
3804
|
+
},
|
|
3805
|
+
{
|
|
3806
|
+
kind: "const",
|
|
3807
|
+
value: [
|
|
3808
|
+
6,
|
|
3809
|
+
221,
|
|
3810
|
+
246,
|
|
3811
|
+
225,
|
|
3812
|
+
215,
|
|
3813
|
+
101,
|
|
3814
|
+
161,
|
|
3815
|
+
147,
|
|
3816
|
+
217,
|
|
3817
|
+
203,
|
|
3818
|
+
225,
|
|
3819
|
+
70,
|
|
3820
|
+
206,
|
|
3821
|
+
235,
|
|
3822
|
+
121,
|
|
3823
|
+
172,
|
|
3824
|
+
28,
|
|
3825
|
+
180,
|
|
3826
|
+
133,
|
|
3827
|
+
237,
|
|
3828
|
+
95,
|
|
3829
|
+
91,
|
|
3830
|
+
55,
|
|
3831
|
+
145,
|
|
3832
|
+
58,
|
|
3833
|
+
140,
|
|
3834
|
+
245,
|
|
3835
|
+
133,
|
|
3836
|
+
126,
|
|
3837
|
+
255,
|
|
3838
|
+
0,
|
|
3839
|
+
169
|
|
3840
|
+
]
|
|
3841
|
+
},
|
|
3842
|
+
{
|
|
3843
|
+
kind: "account",
|
|
3844
|
+
path: "mint"
|
|
3845
|
+
}
|
|
3846
|
+
],
|
|
3847
|
+
program: {
|
|
3848
|
+
kind: "const",
|
|
3849
|
+
value: [
|
|
3850
|
+
140,
|
|
3851
|
+
151,
|
|
3852
|
+
37,
|
|
3853
|
+
143,
|
|
3854
|
+
78,
|
|
3855
|
+
36,
|
|
3856
|
+
137,
|
|
3857
|
+
241,
|
|
3858
|
+
187,
|
|
3859
|
+
61,
|
|
3860
|
+
16,
|
|
3861
|
+
41,
|
|
3862
|
+
20,
|
|
3863
|
+
142,
|
|
3864
|
+
13,
|
|
3865
|
+
131,
|
|
3866
|
+
11,
|
|
3867
|
+
90,
|
|
3868
|
+
19,
|
|
3869
|
+
153,
|
|
3870
|
+
218,
|
|
3871
|
+
255,
|
|
3872
|
+
16,
|
|
3873
|
+
132,
|
|
3874
|
+
4,
|
|
3875
|
+
142,
|
|
3876
|
+
123,
|
|
3877
|
+
216,
|
|
3878
|
+
219,
|
|
3879
|
+
233,
|
|
3880
|
+
248,
|
|
3881
|
+
89
|
|
3882
|
+
]
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
},
|
|
3886
|
+
{
|
|
3887
|
+
name: "mint",
|
|
3888
|
+
optional: true
|
|
3889
|
+
},
|
|
3890
|
+
{
|
|
3891
|
+
name: "token_program",
|
|
3892
|
+
address: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
|
|
3893
|
+
},
|
|
3894
|
+
{
|
|
3895
|
+
name: "associated_token_program",
|
|
3896
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3897
|
+
}
|
|
3898
|
+
],
|
|
3899
|
+
args: [
|
|
3900
|
+
{
|
|
3901
|
+
name: "_re_id",
|
|
3902
|
+
type: {
|
|
3903
|
+
array: [
|
|
3904
|
+
"u8",
|
|
3905
|
+
32
|
|
3906
|
+
]
|
|
3907
|
+
}
|
|
3908
|
+
}
|
|
3909
|
+
]
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
name: "set_claim_fee",
|
|
3913
|
+
discriminator: [
|
|
3914
|
+
124,
|
|
3915
|
+
3,
|
|
3916
|
+
184,
|
|
3917
|
+
17,
|
|
3918
|
+
133,
|
|
3919
|
+
67,
|
|
3920
|
+
255,
|
|
3921
|
+
50
|
|
3922
|
+
],
|
|
3923
|
+
accounts: [
|
|
3924
|
+
{
|
|
3925
|
+
name: "state",
|
|
3926
|
+
writable: true,
|
|
3927
|
+
pda: {
|
|
3928
|
+
seeds: [
|
|
3929
|
+
{
|
|
3930
|
+
kind: "const",
|
|
3931
|
+
value: [
|
|
3932
|
+
114,
|
|
3933
|
+
101,
|
|
3934
|
+
100,
|
|
3935
|
+
95,
|
|
3936
|
+
101,
|
|
3937
|
+
110,
|
|
3938
|
+
118,
|
|
3939
|
+
101,
|
|
3940
|
+
108,
|
|
3941
|
+
111,
|
|
3942
|
+
112,
|
|
3943
|
+
101
|
|
3944
|
+
]
|
|
3945
|
+
}
|
|
3946
|
+
]
|
|
3947
|
+
}
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
name: "owner",
|
|
3951
|
+
writable: true,
|
|
3952
|
+
signer: true,
|
|
3953
|
+
relations: [
|
|
3954
|
+
"state"
|
|
3955
|
+
]
|
|
3956
|
+
},
|
|
3957
|
+
{
|
|
3958
|
+
name: "system_program",
|
|
3959
|
+
address: "11111111111111111111111111111111"
|
|
3960
|
+
}
|
|
3961
|
+
],
|
|
3962
|
+
args: [
|
|
3963
|
+
{
|
|
3964
|
+
name: "claim_fee",
|
|
3965
|
+
type: "u64"
|
|
3966
|
+
}
|
|
3967
|
+
]
|
|
3968
|
+
},
|
|
3969
|
+
{
|
|
3970
|
+
name: "set_fee_recipient",
|
|
3971
|
+
discriminator: [
|
|
3972
|
+
227,
|
|
3973
|
+
18,
|
|
3974
|
+
215,
|
|
3975
|
+
42,
|
|
3976
|
+
237,
|
|
3977
|
+
246,
|
|
3978
|
+
151,
|
|
3979
|
+
66
|
|
3980
|
+
],
|
|
3981
|
+
accounts: [
|
|
3982
|
+
{
|
|
3983
|
+
name: "state",
|
|
3984
|
+
writable: true,
|
|
3985
|
+
pda: {
|
|
3986
|
+
seeds: [
|
|
3987
|
+
{
|
|
3988
|
+
kind: "const",
|
|
3989
|
+
value: [
|
|
3990
|
+
114,
|
|
3991
|
+
101,
|
|
3992
|
+
100,
|
|
3993
|
+
95,
|
|
3994
|
+
101,
|
|
3995
|
+
110,
|
|
3996
|
+
118,
|
|
3997
|
+
101,
|
|
3998
|
+
108,
|
|
3999
|
+
111,
|
|
4000
|
+
112,
|
|
4001
|
+
101
|
|
4002
|
+
]
|
|
4003
|
+
}
|
|
4004
|
+
]
|
|
4005
|
+
}
|
|
4006
|
+
},
|
|
4007
|
+
{
|
|
4008
|
+
name: "owner",
|
|
4009
|
+
writable: true,
|
|
4010
|
+
signer: true,
|
|
4011
|
+
relations: [
|
|
4012
|
+
"state"
|
|
4013
|
+
]
|
|
4014
|
+
},
|
|
4015
|
+
{
|
|
4016
|
+
name: "system_program",
|
|
4017
|
+
address: "11111111111111111111111111111111"
|
|
4018
|
+
}
|
|
4019
|
+
],
|
|
4020
|
+
args: [
|
|
4021
|
+
{
|
|
4022
|
+
name: "fee_recipient",
|
|
4023
|
+
type: "pubkey"
|
|
4024
|
+
}
|
|
4025
|
+
]
|
|
4026
|
+
},
|
|
4027
|
+
{
|
|
4028
|
+
name: "set_primus_zktls",
|
|
4029
|
+
discriminator: [
|
|
4030
|
+
248,
|
|
4031
|
+
182,
|
|
4032
|
+
45,
|
|
4033
|
+
229,
|
|
4034
|
+
46,
|
|
4035
|
+
5,
|
|
4036
|
+
95,
|
|
4037
|
+
71
|
|
4038
|
+
],
|
|
4039
|
+
accounts: [
|
|
4040
|
+
{
|
|
4041
|
+
name: "state",
|
|
4042
|
+
writable: true,
|
|
4043
|
+
pda: {
|
|
4044
|
+
seeds: [
|
|
4045
|
+
{
|
|
4046
|
+
kind: "const",
|
|
4047
|
+
value: [
|
|
4048
|
+
114,
|
|
4049
|
+
101,
|
|
4050
|
+
100,
|
|
4051
|
+
95,
|
|
4052
|
+
101,
|
|
4053
|
+
110,
|
|
4054
|
+
118,
|
|
4055
|
+
101,
|
|
4056
|
+
108,
|
|
4057
|
+
111,
|
|
4058
|
+
112,
|
|
4059
|
+
101
|
|
4060
|
+
]
|
|
4061
|
+
}
|
|
4062
|
+
]
|
|
4063
|
+
}
|
|
4064
|
+
},
|
|
4065
|
+
{
|
|
4066
|
+
name: "owner",
|
|
4067
|
+
writable: true,
|
|
4068
|
+
signer: true,
|
|
4069
|
+
relations: [
|
|
4070
|
+
"state"
|
|
4071
|
+
]
|
|
4072
|
+
},
|
|
4073
|
+
{
|
|
4074
|
+
name: "system_program",
|
|
4075
|
+
address: "11111111111111111111111111111111"
|
|
4076
|
+
}
|
|
4077
|
+
],
|
|
4078
|
+
args: [
|
|
4079
|
+
{
|
|
4080
|
+
name: "primus_zktls",
|
|
4081
|
+
type: "pubkey"
|
|
4082
|
+
}
|
|
4083
|
+
]
|
|
4084
|
+
},
|
|
4085
|
+
{
|
|
4086
|
+
name: "set_withdraw_delay",
|
|
4087
|
+
discriminator: [
|
|
4088
|
+
184,
|
|
4089
|
+
89,
|
|
4090
|
+
21,
|
|
4091
|
+
192,
|
|
4092
|
+
34,
|
|
4093
|
+
24,
|
|
4094
|
+
3,
|
|
4095
|
+
142
|
|
4096
|
+
],
|
|
4097
|
+
accounts: [
|
|
4098
|
+
{
|
|
4099
|
+
name: "state",
|
|
4100
|
+
writable: true,
|
|
4101
|
+
pda: {
|
|
4102
|
+
seeds: [
|
|
4103
|
+
{
|
|
4104
|
+
kind: "const",
|
|
4105
|
+
value: [
|
|
4106
|
+
114,
|
|
4107
|
+
101,
|
|
4108
|
+
100,
|
|
4109
|
+
95,
|
|
4110
|
+
101,
|
|
4111
|
+
110,
|
|
4112
|
+
118,
|
|
4113
|
+
101,
|
|
4114
|
+
108,
|
|
4115
|
+
111,
|
|
4116
|
+
112,
|
|
4117
|
+
101
|
|
4118
|
+
]
|
|
4119
|
+
}
|
|
4120
|
+
]
|
|
4121
|
+
}
|
|
4122
|
+
},
|
|
4123
|
+
{
|
|
4124
|
+
name: "owner",
|
|
4125
|
+
writable: true,
|
|
4126
|
+
signer: true,
|
|
4127
|
+
relations: [
|
|
4128
|
+
"state"
|
|
4129
|
+
]
|
|
4130
|
+
},
|
|
4131
|
+
{
|
|
4132
|
+
name: "system_program",
|
|
4133
|
+
address: "11111111111111111111111111111111"
|
|
4134
|
+
}
|
|
4135
|
+
],
|
|
4136
|
+
args: [
|
|
4137
|
+
{
|
|
4138
|
+
name: "withdraw_delay",
|
|
4139
|
+
type: "u64"
|
|
4140
|
+
}
|
|
4141
|
+
]
|
|
4142
|
+
}
|
|
4143
|
+
],
|
|
4144
|
+
accounts: [
|
|
4145
|
+
{
|
|
4146
|
+
name: "DataBuffer",
|
|
4147
|
+
discriminator: [
|
|
4148
|
+
235,
|
|
4149
|
+
220,
|
|
4150
|
+
51,
|
|
4151
|
+
248,
|
|
4152
|
+
56,
|
|
4153
|
+
77,
|
|
4154
|
+
241,
|
|
4155
|
+
89
|
|
4156
|
+
]
|
|
4157
|
+
},
|
|
4158
|
+
{
|
|
4159
|
+
name: "PrimusState",
|
|
4160
|
+
discriminator: [
|
|
4161
|
+
200,
|
|
4162
|
+
136,
|
|
4163
|
+
35,
|
|
4164
|
+
84,
|
|
4165
|
+
173,
|
|
4166
|
+
237,
|
|
4167
|
+
163,
|
|
4168
|
+
179
|
|
4169
|
+
]
|
|
4170
|
+
},
|
|
4171
|
+
{
|
|
4172
|
+
name: "RERecord",
|
|
4173
|
+
discriminator: [
|
|
4174
|
+
242,
|
|
4175
|
+
171,
|
|
4176
|
+
141,
|
|
4177
|
+
17,
|
|
4178
|
+
123,
|
|
4179
|
+
107,
|
|
4180
|
+
153,
|
|
4181
|
+
15
|
|
4182
|
+
]
|
|
4183
|
+
},
|
|
4184
|
+
{
|
|
4185
|
+
name: "RERecordData",
|
|
4186
|
+
discriminator: [
|
|
4187
|
+
165,
|
|
4188
|
+
107,
|
|
4189
|
+
251,
|
|
4190
|
+
115,
|
|
4191
|
+
50,
|
|
4192
|
+
118,
|
|
4193
|
+
32,
|
|
4194
|
+
148
|
|
4195
|
+
]
|
|
4196
|
+
},
|
|
4197
|
+
{
|
|
4198
|
+
name: "RedEnvelopeState",
|
|
4199
|
+
discriminator: [
|
|
4200
|
+
89,
|
|
4201
|
+
134,
|
|
4202
|
+
184,
|
|
4203
|
+
61,
|
|
4204
|
+
201,
|
|
4205
|
+
123,
|
|
4206
|
+
226,
|
|
4207
|
+
180
|
|
4208
|
+
]
|
|
4209
|
+
}
|
|
4210
|
+
],
|
|
4211
|
+
events: [
|
|
4212
|
+
{
|
|
4213
|
+
name: "REClaimEvent",
|
|
4214
|
+
discriminator: [
|
|
4215
|
+
214,
|
|
4216
|
+
100,
|
|
4217
|
+
41,
|
|
4218
|
+
0,
|
|
4219
|
+
45,
|
|
4220
|
+
92,
|
|
4221
|
+
31,
|
|
4222
|
+
248
|
|
4223
|
+
]
|
|
4224
|
+
},
|
|
4225
|
+
{
|
|
4226
|
+
name: "RESWithdrawEvent",
|
|
4227
|
+
discriminator: [
|
|
4228
|
+
26,
|
|
4229
|
+
207,
|
|
4230
|
+
42,
|
|
4231
|
+
68,
|
|
4232
|
+
36,
|
|
4233
|
+
174,
|
|
4234
|
+
127,
|
|
4235
|
+
205
|
|
4236
|
+
]
|
|
4237
|
+
},
|
|
4238
|
+
{
|
|
4239
|
+
name: "RESendEvent",
|
|
4240
|
+
discriminator: [
|
|
4241
|
+
147,
|
|
4242
|
+
8,
|
|
4243
|
+
237,
|
|
4244
|
+
225,
|
|
4245
|
+
123,
|
|
4246
|
+
64,
|
|
4247
|
+
157,
|
|
4248
|
+
199
|
|
4249
|
+
]
|
|
4250
|
+
}
|
|
4251
|
+
],
|
|
4252
|
+
errors: [
|
|
4253
|
+
{
|
|
4254
|
+
code: 6e3,
|
|
4255
|
+
name: "InvalidZktlsProgram",
|
|
4256
|
+
msg: "Invalid Zktls Program"
|
|
4257
|
+
},
|
|
4258
|
+
{
|
|
4259
|
+
code: 6001,
|
|
4260
|
+
name: "InvalidTokenType",
|
|
4261
|
+
msg: "Invalid token type"
|
|
4262
|
+
},
|
|
4263
|
+
{
|
|
4264
|
+
code: 6002,
|
|
4265
|
+
name: "InvalidREType",
|
|
4266
|
+
msg: "Invalid red envelope type"
|
|
4267
|
+
},
|
|
4268
|
+
{
|
|
4269
|
+
code: 6003,
|
|
4270
|
+
name: "InvalidNumber",
|
|
4271
|
+
msg: "Invalid number"
|
|
4272
|
+
},
|
|
4273
|
+
{
|
|
4274
|
+
code: 6004,
|
|
4275
|
+
name: "InvalidEmptyRatio",
|
|
4276
|
+
msg: "Invalid empty ratio"
|
|
4277
|
+
},
|
|
4278
|
+
{
|
|
4279
|
+
code: 6005,
|
|
4280
|
+
name: "AmountTooLow",
|
|
4281
|
+
msg: "Amount too low"
|
|
4282
|
+
},
|
|
4283
|
+
{
|
|
4284
|
+
code: 6006,
|
|
4285
|
+
name: "WrongAmount",
|
|
4286
|
+
msg: "Wrong amount"
|
|
4287
|
+
},
|
|
4288
|
+
{
|
|
4289
|
+
code: 6007,
|
|
4290
|
+
name: "NoReId",
|
|
4291
|
+
msg: "Red envelope ID does not exist"
|
|
4292
|
+
},
|
|
4293
|
+
{
|
|
4294
|
+
code: 6008,
|
|
4295
|
+
name: "AllClaimed",
|
|
4296
|
+
msg: "All envelopes claimed"
|
|
4297
|
+
},
|
|
4298
|
+
{
|
|
4299
|
+
code: 6009,
|
|
4300
|
+
name: "UserIdEmpty",
|
|
4301
|
+
msg: "User ID empty"
|
|
4302
|
+
},
|
|
4303
|
+
{
|
|
4304
|
+
code: 6010,
|
|
4305
|
+
name: "InvalidUserAddress",
|
|
4306
|
+
msg: "Invalid User Address"
|
|
4307
|
+
},
|
|
4308
|
+
{
|
|
4309
|
+
code: 6011,
|
|
4310
|
+
name: "AlreadyClaimed",
|
|
4311
|
+
msg: "Already claimed"
|
|
4312
|
+
},
|
|
4313
|
+
{
|
|
4314
|
+
code: 6012,
|
|
4315
|
+
name: "AmountUnderflow",
|
|
4316
|
+
msg: "Amount underflow"
|
|
4317
|
+
},
|
|
4318
|
+
{
|
|
4319
|
+
code: 6013,
|
|
4320
|
+
name: "InvalidFeeRecipient",
|
|
4321
|
+
msg: "Invalid fee recipient"
|
|
4322
|
+
},
|
|
4323
|
+
{
|
|
4324
|
+
code: 6014,
|
|
4325
|
+
name: "InvalidStateAccount",
|
|
4326
|
+
msg: "Invalid state account"
|
|
4327
|
+
},
|
|
4328
|
+
{
|
|
4329
|
+
code: 6015,
|
|
4330
|
+
name: "RecipientIsZero",
|
|
4331
|
+
msg: "Recipient cannot be zero"
|
|
4332
|
+
},
|
|
4333
|
+
{
|
|
4334
|
+
code: 6016,
|
|
4335
|
+
name: "InvalidCheckType",
|
|
4336
|
+
msg: "Invalid checkType"
|
|
4337
|
+
},
|
|
4338
|
+
{
|
|
4339
|
+
code: 6017,
|
|
4340
|
+
name: "InvalidCheckParams",
|
|
4341
|
+
msg: "CheckParams decode failed"
|
|
4342
|
+
},
|
|
4343
|
+
{
|
|
4344
|
+
code: 6018,
|
|
4345
|
+
name: "NoFund",
|
|
4346
|
+
msg: "No fund"
|
|
4347
|
+
},
|
|
4348
|
+
{
|
|
4349
|
+
code: 6019,
|
|
4350
|
+
name: "NotOwner",
|
|
4351
|
+
msg: "Not owner"
|
|
4352
|
+
},
|
|
4353
|
+
{
|
|
4354
|
+
code: 6020,
|
|
4355
|
+
name: "NotExpired",
|
|
4356
|
+
msg: "Not expired"
|
|
4357
|
+
},
|
|
4358
|
+
{
|
|
4359
|
+
code: 6021,
|
|
4360
|
+
name: "UnsupportedTokenType",
|
|
4361
|
+
msg: "Unsupported Token Type"
|
|
4362
|
+
},
|
|
4363
|
+
{
|
|
4364
|
+
code: 6022,
|
|
4365
|
+
name: "InsufficientSOL",
|
|
4366
|
+
msg: "Insufficient SOL"
|
|
4367
|
+
},
|
|
4368
|
+
{
|
|
4369
|
+
code: 6023,
|
|
4370
|
+
name: "WrongTokenMint",
|
|
4371
|
+
msg: "Wrong token mint"
|
|
4372
|
+
},
|
|
4373
|
+
{
|
|
4374
|
+
code: 6024,
|
|
4375
|
+
name: "DeserializationFailed",
|
|
4376
|
+
msg: "Deserialization Failed"
|
|
4377
|
+
},
|
|
4378
|
+
{
|
|
4379
|
+
code: 6025,
|
|
4380
|
+
name: "JsonParseError",
|
|
4381
|
+
msg: "JSON Parse Error"
|
|
4382
|
+
},
|
|
4383
|
+
{
|
|
4384
|
+
code: 6026,
|
|
4385
|
+
name: "ResponseLengthError",
|
|
4386
|
+
msg: "response length error"
|
|
4387
|
+
},
|
|
4388
|
+
{
|
|
4389
|
+
code: 6027,
|
|
4390
|
+
name: "AttUrlError",
|
|
4391
|
+
msg: "att url error"
|
|
4392
|
+
},
|
|
4393
|
+
{
|
|
4394
|
+
code: 6028,
|
|
4395
|
+
name: "AttSuffixUrlError",
|
|
4396
|
+
msg: "att suffix url error"
|
|
4397
|
+
},
|
|
4398
|
+
{
|
|
4399
|
+
code: 6029,
|
|
4400
|
+
name: "JsonPathError",
|
|
4401
|
+
msg: "json path error"
|
|
4402
|
+
},
|
|
4403
|
+
{
|
|
4404
|
+
code: 6030,
|
|
4405
|
+
name: "UsernameKeyError",
|
|
4406
|
+
msg: "username key error"
|
|
4407
|
+
},
|
|
4408
|
+
{
|
|
4409
|
+
code: 6031,
|
|
4410
|
+
name: "FollowingError",
|
|
4411
|
+
msg: "following error"
|
|
4412
|
+
},
|
|
4413
|
+
{
|
|
4414
|
+
code: 6032,
|
|
4415
|
+
name: "FollowingNameError",
|
|
4416
|
+
msg: "following name error"
|
|
4417
|
+
},
|
|
4418
|
+
{
|
|
4419
|
+
code: 6033,
|
|
4420
|
+
name: "NameOpError",
|
|
4421
|
+
msg: "name op error"
|
|
4422
|
+
},
|
|
4423
|
+
{
|
|
4424
|
+
code: 6034,
|
|
4425
|
+
name: "AttConditionsError",
|
|
4426
|
+
msg: "att conditions error"
|
|
4427
|
+
},
|
|
4428
|
+
{
|
|
4429
|
+
code: 6035,
|
|
4430
|
+
name: "TooManyUrls",
|
|
4431
|
+
msg: "too many urls"
|
|
4432
|
+
},
|
|
4433
|
+
{
|
|
4434
|
+
code: 6036,
|
|
4435
|
+
name: "TooManyResponseresolve",
|
|
4436
|
+
msg: "too many responseResolve"
|
|
4437
|
+
},
|
|
4438
|
+
{
|
|
4439
|
+
code: 6037,
|
|
4440
|
+
name: "UserNameEmpty",
|
|
4441
|
+
msg: "user name empty"
|
|
4442
|
+
},
|
|
4443
|
+
{
|
|
4444
|
+
code: 6038,
|
|
4445
|
+
name: "SourceError",
|
|
4446
|
+
msg: "source error"
|
|
4447
|
+
},
|
|
4448
|
+
{
|
|
4449
|
+
code: 6039,
|
|
4450
|
+
name: "AccountResponseLengthError",
|
|
4451
|
+
msg: "account response length error"
|
|
4452
|
+
},
|
|
4453
|
+
{
|
|
4454
|
+
code: 6040,
|
|
4455
|
+
name: "TiktokAttUrlError",
|
|
4456
|
+
msg: "tiktok att url error"
|
|
4457
|
+
},
|
|
4458
|
+
{
|
|
4459
|
+
code: 6041,
|
|
4460
|
+
name: "TiktokJsonPathError",
|
|
4461
|
+
msg: "tiktok json path error"
|
|
4462
|
+
},
|
|
4463
|
+
{
|
|
4464
|
+
code: 6042,
|
|
4465
|
+
name: "XAttUrlError",
|
|
4466
|
+
msg: "x att url error"
|
|
4467
|
+
},
|
|
4468
|
+
{
|
|
4469
|
+
code: 6043,
|
|
4470
|
+
name: "XJsonPathError",
|
|
4471
|
+
msg: "x json path error"
|
|
4472
|
+
},
|
|
4473
|
+
{
|
|
4474
|
+
code: 6044,
|
|
4475
|
+
name: "GoogleAttUrlError",
|
|
4476
|
+
msg: "google att url error"
|
|
4477
|
+
},
|
|
4478
|
+
{
|
|
4479
|
+
code: 6045,
|
|
4480
|
+
name: "GoogleJsonPathError",
|
|
4481
|
+
msg: "google json path error"
|
|
4482
|
+
},
|
|
4483
|
+
{
|
|
4484
|
+
code: 6046,
|
|
4485
|
+
name: "XiaohongshuAttUrlError",
|
|
4486
|
+
msg: "xiaohongshu att url error"
|
|
4487
|
+
},
|
|
4488
|
+
{
|
|
4489
|
+
code: 6047,
|
|
4490
|
+
name: "XiaohongshuJsonPathError",
|
|
4491
|
+
msg: "xiaohongshu json path error"
|
|
4492
|
+
}
|
|
4493
|
+
],
|
|
4494
|
+
types: [
|
|
4495
|
+
{
|
|
4496
|
+
name: "AttNetworkRequest",
|
|
4497
|
+
type: {
|
|
4498
|
+
kind: "struct",
|
|
4499
|
+
fields: [
|
|
4500
|
+
{
|
|
4501
|
+
name: "url",
|
|
4502
|
+
type: "string"
|
|
4503
|
+
},
|
|
4504
|
+
{
|
|
4505
|
+
name: "header",
|
|
4506
|
+
type: "string"
|
|
4507
|
+
},
|
|
4508
|
+
{
|
|
4509
|
+
name: "method",
|
|
4510
|
+
type: "string"
|
|
4511
|
+
},
|
|
4512
|
+
{
|
|
4513
|
+
name: "body",
|
|
4514
|
+
type: "string"
|
|
4515
|
+
}
|
|
4516
|
+
]
|
|
4517
|
+
}
|
|
4518
|
+
},
|
|
4519
|
+
{
|
|
4520
|
+
name: "AttNetworkResponseResolve",
|
|
4521
|
+
type: {
|
|
4522
|
+
kind: "struct",
|
|
4523
|
+
fields: [
|
|
4524
|
+
{
|
|
4525
|
+
name: "key_name",
|
|
4526
|
+
type: "string"
|
|
4527
|
+
},
|
|
4528
|
+
{
|
|
4529
|
+
name: "parse_type",
|
|
4530
|
+
type: "string"
|
|
4531
|
+
},
|
|
4532
|
+
{
|
|
4533
|
+
name: "parse_path",
|
|
4534
|
+
type: "string"
|
|
4535
|
+
}
|
|
4536
|
+
]
|
|
4537
|
+
}
|
|
4538
|
+
},
|
|
4539
|
+
{
|
|
4540
|
+
name: "Attestation",
|
|
4541
|
+
type: {
|
|
4542
|
+
kind: "struct",
|
|
4543
|
+
fields: [
|
|
4544
|
+
{
|
|
4545
|
+
name: "recipient",
|
|
4546
|
+
type: {
|
|
4547
|
+
array: [
|
|
4548
|
+
"u8",
|
|
4549
|
+
32
|
|
4550
|
+
]
|
|
4551
|
+
}
|
|
4552
|
+
},
|
|
4553
|
+
{
|
|
4554
|
+
name: "request",
|
|
4555
|
+
type: {
|
|
4556
|
+
defined: {
|
|
4557
|
+
name: "AttNetworkRequest"
|
|
4558
|
+
}
|
|
4559
|
+
}
|
|
4560
|
+
},
|
|
4561
|
+
{
|
|
4562
|
+
name: "response_resolve",
|
|
4563
|
+
type: {
|
|
4564
|
+
vec: {
|
|
4565
|
+
defined: {
|
|
4566
|
+
name: "AttNetworkResponseResolve"
|
|
4567
|
+
}
|
|
4568
|
+
}
|
|
4569
|
+
}
|
|
4570
|
+
},
|
|
4571
|
+
{
|
|
4572
|
+
name: "data",
|
|
4573
|
+
type: "string"
|
|
4574
|
+
},
|
|
4575
|
+
{
|
|
4576
|
+
name: "att_conditions",
|
|
4577
|
+
type: "string"
|
|
4578
|
+
},
|
|
4579
|
+
{
|
|
4580
|
+
name: "timestamp",
|
|
4581
|
+
type: "u64"
|
|
4582
|
+
},
|
|
4583
|
+
{
|
|
4584
|
+
name: "addition_params",
|
|
4585
|
+
type: "string"
|
|
4586
|
+
},
|
|
4587
|
+
{
|
|
4588
|
+
name: "attestors",
|
|
4589
|
+
type: {
|
|
4590
|
+
vec: {
|
|
4591
|
+
defined: {
|
|
4592
|
+
name: "Attestor"
|
|
4593
|
+
}
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
},
|
|
4597
|
+
{
|
|
4598
|
+
name: "signatures",
|
|
4599
|
+
type: {
|
|
4600
|
+
vec: "bytes"
|
|
4601
|
+
}
|
|
4602
|
+
}
|
|
4603
|
+
]
|
|
4604
|
+
}
|
|
4605
|
+
},
|
|
4606
|
+
{
|
|
4607
|
+
name: "Attestor",
|
|
4608
|
+
type: {
|
|
4609
|
+
kind: "struct",
|
|
4610
|
+
fields: [
|
|
4611
|
+
{
|
|
4612
|
+
name: "attestor_addr",
|
|
4613
|
+
type: {
|
|
4614
|
+
array: [
|
|
4615
|
+
"u8",
|
|
4616
|
+
20
|
|
4617
|
+
]
|
|
4618
|
+
}
|
|
4619
|
+
},
|
|
4620
|
+
{
|
|
4621
|
+
name: "url",
|
|
4622
|
+
type: "string"
|
|
4623
|
+
}
|
|
4624
|
+
]
|
|
4625
|
+
}
|
|
4626
|
+
},
|
|
4627
|
+
{
|
|
4628
|
+
name: "CheckParams",
|
|
4629
|
+
type: {
|
|
4630
|
+
kind: "struct",
|
|
4631
|
+
fields: [
|
|
4632
|
+
{
|
|
4633
|
+
name: "check_type",
|
|
4634
|
+
type: "u32"
|
|
4635
|
+
},
|
|
4636
|
+
{
|
|
4637
|
+
name: "params",
|
|
4638
|
+
type: "string"
|
|
4639
|
+
}
|
|
4640
|
+
]
|
|
4641
|
+
}
|
|
4642
|
+
},
|
|
4643
|
+
{
|
|
4644
|
+
name: "DataBuffer",
|
|
4645
|
+
type: {
|
|
4646
|
+
kind: "struct",
|
|
4647
|
+
fields: [
|
|
4648
|
+
{
|
|
4649
|
+
name: "user",
|
|
4650
|
+
type: "pubkey"
|
|
4651
|
+
},
|
|
4652
|
+
{
|
|
4653
|
+
name: "length",
|
|
4654
|
+
type: "u32"
|
|
4655
|
+
},
|
|
4656
|
+
{
|
|
4657
|
+
name: "data",
|
|
4658
|
+
type: "bytes"
|
|
4659
|
+
}
|
|
4660
|
+
]
|
|
4661
|
+
}
|
|
4662
|
+
},
|
|
4663
|
+
{
|
|
4664
|
+
name: "PrimusState",
|
|
4665
|
+
type: {
|
|
4666
|
+
kind: "struct",
|
|
4667
|
+
fields: [
|
|
4668
|
+
{
|
|
4669
|
+
name: "owner",
|
|
4670
|
+
type: "pubkey"
|
|
4671
|
+
},
|
|
4672
|
+
{
|
|
4673
|
+
name: "attestors",
|
|
4674
|
+
type: {
|
|
4675
|
+
vec: {
|
|
4676
|
+
defined: {
|
|
4677
|
+
name: "Attestor"
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
}
|
|
4681
|
+
},
|
|
4682
|
+
{
|
|
4683
|
+
name: "bump",
|
|
4684
|
+
type: "u8"
|
|
4685
|
+
}
|
|
4686
|
+
]
|
|
4687
|
+
}
|
|
4688
|
+
},
|
|
4689
|
+
{
|
|
4690
|
+
name: "REClaimEvent",
|
|
4691
|
+
type: {
|
|
4692
|
+
kind: "struct",
|
|
4693
|
+
fields: [
|
|
4694
|
+
{
|
|
4695
|
+
name: "id",
|
|
4696
|
+
type: {
|
|
4697
|
+
array: [
|
|
4698
|
+
"u8",
|
|
4699
|
+
32
|
|
4700
|
+
]
|
|
4701
|
+
}
|
|
4702
|
+
},
|
|
4703
|
+
{
|
|
4704
|
+
name: "user",
|
|
4705
|
+
type: "pubkey"
|
|
4706
|
+
},
|
|
4707
|
+
{
|
|
4708
|
+
name: "user_id",
|
|
4709
|
+
type: "string"
|
|
4710
|
+
},
|
|
4711
|
+
{
|
|
4712
|
+
name: "amount",
|
|
4713
|
+
type: "u64"
|
|
4714
|
+
},
|
|
4715
|
+
{
|
|
4716
|
+
name: "index",
|
|
4717
|
+
type: "u32"
|
|
4718
|
+
},
|
|
4719
|
+
{
|
|
4720
|
+
name: "timestamp",
|
|
4721
|
+
type: "u64"
|
|
4722
|
+
},
|
|
4723
|
+
{
|
|
4724
|
+
name: "token_address",
|
|
4725
|
+
type: "pubkey"
|
|
4726
|
+
}
|
|
4727
|
+
]
|
|
4728
|
+
}
|
|
4729
|
+
},
|
|
4730
|
+
{
|
|
4731
|
+
name: "RERecord",
|
|
4732
|
+
type: {
|
|
4733
|
+
kind: "struct",
|
|
4734
|
+
fields: [
|
|
4735
|
+
{
|
|
4736
|
+
name: "id",
|
|
4737
|
+
docs: [
|
|
4738
|
+
"Red envelope ID"
|
|
4739
|
+
],
|
|
4740
|
+
type: {
|
|
4741
|
+
array: [
|
|
4742
|
+
"u8",
|
|
4743
|
+
32
|
|
4744
|
+
]
|
|
4745
|
+
}
|
|
4746
|
+
},
|
|
4747
|
+
{
|
|
4748
|
+
name: "token_type",
|
|
4749
|
+
docs: [
|
|
4750
|
+
"Token type (ERC20 / NATIVE)"
|
|
4751
|
+
],
|
|
4752
|
+
type: "u32"
|
|
4753
|
+
},
|
|
4754
|
+
{
|
|
4755
|
+
name: "re_type",
|
|
4756
|
+
docs: [
|
|
4757
|
+
"Red envelope type"
|
|
4758
|
+
],
|
|
4759
|
+
type: "u32"
|
|
4760
|
+
},
|
|
4761
|
+
{
|
|
4762
|
+
name: "number",
|
|
4763
|
+
docs: [
|
|
4764
|
+
"Number of recipients"
|
|
4765
|
+
],
|
|
4766
|
+
type: "u32"
|
|
4767
|
+
},
|
|
4768
|
+
{
|
|
4769
|
+
name: "remaining_number",
|
|
4770
|
+
docs: [
|
|
4771
|
+
"Remaining recipients"
|
|
4772
|
+
],
|
|
4773
|
+
type: "u32"
|
|
4774
|
+
},
|
|
4775
|
+
{
|
|
4776
|
+
name: "timestamp",
|
|
4777
|
+
docs: [
|
|
4778
|
+
"Timestamp sent"
|
|
4779
|
+
],
|
|
4780
|
+
type: "u64"
|
|
4781
|
+
},
|
|
4782
|
+
{
|
|
4783
|
+
name: "token_address",
|
|
4784
|
+
docs: [
|
|
4785
|
+
"Token address"
|
|
4786
|
+
],
|
|
4787
|
+
type: "pubkey"
|
|
4788
|
+
},
|
|
4789
|
+
{
|
|
4790
|
+
name: "re_sender",
|
|
4791
|
+
docs: [
|
|
4792
|
+
"Sender address"
|
|
4793
|
+
],
|
|
4794
|
+
type: "pubkey"
|
|
4795
|
+
},
|
|
4796
|
+
{
|
|
4797
|
+
name: "check_contract",
|
|
4798
|
+
docs: [
|
|
4799
|
+
"Eligibility check contract"
|
|
4800
|
+
],
|
|
4801
|
+
type: "pubkey"
|
|
4802
|
+
},
|
|
4803
|
+
{
|
|
4804
|
+
name: "amount",
|
|
4805
|
+
docs: [
|
|
4806
|
+
"Total amount"
|
|
4807
|
+
],
|
|
4808
|
+
type: "u64"
|
|
4809
|
+
},
|
|
4810
|
+
{
|
|
4811
|
+
name: "remaining_amount",
|
|
4812
|
+
docs: [
|
|
4813
|
+
"Remaining amount"
|
|
4814
|
+
],
|
|
4815
|
+
type: "u64"
|
|
4816
|
+
},
|
|
4817
|
+
{
|
|
4818
|
+
name: "check_params",
|
|
4819
|
+
docs: [
|
|
4820
|
+
"Eligibility check params"
|
|
4821
|
+
],
|
|
4822
|
+
type: {
|
|
4823
|
+
defined: {
|
|
4824
|
+
name: "CheckParams"
|
|
4825
|
+
}
|
|
4826
|
+
}
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
name: "empty_ratio",
|
|
4830
|
+
docs: [
|
|
4831
|
+
"Empty red envelope ratio, 0\u2013100"
|
|
4832
|
+
],
|
|
4833
|
+
type: "u8"
|
|
4834
|
+
},
|
|
4835
|
+
{
|
|
4836
|
+
name: "record_data",
|
|
4837
|
+
docs: [
|
|
4838
|
+
"RE Record account, refer to Account<RERecordData>"
|
|
4839
|
+
],
|
|
4840
|
+
type: "pubkey"
|
|
4841
|
+
}
|
|
4842
|
+
]
|
|
4843
|
+
}
|
|
4844
|
+
},
|
|
4845
|
+
{
|
|
4846
|
+
name: "RERecordData",
|
|
4847
|
+
type: {
|
|
4848
|
+
kind: "struct",
|
|
4849
|
+
fields: [
|
|
4850
|
+
{
|
|
4851
|
+
name: "id",
|
|
4852
|
+
docs: [
|
|
4853
|
+
"Red envelope ID"
|
|
4854
|
+
],
|
|
4855
|
+
type: {
|
|
4856
|
+
array: [
|
|
4857
|
+
"u8",
|
|
4858
|
+
32
|
|
4859
|
+
]
|
|
4860
|
+
}
|
|
4861
|
+
},
|
|
4862
|
+
{
|
|
4863
|
+
name: "amounts",
|
|
4864
|
+
docs: [
|
|
4865
|
+
"Red envelope amount array, containing 0 amounts."
|
|
4866
|
+
],
|
|
4867
|
+
type: {
|
|
4868
|
+
vec: "u64"
|
|
4869
|
+
}
|
|
4870
|
+
},
|
|
4871
|
+
{
|
|
4872
|
+
name: "re_claimed",
|
|
4873
|
+
type: {
|
|
4874
|
+
vec: {
|
|
4875
|
+
array: [
|
|
4876
|
+
"u8",
|
|
4877
|
+
8
|
|
4878
|
+
]
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
}
|
|
4882
|
+
]
|
|
4883
|
+
}
|
|
4884
|
+
},
|
|
4885
|
+
{
|
|
4886
|
+
name: "RESWithdrawEvent",
|
|
4887
|
+
type: {
|
|
4888
|
+
kind: "struct",
|
|
4889
|
+
fields: [
|
|
4890
|
+
{
|
|
4891
|
+
name: "re_id",
|
|
4892
|
+
type: {
|
|
4893
|
+
array: [
|
|
4894
|
+
"u8",
|
|
4895
|
+
32
|
|
4896
|
+
]
|
|
4897
|
+
}
|
|
4898
|
+
},
|
|
4899
|
+
{
|
|
4900
|
+
name: "sender",
|
|
4901
|
+
type: "pubkey"
|
|
4902
|
+
},
|
|
4903
|
+
{
|
|
4904
|
+
name: "amount",
|
|
4905
|
+
type: "u64"
|
|
4906
|
+
},
|
|
4907
|
+
{
|
|
4908
|
+
name: "remaining_number",
|
|
4909
|
+
type: "u32"
|
|
4910
|
+
},
|
|
4911
|
+
{
|
|
4912
|
+
name: "timestamp",
|
|
4913
|
+
type: "u64"
|
|
4914
|
+
}
|
|
4915
|
+
]
|
|
4916
|
+
}
|
|
4917
|
+
},
|
|
4918
|
+
{
|
|
4919
|
+
name: "RESendEvent",
|
|
4920
|
+
type: {
|
|
4921
|
+
kind: "struct",
|
|
4922
|
+
fields: [
|
|
4923
|
+
{
|
|
4924
|
+
name: "id",
|
|
4925
|
+
type: {
|
|
4926
|
+
array: [
|
|
4927
|
+
"u8",
|
|
4928
|
+
32
|
|
4929
|
+
]
|
|
4930
|
+
}
|
|
4931
|
+
},
|
|
4932
|
+
{
|
|
4933
|
+
name: "re_sender",
|
|
4934
|
+
type: "pubkey"
|
|
4935
|
+
},
|
|
4936
|
+
{
|
|
4937
|
+
name: "token_type",
|
|
4938
|
+
type: "u32"
|
|
4939
|
+
},
|
|
4940
|
+
{
|
|
4941
|
+
name: "token_address",
|
|
4942
|
+
type: "pubkey"
|
|
4943
|
+
},
|
|
4944
|
+
{
|
|
4945
|
+
name: "amount",
|
|
4946
|
+
type: "u64"
|
|
4947
|
+
},
|
|
4948
|
+
{
|
|
4949
|
+
name: "re_type",
|
|
4950
|
+
type: "u32"
|
|
4951
|
+
},
|
|
4952
|
+
{
|
|
4953
|
+
name: "number",
|
|
4954
|
+
type: "u32"
|
|
4955
|
+
},
|
|
4956
|
+
{
|
|
4957
|
+
name: "timestamp",
|
|
4958
|
+
type: "u64"
|
|
4959
|
+
},
|
|
4960
|
+
{
|
|
4961
|
+
name: "check_params",
|
|
4962
|
+
type: {
|
|
4963
|
+
defined: {
|
|
4964
|
+
name: "CheckParams"
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
},
|
|
4968
|
+
{
|
|
4969
|
+
name: "empty_ratio",
|
|
4970
|
+
type: "u8"
|
|
4971
|
+
}
|
|
4972
|
+
]
|
|
4973
|
+
}
|
|
4974
|
+
},
|
|
4975
|
+
{
|
|
4976
|
+
name: "RESendParam",
|
|
4977
|
+
type: {
|
|
4978
|
+
kind: "struct",
|
|
4979
|
+
fields: [
|
|
4980
|
+
{
|
|
4981
|
+
name: "re_type",
|
|
4982
|
+
docs: [
|
|
4983
|
+
"Red envelope type: 0 = random, 1 = average"
|
|
4984
|
+
],
|
|
4985
|
+
type: "u32"
|
|
4986
|
+
},
|
|
4987
|
+
{
|
|
4988
|
+
name: "number",
|
|
4989
|
+
docs: [
|
|
4990
|
+
"Number of recipients"
|
|
4991
|
+
],
|
|
4992
|
+
type: "u32"
|
|
4993
|
+
},
|
|
4994
|
+
{
|
|
4995
|
+
name: "amount",
|
|
4996
|
+
docs: [
|
|
4997
|
+
"Total amount, the smallest unit"
|
|
4998
|
+
],
|
|
4999
|
+
type: "u64"
|
|
5000
|
+
},
|
|
5001
|
+
{
|
|
5002
|
+
name: "check_contract",
|
|
5003
|
+
docs: [
|
|
5004
|
+
"Eligibility check contract"
|
|
5005
|
+
],
|
|
5006
|
+
type: "pubkey"
|
|
5007
|
+
},
|
|
5008
|
+
{
|
|
5009
|
+
name: "check_params",
|
|
5010
|
+
docs: [
|
|
5011
|
+
"Params passed to check_contract"
|
|
5012
|
+
],
|
|
5013
|
+
type: {
|
|
5014
|
+
defined: {
|
|
5015
|
+
name: "CheckParams"
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
5018
|
+
},
|
|
5019
|
+
{
|
|
5020
|
+
name: "empty_ratio",
|
|
5021
|
+
docs: [
|
|
5022
|
+
"Empty red envelope ratio, 0\u2013100"
|
|
5023
|
+
],
|
|
5024
|
+
type: "u8"
|
|
5025
|
+
}
|
|
5026
|
+
]
|
|
5027
|
+
}
|
|
5028
|
+
},
|
|
5029
|
+
{
|
|
5030
|
+
name: "RedEnvelopeState",
|
|
5031
|
+
type: {
|
|
5032
|
+
kind: "struct",
|
|
5033
|
+
fields: [
|
|
5034
|
+
{
|
|
5035
|
+
name: "owner",
|
|
5036
|
+
type: "pubkey"
|
|
5037
|
+
},
|
|
5038
|
+
{
|
|
5039
|
+
name: "id_counter",
|
|
5040
|
+
type: "u128"
|
|
5041
|
+
},
|
|
5042
|
+
{
|
|
5043
|
+
name: "primus_zktls",
|
|
5044
|
+
type: "pubkey"
|
|
5045
|
+
},
|
|
5046
|
+
{
|
|
5047
|
+
name: "claim_fee",
|
|
5048
|
+
type: "u64"
|
|
5049
|
+
},
|
|
5050
|
+
{
|
|
5051
|
+
name: "fee_recipient",
|
|
5052
|
+
type: "pubkey"
|
|
5053
|
+
},
|
|
5054
|
+
{
|
|
5055
|
+
name: "withdraw_delay",
|
|
5056
|
+
type: "u64"
|
|
5057
|
+
},
|
|
5058
|
+
{
|
|
5059
|
+
name: "bump",
|
|
5060
|
+
type: "u8"
|
|
5061
|
+
}
|
|
5062
|
+
]
|
|
5063
|
+
}
|
|
5064
|
+
},
|
|
5065
|
+
{
|
|
5066
|
+
name: "TipToken",
|
|
5067
|
+
type: {
|
|
5068
|
+
kind: "struct",
|
|
5069
|
+
fields: [
|
|
5070
|
+
{
|
|
5071
|
+
name: "token_type",
|
|
5072
|
+
docs: [
|
|
5073
|
+
"tokenType is erc20, native or nft. 0 means erc20, 1 means native and 2 means nft."
|
|
5074
|
+
],
|
|
5075
|
+
type: "u32"
|
|
5076
|
+
},
|
|
5077
|
+
{
|
|
5078
|
+
name: "token_address",
|
|
5079
|
+
docs: [
|
|
5080
|
+
"Token address"
|
|
5081
|
+
],
|
|
5082
|
+
type: "pubkey"
|
|
5083
|
+
}
|
|
5084
|
+
]
|
|
5085
|
+
}
|
|
5086
|
+
}
|
|
5087
|
+
]
|
|
5088
|
+
};
|
|
5089
|
+
|
|
5090
|
+
// src/config/zktlsIdl.json
|
|
5091
|
+
var zktlsIdl_default = {
|
|
5092
|
+
address: "3qG9pUbAHfizoqnvj9GxnTPaVgkyb7Ry6Q5vozMYdVAA",
|
|
5093
|
+
metadata: {
|
|
5094
|
+
name: "primus_zktls",
|
|
5095
|
+
version: "0.1.0",
|
|
5096
|
+
spec: "0.1.0",
|
|
5097
|
+
description: "Created with Anchor"
|
|
5098
|
+
},
|
|
5099
|
+
instructions: [
|
|
5100
|
+
{
|
|
5101
|
+
name: "initialize",
|
|
5102
|
+
discriminator: [
|
|
5103
|
+
175,
|
|
5104
|
+
175,
|
|
5105
|
+
109,
|
|
5106
|
+
31,
|
|
5107
|
+
13,
|
|
5108
|
+
152,
|
|
5109
|
+
155,
|
|
5110
|
+
237
|
|
5111
|
+
],
|
|
5112
|
+
accounts: [
|
|
5113
|
+
{
|
|
5114
|
+
name: "state",
|
|
5115
|
+
writable: true,
|
|
5116
|
+
pda: {
|
|
5117
|
+
seeds: [
|
|
5118
|
+
{
|
|
5119
|
+
kind: "const",
|
|
5120
|
+
value: [
|
|
5121
|
+
112,
|
|
5122
|
+
114,
|
|
5123
|
+
105,
|
|
5124
|
+
109,
|
|
5125
|
+
117,
|
|
5126
|
+
115,
|
|
5127
|
+
95,
|
|
5128
|
+
115,
|
|
5129
|
+
116,
|
|
5130
|
+
97,
|
|
5131
|
+
116,
|
|
5132
|
+
101
|
|
5133
|
+
]
|
|
5134
|
+
}
|
|
5135
|
+
]
|
|
5136
|
+
}
|
|
5137
|
+
},
|
|
5138
|
+
{
|
|
5139
|
+
name: "owner",
|
|
5140
|
+
writable: true,
|
|
5141
|
+
signer: true
|
|
5142
|
+
},
|
|
5143
|
+
{
|
|
5144
|
+
name: "system_program",
|
|
5145
|
+
address: "11111111111111111111111111111111"
|
|
5146
|
+
}
|
|
5147
|
+
],
|
|
5148
|
+
args: [
|
|
5149
|
+
{
|
|
5150
|
+
name: "default_addr",
|
|
5151
|
+
type: {
|
|
5152
|
+
array: [
|
|
5153
|
+
"u8",
|
|
5154
|
+
20
|
|
5155
|
+
]
|
|
5156
|
+
}
|
|
5157
|
+
}
|
|
5158
|
+
]
|
|
5159
|
+
},
|
|
5160
|
+
{
|
|
5161
|
+
name: "remove_attestor",
|
|
5162
|
+
discriminator: [
|
|
5163
|
+
108,
|
|
5164
|
+
232,
|
|
5165
|
+
239,
|
|
5166
|
+
229,
|
|
5167
|
+
84,
|
|
5168
|
+
249,
|
|
5169
|
+
29,
|
|
5170
|
+
22
|
|
5171
|
+
],
|
|
5172
|
+
accounts: [
|
|
5173
|
+
{
|
|
5174
|
+
name: "state",
|
|
5175
|
+
writable: true
|
|
5176
|
+
},
|
|
5177
|
+
{
|
|
5178
|
+
name: "owner",
|
|
5179
|
+
writable: true,
|
|
5180
|
+
signer: true,
|
|
5181
|
+
relations: [
|
|
5182
|
+
"state"
|
|
5183
|
+
]
|
|
5184
|
+
}
|
|
5185
|
+
],
|
|
5186
|
+
args: [
|
|
5187
|
+
{
|
|
5188
|
+
name: "target_addr",
|
|
5189
|
+
type: {
|
|
5190
|
+
array: [
|
|
5191
|
+
"u8",
|
|
5192
|
+
20
|
|
5193
|
+
]
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
]
|
|
5197
|
+
},
|
|
5198
|
+
{
|
|
5199
|
+
name: "set_attestor",
|
|
5200
|
+
discriminator: [
|
|
5201
|
+
95,
|
|
5202
|
+
11,
|
|
5203
|
+
236,
|
|
5204
|
+
157,
|
|
5205
|
+
234,
|
|
5206
|
+
146,
|
|
5207
|
+
163,
|
|
5208
|
+
237
|
|
5209
|
+
],
|
|
5210
|
+
accounts: [
|
|
5211
|
+
{
|
|
5212
|
+
name: "state",
|
|
5213
|
+
writable: true
|
|
5214
|
+
},
|
|
5215
|
+
{
|
|
5216
|
+
name: "owner",
|
|
5217
|
+
writable: true,
|
|
5218
|
+
signer: true,
|
|
5219
|
+
relations: [
|
|
5220
|
+
"state"
|
|
5221
|
+
]
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
name: "system_program",
|
|
5225
|
+
address: "11111111111111111111111111111111"
|
|
5226
|
+
}
|
|
5227
|
+
],
|
|
5228
|
+
args: [
|
|
5229
|
+
{
|
|
5230
|
+
name: "attestor",
|
|
5231
|
+
type: {
|
|
5232
|
+
defined: {
|
|
5233
|
+
name: "Attestor"
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
}
|
|
5237
|
+
]
|
|
5238
|
+
},
|
|
5239
|
+
{
|
|
5240
|
+
name: "store_chunk",
|
|
5241
|
+
discriminator: [
|
|
5242
|
+
100,
|
|
5243
|
+
147,
|
|
5244
|
+
78,
|
|
5245
|
+
157,
|
|
5246
|
+
82,
|
|
5247
|
+
197,
|
|
5248
|
+
253,
|
|
5249
|
+
165
|
|
5250
|
+
],
|
|
5251
|
+
accounts: [
|
|
5252
|
+
{
|
|
5253
|
+
name: "data_buffer",
|
|
5254
|
+
writable: true
|
|
5255
|
+
},
|
|
5256
|
+
{
|
|
5257
|
+
name: "user",
|
|
5258
|
+
signer: true,
|
|
5259
|
+
relations: [
|
|
5260
|
+
"data_buffer"
|
|
5261
|
+
]
|
|
5262
|
+
}
|
|
5263
|
+
],
|
|
5264
|
+
args: [
|
|
5265
|
+
{
|
|
5266
|
+
name: "chunk",
|
|
5267
|
+
type: "bytes"
|
|
5268
|
+
}
|
|
5269
|
+
]
|
|
5270
|
+
},
|
|
5271
|
+
{
|
|
5272
|
+
name: "store_close",
|
|
5273
|
+
discriminator: [
|
|
5274
|
+
231,
|
|
5275
|
+
65,
|
|
5276
|
+
66,
|
|
5277
|
+
193,
|
|
5278
|
+
128,
|
|
5279
|
+
236,
|
|
5280
|
+
61,
|
|
5281
|
+
11
|
|
5282
|
+
],
|
|
5283
|
+
accounts: [
|
|
5284
|
+
{
|
|
5285
|
+
name: "data_buffer",
|
|
5286
|
+
writable: true
|
|
5287
|
+
},
|
|
5288
|
+
{
|
|
5289
|
+
name: "user",
|
|
5290
|
+
signer: true,
|
|
5291
|
+
relations: [
|
|
5292
|
+
"data_buffer"
|
|
5293
|
+
]
|
|
5294
|
+
}
|
|
5295
|
+
],
|
|
5296
|
+
args: []
|
|
5297
|
+
},
|
|
5298
|
+
{
|
|
5299
|
+
name: "store_initialize",
|
|
5300
|
+
docs: [
|
|
5301
|
+
"DataBuffer Store"
|
|
5302
|
+
],
|
|
5303
|
+
discriminator: [
|
|
5304
|
+
58,
|
|
5305
|
+
143,
|
|
5306
|
+
215,
|
|
5307
|
+
232,
|
|
5308
|
+
184,
|
|
5309
|
+
29,
|
|
5310
|
+
233,
|
|
5311
|
+
116
|
|
5312
|
+
],
|
|
5313
|
+
accounts: [
|
|
5314
|
+
{
|
|
5315
|
+
name: "data_buffer",
|
|
5316
|
+
writable: true,
|
|
5317
|
+
signer: true
|
|
5318
|
+
},
|
|
5319
|
+
{
|
|
5320
|
+
name: "user",
|
|
5321
|
+
writable: true,
|
|
5322
|
+
signer: true
|
|
5323
|
+
},
|
|
5324
|
+
{
|
|
5325
|
+
name: "system_program",
|
|
5326
|
+
address: "11111111111111111111111111111111"
|
|
5327
|
+
}
|
|
5328
|
+
],
|
|
5329
|
+
args: [
|
|
5330
|
+
{
|
|
5331
|
+
name: "data_length",
|
|
5332
|
+
type: "u32"
|
|
5333
|
+
}
|
|
5334
|
+
]
|
|
5335
|
+
},
|
|
5336
|
+
{
|
|
5337
|
+
name: "verify_attestation",
|
|
5338
|
+
discriminator: [
|
|
5339
|
+
144,
|
|
5340
|
+
30,
|
|
5341
|
+
116,
|
|
5342
|
+
186,
|
|
5343
|
+
33,
|
|
5344
|
+
176,
|
|
5345
|
+
35,
|
|
5346
|
+
60
|
|
5347
|
+
],
|
|
5348
|
+
accounts: [
|
|
5349
|
+
{
|
|
5350
|
+
name: "state",
|
|
5351
|
+
writable: true
|
|
5352
|
+
},
|
|
5353
|
+
{
|
|
5354
|
+
name: "user",
|
|
5355
|
+
signer: true,
|
|
5356
|
+
relations: [
|
|
5357
|
+
"data_buffer"
|
|
5358
|
+
]
|
|
5359
|
+
},
|
|
5360
|
+
{
|
|
5361
|
+
name: "data_buffer",
|
|
5362
|
+
writable: true,
|
|
5363
|
+
optional: true
|
|
5364
|
+
}
|
|
5365
|
+
],
|
|
5366
|
+
args: [
|
|
5367
|
+
{
|
|
5368
|
+
name: "_att",
|
|
5369
|
+
type: {
|
|
5370
|
+
option: {
|
|
5371
|
+
defined: {
|
|
5372
|
+
name: "Attestation"
|
|
5373
|
+
}
|
|
5374
|
+
}
|
|
5375
|
+
}
|
|
5376
|
+
}
|
|
5377
|
+
]
|
|
5378
|
+
}
|
|
5379
|
+
],
|
|
5380
|
+
accounts: [
|
|
5381
|
+
{
|
|
5382
|
+
name: "DataBuffer",
|
|
5383
|
+
discriminator: [
|
|
5384
|
+
235,
|
|
5385
|
+
220,
|
|
5386
|
+
51,
|
|
5387
|
+
248,
|
|
5388
|
+
56,
|
|
5389
|
+
77,
|
|
5390
|
+
241,
|
|
5391
|
+
89
|
|
5392
|
+
]
|
|
5393
|
+
},
|
|
5394
|
+
{
|
|
5395
|
+
name: "PrimusState",
|
|
5396
|
+
discriminator: [
|
|
5397
|
+
200,
|
|
5398
|
+
136,
|
|
5399
|
+
35,
|
|
5400
|
+
84,
|
|
5401
|
+
173,
|
|
5402
|
+
237,
|
|
5403
|
+
163,
|
|
5404
|
+
179
|
|
5405
|
+
]
|
|
5406
|
+
}
|
|
5407
|
+
],
|
|
5408
|
+
events: [
|
|
5409
|
+
{
|
|
5410
|
+
name: "AddAttestorEvent",
|
|
5411
|
+
discriminator: [
|
|
5412
|
+
36,
|
|
5413
|
+
104,
|
|
5414
|
+
4,
|
|
5415
|
+
119,
|
|
5416
|
+
98,
|
|
5417
|
+
31,
|
|
5418
|
+
220,
|
|
5419
|
+
145
|
|
5420
|
+
]
|
|
5421
|
+
},
|
|
5422
|
+
{
|
|
5423
|
+
name: "DelAttestorEvent",
|
|
5424
|
+
discriminator: [
|
|
5425
|
+
103,
|
|
5426
|
+
73,
|
|
5427
|
+
88,
|
|
5428
|
+
10,
|
|
5429
|
+
15,
|
|
5430
|
+
78,
|
|
5431
|
+
23,
|
|
5432
|
+
49
|
|
5433
|
+
]
|
|
5434
|
+
}
|
|
5435
|
+
],
|
|
5436
|
+
errors: [
|
|
5437
|
+
{
|
|
5438
|
+
code: 6e3,
|
|
5439
|
+
name: "Unauthorized",
|
|
5440
|
+
msg: "Unauthorized"
|
|
5441
|
+
},
|
|
5442
|
+
{
|
|
5443
|
+
code: 6001,
|
|
5444
|
+
name: "AttestationExpired",
|
|
5445
|
+
msg: "Attestation expired"
|
|
5446
|
+
},
|
|
5447
|
+
{
|
|
5448
|
+
code: 6002,
|
|
5449
|
+
name: "AttestorLimitReached",
|
|
5450
|
+
msg: "Attestor limit reached"
|
|
5451
|
+
},
|
|
5452
|
+
{
|
|
5453
|
+
code: 6003,
|
|
5454
|
+
name: "AttestorNotFound",
|
|
5455
|
+
msg: "Attestor not found"
|
|
5456
|
+
},
|
|
5457
|
+
{
|
|
5458
|
+
code: 6004,
|
|
5459
|
+
name: "InvalidSignatureLength",
|
|
5460
|
+
msg: "Invalid signature length"
|
|
5461
|
+
},
|
|
5462
|
+
{
|
|
5463
|
+
code: 6005,
|
|
5464
|
+
name: "InvalidSignatureVValue",
|
|
5465
|
+
msg: "Invalid signature v value"
|
|
5466
|
+
},
|
|
5467
|
+
{
|
|
5468
|
+
code: 6006,
|
|
5469
|
+
name: "InvalidSignature",
|
|
5470
|
+
msg: "Invalid signature"
|
|
5471
|
+
},
|
|
5472
|
+
{
|
|
5473
|
+
code: 6007,
|
|
5474
|
+
name: "TooLarge",
|
|
5475
|
+
msg: "Too Large"
|
|
5476
|
+
},
|
|
5477
|
+
{
|
|
5478
|
+
code: 6008,
|
|
5479
|
+
name: "DeserializationFailed",
|
|
5480
|
+
msg: "Deserialization Failed"
|
|
5481
|
+
},
|
|
5482
|
+
{
|
|
5483
|
+
code: 6009,
|
|
5484
|
+
name: "OutOfBounds",
|
|
5485
|
+
msg: "Out Of Bounds"
|
|
5486
|
+
}
|
|
5487
|
+
],
|
|
5488
|
+
types: [
|
|
5489
|
+
{
|
|
5490
|
+
name: "AddAttestorEvent",
|
|
5491
|
+
type: {
|
|
5492
|
+
kind: "struct",
|
|
5493
|
+
fields: [
|
|
5494
|
+
{
|
|
5495
|
+
name: "address",
|
|
5496
|
+
type: {
|
|
5497
|
+
array: [
|
|
5498
|
+
"u8",
|
|
5499
|
+
20
|
|
5500
|
+
]
|
|
5501
|
+
}
|
|
5502
|
+
},
|
|
5503
|
+
{
|
|
5504
|
+
name: "attestor",
|
|
5505
|
+
type: {
|
|
5506
|
+
defined: {
|
|
5507
|
+
name: "Attestor"
|
|
5508
|
+
}
|
|
5509
|
+
}
|
|
5510
|
+
}
|
|
5511
|
+
]
|
|
5512
|
+
}
|
|
5513
|
+
},
|
|
5514
|
+
{
|
|
5515
|
+
name: "AttNetworkRequest",
|
|
5516
|
+
type: {
|
|
5517
|
+
kind: "struct",
|
|
5518
|
+
fields: [
|
|
5519
|
+
{
|
|
5520
|
+
name: "url",
|
|
5521
|
+
type: "string"
|
|
5522
|
+
},
|
|
5523
|
+
{
|
|
5524
|
+
name: "header",
|
|
5525
|
+
type: "string"
|
|
5526
|
+
},
|
|
5527
|
+
{
|
|
5528
|
+
name: "method",
|
|
5529
|
+
type: "string"
|
|
5530
|
+
},
|
|
5531
|
+
{
|
|
5532
|
+
name: "body",
|
|
5533
|
+
type: "string"
|
|
5534
|
+
}
|
|
5535
|
+
]
|
|
5536
|
+
}
|
|
5537
|
+
},
|
|
5538
|
+
{
|
|
5539
|
+
name: "AttNetworkResponseResolve",
|
|
5540
|
+
type: {
|
|
5541
|
+
kind: "struct",
|
|
5542
|
+
fields: [
|
|
5543
|
+
{
|
|
5544
|
+
name: "key_name",
|
|
5545
|
+
type: "string"
|
|
5546
|
+
},
|
|
5547
|
+
{
|
|
5548
|
+
name: "parse_type",
|
|
5549
|
+
type: "string"
|
|
5550
|
+
},
|
|
5551
|
+
{
|
|
5552
|
+
name: "parse_path",
|
|
5553
|
+
type: "string"
|
|
5554
|
+
}
|
|
5555
|
+
]
|
|
5556
|
+
}
|
|
5557
|
+
},
|
|
5558
|
+
{
|
|
5559
|
+
name: "Attestation",
|
|
5560
|
+
type: {
|
|
5561
|
+
kind: "struct",
|
|
5562
|
+
fields: [
|
|
5563
|
+
{
|
|
5564
|
+
name: "recipient",
|
|
5565
|
+
type: {
|
|
5566
|
+
array: [
|
|
5567
|
+
"u8",
|
|
5568
|
+
32
|
|
5569
|
+
]
|
|
5570
|
+
}
|
|
5571
|
+
},
|
|
5572
|
+
{
|
|
5573
|
+
name: "request",
|
|
5574
|
+
type: {
|
|
5575
|
+
defined: {
|
|
5576
|
+
name: "AttNetworkRequest"
|
|
5577
|
+
}
|
|
5578
|
+
}
|
|
5579
|
+
},
|
|
5580
|
+
{
|
|
5581
|
+
name: "response_resolve",
|
|
5582
|
+
type: {
|
|
5583
|
+
vec: {
|
|
5584
|
+
defined: {
|
|
5585
|
+
name: "AttNetworkResponseResolve"
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
}
|
|
5589
|
+
},
|
|
5590
|
+
{
|
|
5591
|
+
name: "data",
|
|
5592
|
+
type: "string"
|
|
5593
|
+
},
|
|
5594
|
+
{
|
|
5595
|
+
name: "att_conditions",
|
|
5596
|
+
type: "string"
|
|
5597
|
+
},
|
|
5598
|
+
{
|
|
5599
|
+
name: "timestamp",
|
|
5600
|
+
type: "u64"
|
|
5601
|
+
},
|
|
5602
|
+
{
|
|
5603
|
+
name: "addition_params",
|
|
5604
|
+
type: "string"
|
|
5605
|
+
},
|
|
5606
|
+
{
|
|
5607
|
+
name: "attestors",
|
|
5608
|
+
type: {
|
|
5609
|
+
vec: {
|
|
5610
|
+
defined: {
|
|
5611
|
+
name: "Attestor"
|
|
5612
|
+
}
|
|
5613
|
+
}
|
|
5614
|
+
}
|
|
5615
|
+
},
|
|
5616
|
+
{
|
|
5617
|
+
name: "signatures",
|
|
5618
|
+
type: {
|
|
5619
|
+
vec: "bytes"
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
]
|
|
5623
|
+
}
|
|
5624
|
+
},
|
|
5625
|
+
{
|
|
5626
|
+
name: "Attestor",
|
|
5627
|
+
type: {
|
|
5628
|
+
kind: "struct",
|
|
5629
|
+
fields: [
|
|
5630
|
+
{
|
|
5631
|
+
name: "attestor_addr",
|
|
5632
|
+
type: {
|
|
5633
|
+
array: [
|
|
5634
|
+
"u8",
|
|
5635
|
+
20
|
|
5636
|
+
]
|
|
5637
|
+
}
|
|
5638
|
+
},
|
|
5639
|
+
{
|
|
5640
|
+
name: "url",
|
|
5641
|
+
type: "string"
|
|
5642
|
+
}
|
|
5643
|
+
]
|
|
5644
|
+
}
|
|
5645
|
+
},
|
|
5646
|
+
{
|
|
5647
|
+
name: "DataBuffer",
|
|
5648
|
+
type: {
|
|
5649
|
+
kind: "struct",
|
|
5650
|
+
fields: [
|
|
5651
|
+
{
|
|
5652
|
+
name: "user",
|
|
5653
|
+
type: "pubkey"
|
|
5654
|
+
},
|
|
5655
|
+
{
|
|
5656
|
+
name: "length",
|
|
5657
|
+
type: "u32"
|
|
5658
|
+
},
|
|
5659
|
+
{
|
|
5660
|
+
name: "data",
|
|
5661
|
+
type: "bytes"
|
|
5662
|
+
}
|
|
5663
|
+
]
|
|
5664
|
+
}
|
|
5665
|
+
},
|
|
5666
|
+
{
|
|
5667
|
+
name: "DelAttestorEvent",
|
|
5668
|
+
type: {
|
|
5669
|
+
kind: "struct",
|
|
5670
|
+
fields: [
|
|
5671
|
+
{
|
|
5672
|
+
name: "address",
|
|
5673
|
+
type: {
|
|
5674
|
+
array: [
|
|
5675
|
+
"u8",
|
|
5676
|
+
20
|
|
5677
|
+
]
|
|
5678
|
+
}
|
|
5679
|
+
}
|
|
5680
|
+
]
|
|
5681
|
+
}
|
|
5682
|
+
},
|
|
5683
|
+
{
|
|
5684
|
+
name: "PrimusState",
|
|
5685
|
+
type: {
|
|
5686
|
+
kind: "struct",
|
|
5687
|
+
fields: [
|
|
5688
|
+
{
|
|
5689
|
+
name: "owner",
|
|
5690
|
+
type: "pubkey"
|
|
5691
|
+
},
|
|
5692
|
+
{
|
|
5693
|
+
name: "attestors",
|
|
5694
|
+
type: {
|
|
5695
|
+
vec: {
|
|
5696
|
+
defined: {
|
|
5697
|
+
name: "Attestor"
|
|
5698
|
+
}
|
|
5699
|
+
}
|
|
5700
|
+
}
|
|
5701
|
+
},
|
|
5702
|
+
{
|
|
5703
|
+
name: "bump",
|
|
5704
|
+
type: "u8"
|
|
5705
|
+
}
|
|
5706
|
+
]
|
|
5707
|
+
}
|
|
5708
|
+
}
|
|
5709
|
+
]
|
|
5710
|
+
};
|
|
5711
|
+
|
|
5712
|
+
// src/classes/solana/sdk.ts
|
|
5713
|
+
import * as anchor2 from "@coral-xyz/anchor";
|
|
5714
|
+
import {
|
|
5715
|
+
PublicKey as PublicKey3,
|
|
5716
|
+
SystemProgram,
|
|
5717
|
+
Transaction,
|
|
5718
|
+
Keypair
|
|
5719
|
+
} from "@solana/web3.js";
|
|
5720
|
+
|
|
5721
|
+
// src/classes/solana/attestation_schema.ts
|
|
5722
|
+
import * as borsh2 from "borsh";
|
|
5723
|
+
var { serialize } = borsh2;
|
|
5724
|
+
var Attestor = class {
|
|
5725
|
+
attestorAddr;
|
|
5726
|
+
url;
|
|
5727
|
+
constructor(fields) {
|
|
5728
|
+
this.attestorAddr = fields.attestorAddr;
|
|
5729
|
+
this.url = fields.url;
|
|
5730
|
+
}
|
|
5731
|
+
};
|
|
5732
|
+
var AttNetworkRequest = class {
|
|
5733
|
+
url;
|
|
5734
|
+
header;
|
|
5735
|
+
method;
|
|
5736
|
+
body;
|
|
5737
|
+
constructor(fields) {
|
|
5738
|
+
this.url = fields.url;
|
|
5739
|
+
this.header = fields.header;
|
|
5740
|
+
this.method = fields.method;
|
|
5741
|
+
this.body = fields.body;
|
|
5742
|
+
}
|
|
5743
|
+
};
|
|
5744
|
+
var AttNetworkResponseResolve = class {
|
|
5745
|
+
keyName;
|
|
5746
|
+
parseType;
|
|
5747
|
+
parsePath;
|
|
5748
|
+
constructor(fields) {
|
|
5749
|
+
this.keyName = fields.keyName;
|
|
5750
|
+
this.parseType = fields.parseType;
|
|
5751
|
+
this.parsePath = fields.parsePath;
|
|
5752
|
+
}
|
|
5753
|
+
};
|
|
5754
|
+
var Attestation = class {
|
|
5755
|
+
recipient;
|
|
5756
|
+
request;
|
|
5757
|
+
responseResolve;
|
|
5758
|
+
data;
|
|
5759
|
+
attConditions;
|
|
5760
|
+
timestamp;
|
|
5761
|
+
additionParams;
|
|
5762
|
+
attestors;
|
|
5763
|
+
signatures;
|
|
5764
|
+
constructor(fields) {
|
|
5765
|
+
this.recipient = fields.recipient;
|
|
5766
|
+
this.request = new AttNetworkRequest(fields.request);
|
|
5767
|
+
this.responseResolve = fields.responseResolve.map((x) => new AttNetworkResponseResolve(x));
|
|
5768
|
+
this.data = fields.data;
|
|
5769
|
+
this.attConditions = fields.attConditions;
|
|
5770
|
+
this.timestamp = fields.timestamp;
|
|
5771
|
+
this.additionParams = fields.additionParams;
|
|
5772
|
+
this.attestors = fields.attestors.map((x) => new Attestor(x));
|
|
5773
|
+
this.signatures = fields.signatures;
|
|
5774
|
+
}
|
|
5775
|
+
};
|
|
5776
|
+
var schema = /* @__PURE__ */ new Map([
|
|
5777
|
+
[Attestor, {
|
|
5778
|
+
kind: "struct",
|
|
5779
|
+
fields: [
|
|
5780
|
+
["attestorAddr", [20]],
|
|
5781
|
+
["url", "string"]
|
|
5782
|
+
]
|
|
5783
|
+
}],
|
|
5784
|
+
[AttNetworkRequest, {
|
|
5785
|
+
kind: "struct",
|
|
5786
|
+
fields: [
|
|
5787
|
+
["url", "string"],
|
|
5788
|
+
["header", "string"],
|
|
5789
|
+
["method", "string"],
|
|
5790
|
+
["body", "string"]
|
|
5791
|
+
]
|
|
5792
|
+
}],
|
|
5793
|
+
[AttNetworkResponseResolve, {
|
|
5794
|
+
kind: "struct",
|
|
5795
|
+
fields: [
|
|
5796
|
+
["keyName", "string"],
|
|
5797
|
+
["parseType", "string"],
|
|
5798
|
+
["parsePath", "string"]
|
|
5799
|
+
]
|
|
5800
|
+
}],
|
|
5801
|
+
[Attestation, {
|
|
5802
|
+
kind: "struct",
|
|
5803
|
+
fields: [
|
|
5804
|
+
["recipient", [32]],
|
|
5805
|
+
["request", AttNetworkRequest],
|
|
5806
|
+
["responseResolve", [AttNetworkResponseResolve]],
|
|
5807
|
+
["data", "string"],
|
|
5808
|
+
["attConditions", "string"],
|
|
5809
|
+
["timestamp", "u64"],
|
|
5810
|
+
["additionParams", "string"],
|
|
5811
|
+
["attestors", [Attestor]],
|
|
5812
|
+
["signatures", [["u8"]]]
|
|
5813
|
+
]
|
|
5814
|
+
}]
|
|
5815
|
+
]);
|
|
5816
|
+
function normalizeAttestationInput(obj) {
|
|
5817
|
+
return new Attestation({
|
|
5818
|
+
...obj,
|
|
5819
|
+
request: new AttNetworkRequest(obj.request),
|
|
5820
|
+
responseResolve: obj.responseResolve.map((x) => new AttNetworkResponseResolve(x)),
|
|
5821
|
+
attestors: obj.attestors.map((x) => new Attestor(x))
|
|
5822
|
+
});
|
|
5823
|
+
}
|
|
5824
|
+
function serializeAttestation(attObj) {
|
|
5825
|
+
const borshObj = normalizeAttestationInput(attObj);
|
|
5826
|
+
console.log("attObj", attObj, "serializeAttestation-borshObj", borshObj);
|
|
5827
|
+
const buffer = serialize(schema, borshObj);
|
|
5828
|
+
console.log("attObj=buffer", buffer);
|
|
5829
|
+
return buffer;
|
|
5830
|
+
}
|
|
5831
|
+
|
|
5832
|
+
// src/classes/solana/pda.ts
|
|
5833
|
+
import {
|
|
5834
|
+
PublicKey as PublicKey2
|
|
5835
|
+
} from "@solana/web3.js";
|
|
5836
|
+
var SEED_PRIMUS_STATE = new TextEncoder().encode("primus_state");
|
|
5837
|
+
var SEED_PRIMUS_RE_STATE = new TextEncoder().encode("red_envelope");
|
|
5838
|
+
var SEED_PRIMUS_RE_RECORD = new TextEncoder().encode("re_record");
|
|
5839
|
+
function getPrimusZktlsPda({
|
|
5840
|
+
programId
|
|
5841
|
+
}) {
|
|
5842
|
+
return PublicKey2.findProgramAddressSync(
|
|
5843
|
+
[SEED_PRIMUS_STATE],
|
|
5844
|
+
programId
|
|
5845
|
+
);
|
|
5846
|
+
}
|
|
5847
|
+
function getPrimusRedEnvelopePda({
|
|
5848
|
+
programId
|
|
5849
|
+
}) {
|
|
5850
|
+
return PublicKey2.findProgramAddressSync(
|
|
5851
|
+
[SEED_PRIMUS_RE_STATE],
|
|
5852
|
+
programId
|
|
5853
|
+
);
|
|
5854
|
+
}
|
|
5855
|
+
function getPrimusRERecordPda({
|
|
5856
|
+
programId,
|
|
5857
|
+
reId
|
|
5858
|
+
}) {
|
|
5859
|
+
return PublicKey2.findProgramAddressSync(
|
|
5860
|
+
[SEED_PRIMUS_RE_RECORD, reId],
|
|
5861
|
+
programId
|
|
5862
|
+
);
|
|
5863
|
+
}
|
|
5864
|
+
|
|
5865
|
+
// src/classes/solana/sdk.ts
|
|
5866
|
+
import { utils } from "ethers";
|
|
5867
|
+
import { getAssociatedTokenAddress } from "@solana/spl-token";
|
|
5868
|
+
var ERC20_TYPE = 0;
|
|
5869
|
+
var CHUNK_SIZE = 960;
|
|
5870
|
+
var VERBOSE = 0;
|
|
5871
|
+
var RE_USERID_LEN = 8;
|
|
5872
|
+
var NATIVETOKENATTBUFFERMAXLEN = 718;
|
|
5873
|
+
var ERC20TOKENATTBUFFERMAXLEN = 622;
|
|
5874
|
+
async function waitForTransactionConfirmation(provider, tx, retries = 5, delayMs = 1e3) {
|
|
5875
|
+
for (let i = 0; i < retries; i++) {
|
|
5876
|
+
const txDetails = await provider.connection.getTransaction(tx, {
|
|
5877
|
+
maxSupportedTransactionVersion: 0,
|
|
5878
|
+
commitment: "confirmed"
|
|
5879
|
+
});
|
|
5880
|
+
if (txDetails) {
|
|
5881
|
+
console.log("Transaction details:", txDetails);
|
|
5882
|
+
if (VERBOSE > 2) {
|
|
5883
|
+
console.log("Program logs:", txDetails.meta?.logMessages);
|
|
5884
|
+
}
|
|
5885
|
+
return txDetails;
|
|
5886
|
+
}
|
|
5887
|
+
await new Promise((res) => setTimeout(res, delayMs));
|
|
5888
|
+
}
|
|
5889
|
+
console.warn(`Transaction ${tx} not found after ${retries} retries.`);
|
|
5890
|
+
return null;
|
|
5891
|
+
}
|
|
5892
|
+
async function reSend({
|
|
5893
|
+
redEnvelopeProgram,
|
|
5894
|
+
userKey,
|
|
5895
|
+
provider,
|
|
5896
|
+
tipToken,
|
|
5897
|
+
reSendParam,
|
|
5898
|
+
payer = null
|
|
5899
|
+
}) {
|
|
5900
|
+
return new Promise(async (resolve, reject) => {
|
|
5901
|
+
let signatureStr;
|
|
5902
|
+
try {
|
|
5903
|
+
const spaceAccount = Keypair.generate();
|
|
5904
|
+
const space = 8 + 32 + 4 + 8 * reSendParam.number + 4 + RE_USERID_LEN * reSendParam.number;
|
|
5905
|
+
if (space > 10 * 1024 * 1024 - 256) {
|
|
5906
|
+
throw "Cannot make so large space[" + space.toString() + "]";
|
|
5907
|
+
}
|
|
5908
|
+
const lamports = await provider.connection.getMinimumBalanceForRentExemption(space);
|
|
5909
|
+
console.log("spaceAccount:", spaceAccount.publicKey.toBase58(), "space:", space, "minimum rent:", lamports / 1e9, "SOL");
|
|
5910
|
+
const createIx = SystemProgram.createAccount({
|
|
5911
|
+
fromPubkey: userKey,
|
|
5912
|
+
newAccountPubkey: spaceAccount.publicKey,
|
|
5913
|
+
lamports,
|
|
5914
|
+
space,
|
|
5915
|
+
programId: redEnvelopeProgram.programId
|
|
5916
|
+
});
|
|
5917
|
+
const reRecordDataInitIx = await redEnvelopeProgram.methods.reRecordDataInit().accounts({
|
|
5918
|
+
reRecordData: spaceAccount.publicKey,
|
|
5919
|
+
sender: userKey
|
|
5920
|
+
}).signers([spaceAccount]).instruction();
|
|
5921
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
5922
|
+
const redEnvelopeState = await redEnvelopeProgram.account.redEnvelopeState.fetch(redEnvelopePda);
|
|
5923
|
+
console.log("idCounter", redEnvelopeState.idCounter.toString());
|
|
5924
|
+
const idCounter = new anchor2.BN(redEnvelopeState.idCounter);
|
|
5925
|
+
const idCounterBytes = idCounter.toArrayLike(Buffer, "le", 16);
|
|
5926
|
+
const reId = Buffer.from(utils.arrayify(utils.keccak256(idCounterBytes)));
|
|
5927
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
5928
|
+
let mint = null;
|
|
5929
|
+
let fromTokenAccount = null;
|
|
5930
|
+
let toTokenAccount = null;
|
|
5931
|
+
if (tipToken.tokenType == ERC20_TYPE) {
|
|
5932
|
+
mint = tipToken.tokenAddress;
|
|
5933
|
+
fromTokenAccount = await getAssociatedTokenAddress(mint, userKey);
|
|
5934
|
+
toTokenAccount = await getAssociatedTokenAddress(mint, redEnvelopePda, true);
|
|
5935
|
+
}
|
|
5936
|
+
const reSendIx = await redEnvelopeProgram.methods.reSend(Array.from(reId), tipToken, reSendParam).accounts({
|
|
5937
|
+
state: redEnvelopePda,
|
|
5938
|
+
reRecord: reRecordPda,
|
|
5939
|
+
reRecordData: spaceAccount.publicKey,
|
|
5940
|
+
sender: userKey,
|
|
5941
|
+
// SPL
|
|
5942
|
+
fromTokenAccount,
|
|
5943
|
+
toTokenAccount,
|
|
5944
|
+
mint
|
|
5945
|
+
}).instruction();
|
|
5946
|
+
const tx = new Transaction().add(createIx).add(reRecordDataInitIx).add(reSendIx);
|
|
5947
|
+
tx.feePayer = userKey;
|
|
5948
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
5949
|
+
tx.partialSign(spaceAccount);
|
|
5950
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
5951
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
5952
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
5953
|
+
if (isOnChain) {
|
|
5954
|
+
console.log("reSend done, reId: ", reId.toString("hex"), signatureStr);
|
|
5955
|
+
return resolve(signatureStr);
|
|
5956
|
+
} else {
|
|
5957
|
+
const serializeSignedTx = signedTx.serialize();
|
|
5958
|
+
console.log("signedTx", signedTx, serializeSignedTx, tx.recentBlockhash);
|
|
5959
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
5960
|
+
console.log("reSend done, reId: ", reId.toString("hex"), signatureStr);
|
|
5961
|
+
return resolve(signatureStr);
|
|
5962
|
+
}
|
|
5963
|
+
} catch (err) {
|
|
5964
|
+
if (getTxIsOnProcess(err)) {
|
|
5965
|
+
console.log("reSenderWithdraw done");
|
|
5966
|
+
return resolve(signatureStr);
|
|
5967
|
+
} else {
|
|
5968
|
+
console.error("reSend error:", err);
|
|
5969
|
+
const formatErr = formatErrFn(err);
|
|
5970
|
+
return reject(formatErr);
|
|
5971
|
+
}
|
|
5972
|
+
} finally {
|
|
5973
|
+
}
|
|
5974
|
+
});
|
|
5975
|
+
}
|
|
5976
|
+
async function reClaim({
|
|
5977
|
+
redEnvelopeProgram,
|
|
5978
|
+
userKey,
|
|
5979
|
+
provider,
|
|
5980
|
+
zktlsProgram,
|
|
5981
|
+
reId,
|
|
5982
|
+
attObj
|
|
5983
|
+
}) {
|
|
5984
|
+
return new Promise(async (resolve, reject) => {
|
|
5985
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
5986
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
5987
|
+
const [primusZktlsPda] = getPrimusZktlsPda({ programId: zktlsProgram.programId });
|
|
5988
|
+
console.log("primusZktlsPda:", primusZktlsPda.toBase58());
|
|
5989
|
+
console.log("reRecordPda:", reRecordPda.toBase58());
|
|
5990
|
+
const attRecipient = new PublicKey3(attObj.recipient);
|
|
5991
|
+
const redEnvelopeState = await redEnvelopeProgram.account.redEnvelopeState.fetch(redEnvelopePda);
|
|
5992
|
+
console.log("redEnvelopeState.feeRecipient", redEnvelopeState.feeRecipient.toBase58());
|
|
5993
|
+
const feeRecipient = redEnvelopeState.feeRecipient;
|
|
5994
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
5995
|
+
let tx;
|
|
5996
|
+
let signatureStr;
|
|
5997
|
+
const dataBuffer = anchor2.web3.Keypair.generate();
|
|
5998
|
+
const dataBufferKey = dataBuffer.publicKey;
|
|
5999
|
+
const attBuffer = serializeAttestation(attObj);
|
|
6000
|
+
console.log(`attBuffer.length=${attBuffer.length}`);
|
|
6001
|
+
let storeInitialized = false;
|
|
6002
|
+
let useStoreVersion = false;
|
|
6003
|
+
if (reRecord.tokenType == ERC20_TYPE && attBuffer.length > ERC20TOKENATTBUFFERMAXLEN || reRecord.tokenType != ERC20_TYPE && attBuffer.length > NATIVETOKENATTBUFFERMAXLEN) {
|
|
6004
|
+
useStoreVersion = true;
|
|
6005
|
+
}
|
|
6006
|
+
try {
|
|
6007
|
+
if (useStoreVersion) {
|
|
6008
|
+
const txStoreInitialize = await zktlsProgram.methods.storeInitialize(attBuffer.length).accounts({ dataBuffer: dataBufferKey, user: userKey }).signers([dataBuffer]).rpc();
|
|
6009
|
+
await waitForTransactionConfirmation(provider, txStoreInitialize);
|
|
6010
|
+
storeInitialized = true;
|
|
6011
|
+
console.log("storeInitialize done");
|
|
6012
|
+
for (let offset = 0; offset < attBuffer.length; offset += CHUNK_SIZE) {
|
|
6013
|
+
const chunk = attBuffer.slice(offset, offset + CHUNK_SIZE);
|
|
6014
|
+
const txStoreChunk = await zktlsProgram.methods.storeChunk(Buffer.from(chunk)).accounts({ dataBuffer: dataBufferKey, user: userKey }).rpc();
|
|
6015
|
+
await waitForTransactionConfirmation(provider, txStoreChunk);
|
|
6016
|
+
}
|
|
6017
|
+
console.log("storeChunk done");
|
|
6018
|
+
}
|
|
6019
|
+
const reRecordData2 = await redEnvelopeProgram.account.reRecordData.fetch(reRecord.recordData);
|
|
6020
|
+
console.log("reRecordData2:", reRecordData2);
|
|
6021
|
+
console.log("reRecord.tokenType:", reRecord.tokenType);
|
|
6022
|
+
const reRecordData = reRecord.recordData;
|
|
6023
|
+
console.log("reRecord.recordData", reRecord.recordData.toBase58());
|
|
6024
|
+
let mint = null;
|
|
6025
|
+
let fromTokenAccount = null;
|
|
6026
|
+
let toTokenAccount = null;
|
|
6027
|
+
if (reRecord.tokenType == ERC20_TYPE) {
|
|
6028
|
+
console.log("reRecord.tokenAddress:", reRecord.tokenAddress);
|
|
6029
|
+
mint = reRecord.tokenAddress;
|
|
6030
|
+
fromTokenAccount = await getAssociatedTokenAddress(mint, redEnvelopePda, true);
|
|
6031
|
+
toTokenAccount = await getAssociatedTokenAddress(mint, attRecipient);
|
|
6032
|
+
}
|
|
6033
|
+
let _att = attObj;
|
|
6034
|
+
let _dataBufferKey = null;
|
|
6035
|
+
if (useStoreVersion) {
|
|
6036
|
+
_att = null;
|
|
6037
|
+
_dataBufferKey = dataBufferKey;
|
|
6038
|
+
}
|
|
6039
|
+
tx = await redEnvelopeProgram.methods.reClaim(reId, _att).accounts({
|
|
6040
|
+
state: redEnvelopePda,
|
|
6041
|
+
reRecord: reRecordPda,
|
|
6042
|
+
reRecordData,
|
|
6043
|
+
claimer: userKey,
|
|
6044
|
+
primusZktlsProgram: zktlsProgram.programId.toBase58(),
|
|
6045
|
+
primusZktlsState: primusZktlsPda,
|
|
6046
|
+
feeRecipient,
|
|
6047
|
+
attRecipient,
|
|
6048
|
+
dataBuffer: _dataBufferKey,
|
|
6049
|
+
// SPL
|
|
6050
|
+
fromTokenAccount,
|
|
6051
|
+
toTokenAccount,
|
|
6052
|
+
mint
|
|
6053
|
+
}).transaction();
|
|
6054
|
+
tx.feePayer = userKey;
|
|
6055
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
6056
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
6057
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
6058
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
6059
|
+
if (isOnChain) {
|
|
6060
|
+
console.log("reClaim done", signatureStr);
|
|
6061
|
+
return resolve(signatureStr);
|
|
6062
|
+
} else {
|
|
6063
|
+
const serializeSignedTx = signedTx.serialize();
|
|
6064
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
6065
|
+
console.log("reClaim done ", signatureStr);
|
|
6066
|
+
return resolve(signatureStr);
|
|
6067
|
+
}
|
|
6068
|
+
} catch (err) {
|
|
6069
|
+
if (getTxIsOnProcess(err)) {
|
|
6070
|
+
console.log("reClaim done");
|
|
6071
|
+
} else {
|
|
6072
|
+
console.error("reClaim error:", err);
|
|
6073
|
+
const formatErr = formatErrFn(err);
|
|
6074
|
+
return reject(formatErr);
|
|
6075
|
+
}
|
|
6076
|
+
} finally {
|
|
6077
|
+
if (useStoreVersion && storeInitialized) {
|
|
6078
|
+
try {
|
|
6079
|
+
const txStoreClose = await zktlsProgram.methods.storeClose().accounts({ dataBuffer: dataBufferKey, user: userKey }).rpc();
|
|
6080
|
+
await waitForTransactionConfirmation(provider, txStoreClose);
|
|
6081
|
+
console.log("storeClose done");
|
|
6082
|
+
return resolve(signatureStr);
|
|
6083
|
+
} catch (closeErr) {
|
|
6084
|
+
console.error("Failed to close dataBuffer:", closeErr);
|
|
6085
|
+
}
|
|
6086
|
+
} else {
|
|
6087
|
+
return resolve(signatureStr);
|
|
6088
|
+
}
|
|
6089
|
+
}
|
|
6090
|
+
});
|
|
6091
|
+
}
|
|
6092
|
+
async function reSenderWithdraw({
|
|
6093
|
+
redEnvelopeProgram,
|
|
6094
|
+
userKey,
|
|
6095
|
+
provider,
|
|
6096
|
+
reId
|
|
6097
|
+
}) {
|
|
6098
|
+
return new Promise(async (resolve, reject) => {
|
|
6099
|
+
let tx;
|
|
6100
|
+
let signatureStr;
|
|
6101
|
+
try {
|
|
6102
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
6103
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
6104
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
6105
|
+
console.log("reRecord.tokenType:", reRecord.tokenType);
|
|
6106
|
+
let mint = null;
|
|
6107
|
+
let fromTokenAccount = null;
|
|
6108
|
+
let toTokenAccount = null;
|
|
6109
|
+
if (reRecord.tokenType == ERC20_TYPE) {
|
|
6110
|
+
console.log("reRecord.tokenAddress:", reRecord.tokenAddress);
|
|
6111
|
+
mint = reRecord.tokenAddress;
|
|
6112
|
+
fromTokenAccount = await getAssociatedTokenAddress(mint, redEnvelopePda, true);
|
|
6113
|
+
toTokenAccount = await getAssociatedTokenAddress(mint, userKey);
|
|
6114
|
+
}
|
|
6115
|
+
tx = await redEnvelopeProgram.methods.reSenderWithdraw(reId).accounts({
|
|
6116
|
+
state: redEnvelopePda,
|
|
6117
|
+
reRecord: reRecordPda,
|
|
6118
|
+
reSender: userKey,
|
|
6119
|
+
// SPL
|
|
6120
|
+
fromTokenAccount,
|
|
6121
|
+
toTokenAccount,
|
|
6122
|
+
mint
|
|
6123
|
+
}).transaction();
|
|
6124
|
+
tx.feePayer = userKey;
|
|
6125
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
6126
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
6127
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
6128
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
6129
|
+
if (isOnChain) {
|
|
6130
|
+
console.log("reSenderWithdraw done", signatureStr);
|
|
6131
|
+
return resolve(signatureStr);
|
|
6132
|
+
} else {
|
|
6133
|
+
const serializeSignedTx = signedTx.serialize();
|
|
6134
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
6135
|
+
console.log("reSenderWithdraw done", signatureStr);
|
|
6136
|
+
return resolve(signatureStr);
|
|
6137
|
+
}
|
|
6138
|
+
} catch (err) {
|
|
6139
|
+
if (getTxIsOnProcess(err)) {
|
|
6140
|
+
console.log("reSenderWithdraw done");
|
|
6141
|
+
return resolve(signatureStr);
|
|
6142
|
+
} else {
|
|
6143
|
+
console.error("reSenderWithdraw error:", err);
|
|
6144
|
+
const formatErr = formatErrFn(err);
|
|
6145
|
+
return reject(formatErr);
|
|
6146
|
+
}
|
|
6147
|
+
}
|
|
6148
|
+
});
|
|
6149
|
+
}
|
|
6150
|
+
async function getREInfo({
|
|
6151
|
+
redEnvelopeProgram,
|
|
6152
|
+
reId
|
|
6153
|
+
}) {
|
|
6154
|
+
return new Promise(async (resolve, reject) => {
|
|
6155
|
+
try {
|
|
6156
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
6157
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
6158
|
+
console.log("getREInfo done", reRecord);
|
|
6159
|
+
return resolve(reRecord);
|
|
6160
|
+
} catch (err) {
|
|
6161
|
+
console.error("getREInfo error:", err);
|
|
6162
|
+
const formatErr = formatErrFn(err);
|
|
6163
|
+
return reject(formatErr);
|
|
6164
|
+
}
|
|
6165
|
+
});
|
|
6166
|
+
}
|
|
6167
|
+
|
|
6168
|
+
// src/classes/FundOnSolanaForRedPacket.ts
|
|
6169
|
+
import { PublicKey as PublicKey4 } from "@solana/web3.js";
|
|
6170
|
+
var FundOnSolanaForRedPacket = class {
|
|
6171
|
+
fundContract;
|
|
6172
|
+
provider;
|
|
6173
|
+
constructor() {
|
|
6174
|
+
}
|
|
6175
|
+
async init(provider, chainId) {
|
|
6176
|
+
return new Promise(async (resolve, reject) => {
|
|
6177
|
+
try {
|
|
6178
|
+
this.fundContract = getProgram(redPacketIdl_default, provider);
|
|
6179
|
+
this.provider = provider;
|
|
6180
|
+
resolve("success");
|
|
6181
|
+
} catch (error) {
|
|
6182
|
+
return reject(error);
|
|
6183
|
+
}
|
|
6184
|
+
});
|
|
6185
|
+
}
|
|
6186
|
+
async fund(tokenInfo, sendParam) {
|
|
6187
|
+
return new Promise(async (resolve, reject) => {
|
|
6188
|
+
try {
|
|
6189
|
+
let decimals = 9;
|
|
6190
|
+
let amountOnChain;
|
|
6191
|
+
let formatTokenInfo = { ...tokenInfo };
|
|
6192
|
+
if (tokenInfo.tokenType === 1) {
|
|
6193
|
+
formatTokenInfo.tokenAddress = anchor3.web3.PublicKey.default;
|
|
6194
|
+
amountOnChain = toTokenAmount(sendParam.amount, decimals);
|
|
6195
|
+
} else if (tokenInfo.tokenType === 0) {
|
|
6196
|
+
decimals = await getTokenDecimals(tokenInfo.tokenAddress, this.provider.connection);
|
|
6197
|
+
amountOnChain = toTokenAmount(sendParam.amount, decimals);
|
|
6198
|
+
formatTokenInfo.tokenAddress = new PublicKey4(tokenInfo.tokenAddress);
|
|
6199
|
+
}
|
|
6200
|
+
const reSendParam = {
|
|
6201
|
+
...sendParam,
|
|
6202
|
+
amount: amountOnChain,
|
|
6203
|
+
checkContract: sendParam.checkContract || anchor3.web3.PublicKey.default
|
|
6204
|
+
};
|
|
6205
|
+
const result = await reSend({
|
|
6206
|
+
redEnvelopeProgram: this.fundContract,
|
|
6207
|
+
userKey: this.provider.publicKey,
|
|
6208
|
+
provider: this.provider,
|
|
6209
|
+
tipToken: formatTokenInfo,
|
|
6210
|
+
reSendParam
|
|
6211
|
+
});
|
|
6212
|
+
resolve(result);
|
|
6213
|
+
} catch (error) {
|
|
6214
|
+
return reject(error);
|
|
6215
|
+
}
|
|
6216
|
+
});
|
|
6217
|
+
}
|
|
6218
|
+
async claim(redPacketId, attestation) {
|
|
6219
|
+
return new Promise(async (resolve, reject) => {
|
|
6220
|
+
try {
|
|
6221
|
+
const zktlsProgram = getProgram(zktlsIdl_default, this.provider);
|
|
6222
|
+
const attObj = formatAttestation(attestation);
|
|
6223
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6224
|
+
const result = await reClaim({
|
|
6225
|
+
redEnvelopeProgram: this.fundContract,
|
|
6226
|
+
userKey: this.provider.publicKey,
|
|
6227
|
+
provider: this.provider,
|
|
6228
|
+
zktlsProgram,
|
|
6229
|
+
reId: formatReId,
|
|
6230
|
+
attObj
|
|
6231
|
+
});
|
|
6232
|
+
return resolve(result);
|
|
6233
|
+
} catch (error) {
|
|
6234
|
+
return reject(error);
|
|
6235
|
+
}
|
|
6236
|
+
});
|
|
6237
|
+
}
|
|
6238
|
+
async withdraw(redPacketId) {
|
|
6239
|
+
return new Promise(async (resolve, reject) => {
|
|
6240
|
+
try {
|
|
6241
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6242
|
+
const result = await reSenderWithdraw({
|
|
6243
|
+
redEnvelopeProgram: this.fundContract,
|
|
6244
|
+
userKey: this.provider.publicKey,
|
|
6245
|
+
provider: this.provider,
|
|
6246
|
+
reId: formatReId
|
|
6247
|
+
});
|
|
6248
|
+
return resolve(result);
|
|
6249
|
+
} catch (error) {
|
|
6250
|
+
return reject(error);
|
|
6251
|
+
}
|
|
6252
|
+
});
|
|
6253
|
+
}
|
|
6254
|
+
async getRedPacketInfo(redPacketId) {
|
|
6255
|
+
return new Promise(async (resolve, reject) => {
|
|
6256
|
+
try {
|
|
6257
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6258
|
+
const result = await getREInfo({ redEnvelopeProgram: this.fundContract, reId: formatReId });
|
|
6259
|
+
const redpacketInfo = { ...result, id: redPacketId };
|
|
6260
|
+
return resolve(redpacketInfo);
|
|
6261
|
+
} catch (error) {
|
|
6262
|
+
return reject(error);
|
|
6263
|
+
}
|
|
6264
|
+
});
|
|
6265
|
+
}
|
|
6266
|
+
async decodeReSendEvent(eventData) {
|
|
6267
|
+
return await decodeReSendEvent(eventData);
|
|
6268
|
+
}
|
|
6269
|
+
async decodeClaimEvent(eventData) {
|
|
6270
|
+
return await decodeClaimEvent(eventData);
|
|
6271
|
+
}
|
|
6272
|
+
};
|
|
6273
|
+
|
|
6274
|
+
// src/classes/ZktlsSdk.ts
|
|
6275
|
+
import { PrimusZKTLS } from "@primuslabs/zktls-js-sdk";
|
|
6276
|
+
var ZktlsSdk = class {
|
|
6277
|
+
zkTlsSdk;
|
|
6278
|
+
constructor() {
|
|
6279
|
+
}
|
|
6280
|
+
getZkTlsSdk() {
|
|
6281
|
+
return this.zkTlsSdk;
|
|
6282
|
+
}
|
|
6283
|
+
async init(appId) {
|
|
6284
|
+
return new Promise(async (resolve, reject) => {
|
|
6285
|
+
try {
|
|
6286
|
+
this.zkTlsSdk = new PrimusZKTLS();
|
|
6287
|
+
let platformDevice = "pc";
|
|
6288
|
+
const isIpad = () => {
|
|
6289
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
6290
|
+
const isTabletSize = window.innerWidth > 768 && window.innerWidth < 1366;
|
|
6291
|
+
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
6292
|
+
};
|
|
6293
|
+
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
6294
|
+
platformDevice = "android";
|
|
6295
|
+
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
6296
|
+
platformDevice = "ios";
|
|
6297
|
+
}
|
|
6298
|
+
console.log("init appId", appId, platformDevice);
|
|
6299
|
+
const extensionVersion = await this.zkTlsSdk.init(
|
|
6300
|
+
appId,
|
|
6301
|
+
"",
|
|
6302
|
+
{ platform: platformDevice }
|
|
6303
|
+
);
|
|
6304
|
+
resolve(extensionVersion);
|
|
6305
|
+
} catch (error) {
|
|
6306
|
+
return reject(error);
|
|
6307
|
+
}
|
|
6308
|
+
});
|
|
6309
|
+
}
|
|
6310
|
+
async attest(attestParams, signFn, backUrl) {
|
|
6311
|
+
return new Promise(async (resolve, reject) => {
|
|
6312
|
+
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
6313
|
+
const { socialPlatform, userIdentifier, address } = attestParams;
|
|
6314
|
+
const { id: templateId, field } = DATASOURCETEMPLATESMAP[socialPlatform];
|
|
6315
|
+
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
6316
|
+
templateId,
|
|
6317
|
+
address
|
|
6318
|
+
);
|
|
6319
|
+
if (backUrl) {
|
|
6320
|
+
attRequest.setBackUrl(backUrl);
|
|
6321
|
+
}
|
|
6322
|
+
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
6323
|
+
attRequest.setAttConditions([
|
|
6324
|
+
[
|
|
6325
|
+
{
|
|
6326
|
+
field,
|
|
6327
|
+
op: "STREQ",
|
|
6328
|
+
value: userIdentifier
|
|
6329
|
+
}
|
|
6330
|
+
]
|
|
6331
|
+
]);
|
|
6332
|
+
const signParams = attRequest.toJsonString();
|
|
6333
|
+
const signature = await signFn(signParams);
|
|
6334
|
+
if (!signature) {
|
|
6335
|
+
return reject(`appSignature is empty!`);
|
|
6336
|
+
}
|
|
6337
|
+
try {
|
|
6338
|
+
const formatAttestParams = {
|
|
6339
|
+
attRequest: {
|
|
6340
|
+
...JSON.parse(signParams)
|
|
6341
|
+
},
|
|
6342
|
+
appSignature: signature
|
|
6343
|
+
};
|
|
6344
|
+
const attestation = await this.zkTlsSdk.startAttestation(
|
|
6345
|
+
JSON.stringify(formatAttestParams)
|
|
6346
|
+
);
|
|
6347
|
+
return resolve(attestation);
|
|
6348
|
+
} catch (error) {
|
|
6349
|
+
return reject(error);
|
|
6350
|
+
}
|
|
6351
|
+
});
|
|
6352
|
+
}
|
|
6353
|
+
async attestCommon(attestParams) {
|
|
6354
|
+
const { templateId, address, signFn, conditions, additionParams, backUrl } = attestParams;
|
|
6355
|
+
return new Promise(async (resolve, reject) => {
|
|
6356
|
+
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
6357
|
+
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
6358
|
+
templateId,
|
|
6359
|
+
address
|
|
6360
|
+
);
|
|
6361
|
+
if (backUrl) {
|
|
6362
|
+
attRequest.setBackUrl(backUrl);
|
|
6363
|
+
}
|
|
6364
|
+
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
6365
|
+
if (conditions) {
|
|
6366
|
+
attRequest.setAttConditions(conditions);
|
|
6367
|
+
}
|
|
6368
|
+
if (additionParams) {
|
|
6369
|
+
console.log("setAdditionParams--", additionParams);
|
|
6370
|
+
attRequest.setAdditionParams(additionParams);
|
|
6371
|
+
}
|
|
6372
|
+
const signParams = attRequest.toJsonString();
|
|
6373
|
+
const signature = await signFn(signParams);
|
|
6374
|
+
if (!signature) {
|
|
6375
|
+
return reject(`appSignature is empty!`);
|
|
6376
|
+
}
|
|
6377
|
+
try {
|
|
6378
|
+
const formatAttestParams = {
|
|
6379
|
+
attRequest: {
|
|
6380
|
+
...JSON.parse(signParams)
|
|
6381
|
+
},
|
|
6382
|
+
appSignature: signature
|
|
6383
|
+
};
|
|
6384
|
+
const attestation = await this.zkTlsSdk.startAttestation(
|
|
6385
|
+
JSON.stringify(formatAttestParams)
|
|
6386
|
+
);
|
|
6387
|
+
return resolve(attestation);
|
|
6388
|
+
} catch (error) {
|
|
6389
|
+
return reject(error);
|
|
6390
|
+
}
|
|
6391
|
+
});
|
|
6392
|
+
}
|
|
6393
|
+
};
|
|
6394
|
+
|
|
6395
|
+
// src/index.ts
|
|
6396
|
+
console.log("SUPPORTEDCHAINIDS444", SUPPORTEDCHAINIDS);
|
|
6397
|
+
var PrimusFund = class {
|
|
6398
|
+
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
6399
|
+
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
6400
|
+
provider;
|
|
6401
|
+
_fund;
|
|
6402
|
+
_fundForRedPacket;
|
|
6403
|
+
_fundOnSolanaForRedPacket;
|
|
6404
|
+
// TODO
|
|
6405
|
+
_zkTlsSdk;
|
|
6406
|
+
static utils = {
|
|
6407
|
+
decodeReSendEvent,
|
|
6408
|
+
decodeClaimEvent
|
|
6409
|
+
};
|
|
6410
|
+
async init(provider, chainId, appId) {
|
|
6411
|
+
return new Promise(async (resolve, reject) => {
|
|
6412
|
+
try {
|
|
6413
|
+
if (!this.supportedChainIds.includes(chainId) && !SUPPORTEDSOLANACHAINIDS.includes(chainId)) {
|
|
6414
|
+
return reject("chainId is not supported");
|
|
6415
|
+
}
|
|
6416
|
+
if (this.supportedChainIds.includes(chainId)) {
|
|
6417
|
+
let formatProvider;
|
|
6418
|
+
let signer;
|
|
6419
|
+
if (provider instanceof ethers5.providers.JsonRpcProvider) {
|
|
6420
|
+
formatProvider = provider;
|
|
6421
|
+
} else {
|
|
6422
|
+
formatProvider = new ethers5.providers.Web3Provider(provider);
|
|
6423
|
+
signer = formatProvider.getSigner();
|
|
6424
|
+
}
|
|
6425
|
+
await formatProvider.ready;
|
|
6426
|
+
const network = await formatProvider.getNetwork();
|
|
6427
|
+
const providerChainId = network.chainId;
|
|
6428
|
+
console.log("init provider", provider, network);
|
|
6429
|
+
console.log("init providerChainId", providerChainId, chainId);
|
|
6430
|
+
if (providerChainId !== chainId) {
|
|
6431
|
+
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
6432
|
+
}
|
|
6433
|
+
this.provider = signer ?? formatProvider;
|
|
6434
|
+
this._fund = new Fund();
|
|
6435
|
+
await this._fund.init(this.provider, chainId);
|
|
6436
|
+
this._fundForRedPacket = new FundForRedPacket();
|
|
6437
|
+
await this._fundForRedPacket.init(this.provider, chainId);
|
|
6438
|
+
} else if (SUPPORTEDSOLANACHAINIDS.includes(chainId)) {
|
|
6439
|
+
this.provider = provider;
|
|
6440
|
+
this._fundOnSolanaForRedPacket = new FundOnSolanaForRedPacket();
|
|
6441
|
+
this._fundOnSolanaForRedPacket.init(provider, chainId);
|
|
6442
|
+
}
|
|
6443
|
+
if (appId) {
|
|
6444
|
+
this._zkTlsSdk = new ZktlsSdk();
|
|
6445
|
+
await this._zkTlsSdk.init(appId);
|
|
6446
|
+
}
|
|
6447
|
+
return resolve(true);
|
|
6448
|
+
} catch (error) {
|
|
6449
|
+
return reject(error);
|
|
6450
|
+
}
|
|
6451
|
+
});
|
|
6452
|
+
}
|
|
6453
|
+
async fund(fundParam) {
|
|
6454
|
+
return new Promise(async (resolve, reject) => {
|
|
6455
|
+
try {
|
|
6456
|
+
const { tokenInfo, recipientInfos } = fundParam;
|
|
6457
|
+
if (!recipientInfos || recipientInfos.length === 0) {
|
|
6458
|
+
return reject("recipientInfos is empty");
|
|
6459
|
+
}
|
|
6460
|
+
const hasUnsupportedSocialPlatforms = recipientInfos.some((i) => !this.supportedSocialPlatforms.includes(i.socialPlatform.toLowerCase()));
|
|
6461
|
+
if (hasUnsupportedSocialPlatforms) {
|
|
6462
|
+
return reject("socialPlatform is not supported");
|
|
6463
|
+
}
|
|
6464
|
+
if (tokenInfo.tokenType === 1) {
|
|
6465
|
+
tokenInfo.tokenAddress = ethers5.constants.AddressZero;
|
|
6466
|
+
}
|
|
6467
|
+
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
6468
|
+
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
6469
|
+
let formatUserIdentifier = i.userIdentifier;
|
|
6470
|
+
if (i.socialPlatform === "x" && i.userIdentifier.startsWith("@")) {
|
|
6471
|
+
formatUserIdentifier = i.userIdentifier.slice(1);
|
|
6472
|
+
}
|
|
6473
|
+
return {
|
|
2726
6474
|
nftIds: i.nftIds ?? [],
|
|
2727
6475
|
socialPlatform: formatSocialPlatform,
|
|
2728
6476
|
userIdentifier: formatUserIdentifier,
|
|
@@ -2878,25 +6626,31 @@ var PrimusFund = class {
|
|
|
2878
6626
|
}
|
|
2879
6627
|
});
|
|
2880
6628
|
}
|
|
6629
|
+
_formatGetFundRecordsParams(queryList) {
|
|
6630
|
+
const socialPlatforms = [];
|
|
6631
|
+
const userIdentifiers = [];
|
|
6632
|
+
for (let i = 0; i < queryList.length; i++) {
|
|
6633
|
+
socialPlatforms[i] = queryList[i].socialPlatform.toLowerCase();
|
|
6634
|
+
userIdentifiers[i] = queryList[i].userIdentifier;
|
|
6635
|
+
if (socialPlatforms[i] === "x" && userIdentifiers[i].startsWith("@")) {
|
|
6636
|
+
queryList[i].userIdentifier = queryList[i].userIdentifier.slice(1);
|
|
6637
|
+
}
|
|
6638
|
+
}
|
|
6639
|
+
return queryList;
|
|
6640
|
+
}
|
|
2881
6641
|
async getFundRecords(getFundRecordsParams) {
|
|
2882
|
-
|
|
6642
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
6643
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
6644
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
2883
6645
|
return new Promise(async (resolve, reject) => {
|
|
2884
6646
|
if (!queryList || queryList?.length === 0) {
|
|
2885
6647
|
const error = new Error("getFundRecordsParams is empty");
|
|
2886
6648
|
return reject(error);
|
|
2887
6649
|
}
|
|
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) {
|
|
6650
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
2898
6651
|
return reject(`getFundRecordsParams is wrong`);
|
|
2899
6652
|
}
|
|
6653
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
2900
6654
|
try {
|
|
2901
6655
|
const result = await this._fund?.getTipRecords(queryList);
|
|
2902
6656
|
resolve(result);
|
|
@@ -2905,6 +6659,69 @@ var PrimusFund = class {
|
|
|
2905
6659
|
}
|
|
2906
6660
|
});
|
|
2907
6661
|
}
|
|
6662
|
+
async getFundRecordsNativeAmount(getFundRecordsParams) {
|
|
6663
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
6664
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
6665
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
6666
|
+
return new Promise(async (resolve, reject) => {
|
|
6667
|
+
if (!queryList || queryList?.length === 0) {
|
|
6668
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
6669
|
+
return reject(error);
|
|
6670
|
+
}
|
|
6671
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
6672
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
6673
|
+
}
|
|
6674
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
6675
|
+
try {
|
|
6676
|
+
const result = await this._fund?.getTipRecordsNativeAmount(queryList);
|
|
6677
|
+
resolve(result);
|
|
6678
|
+
} catch (error) {
|
|
6679
|
+
return reject(error);
|
|
6680
|
+
}
|
|
6681
|
+
});
|
|
6682
|
+
}
|
|
6683
|
+
async getFundRecordsLen(getFundRecordsParams) {
|
|
6684
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
6685
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
6686
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
6687
|
+
return new Promise(async (resolve, reject) => {
|
|
6688
|
+
if (!queryList || queryList?.length === 0) {
|
|
6689
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
6690
|
+
return reject(error);
|
|
6691
|
+
}
|
|
6692
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
6693
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
6694
|
+
}
|
|
6695
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
6696
|
+
try {
|
|
6697
|
+
const result = await this._fund?.getTipRecordsLength(queryList);
|
|
6698
|
+
resolve(result);
|
|
6699
|
+
} catch (error) {
|
|
6700
|
+
return reject(error);
|
|
6701
|
+
}
|
|
6702
|
+
});
|
|
6703
|
+
}
|
|
6704
|
+
async getFundRecordsPaginated(getFundRecordsParams, pageNum, pageSize) {
|
|
6705
|
+
let queryList = Array.isArray(getFundRecordsParams) ? getFundRecordsParams : [getFundRecordsParams];
|
|
6706
|
+
const socialPlatformList = queryList.map((i) => i.socialPlatform);
|
|
6707
|
+
const userIdentifierList = queryList.map((i) => i.userIdentifier);
|
|
6708
|
+
return new Promise(async (resolve, reject) => {
|
|
6709
|
+
if (!queryList || queryList?.length === 0) {
|
|
6710
|
+
const error = new Error("getFundRecordsParams is empty");
|
|
6711
|
+
return reject(error);
|
|
6712
|
+
}
|
|
6713
|
+
if (socialPlatformList.length !== userIdentifierList.length) {
|
|
6714
|
+
return reject(`getFundRecordsParams is wrong`);
|
|
6715
|
+
}
|
|
6716
|
+
queryList = this._formatGetFundRecordsParams(queryList);
|
|
6717
|
+
try {
|
|
6718
|
+
const result = await this._fund?.getTipRecordsPaginated(queryList, pageNum, pageSize);
|
|
6719
|
+
resolve(result);
|
|
6720
|
+
} catch (error) {
|
|
6721
|
+
return reject(error);
|
|
6722
|
+
}
|
|
6723
|
+
});
|
|
6724
|
+
}
|
|
2908
6725
|
async fundForRedPacket(fundParam) {
|
|
2909
6726
|
return new Promise(async (resolve, reject) => {
|
|
2910
6727
|
try {
|
|
@@ -2937,10 +6754,15 @@ var PrimusFund = class {
|
|
|
2937
6754
|
}
|
|
2938
6755
|
});
|
|
2939
6756
|
}
|
|
2940
|
-
async getRedPacketInfo(redPacketId) {
|
|
6757
|
+
async getRedPacketInfo(redPacketId, chainId) {
|
|
2941
6758
|
return new Promise(async (resolve, reject) => {
|
|
2942
6759
|
try {
|
|
2943
|
-
|
|
6760
|
+
let result;
|
|
6761
|
+
if (chainId && typeof chainId === "string") {
|
|
6762
|
+
result = await this._fundOnSolanaForRedPacket?.getRedPacketInfo(redPacketId);
|
|
6763
|
+
} else {
|
|
6764
|
+
result = await this._fundForRedPacket?.getRedPacketInfo(redPacketId);
|
|
6765
|
+
}
|
|
2944
6766
|
return resolve(result);
|
|
2945
6767
|
} catch (error) {
|
|
2946
6768
|
return reject(error);
|
|
@@ -2978,6 +6800,52 @@ var PrimusFund = class {
|
|
|
2978
6800
|
}
|
|
2979
6801
|
});
|
|
2980
6802
|
}
|
|
6803
|
+
async fundonSolanaForRedPacket(fundParam) {
|
|
6804
|
+
return new Promise(async (resolve, reject) => {
|
|
6805
|
+
try {
|
|
6806
|
+
const { tokenInfo, sendParam } = fundParam;
|
|
6807
|
+
const result = await this._fundOnSolanaForRedPacket?.fund(tokenInfo, sendParam);
|
|
6808
|
+
return resolve(result);
|
|
6809
|
+
} catch (error) {
|
|
6810
|
+
return reject(error);
|
|
6811
|
+
}
|
|
6812
|
+
});
|
|
6813
|
+
}
|
|
6814
|
+
async claimOnSolanaForRedPacket(redPacketId, attestation) {
|
|
6815
|
+
return new Promise(async (resolve, reject) => {
|
|
6816
|
+
try {
|
|
6817
|
+
let formatAttestation2 = { ...attestation, responseResolve: attestation.reponseResolve };
|
|
6818
|
+
delete formatAttestation2.reponseResolve;
|
|
6819
|
+
const result = await this._fundOnSolanaForRedPacket?.claim(redPacketId, formatAttestation2);
|
|
6820
|
+
return resolve(result);
|
|
6821
|
+
} catch (error) {
|
|
6822
|
+
return reject(error);
|
|
6823
|
+
}
|
|
6824
|
+
});
|
|
6825
|
+
}
|
|
6826
|
+
async withdrawOnSolanaForRedPacket(redPacketId) {
|
|
6827
|
+
return new Promise(async (resolve, reject) => {
|
|
6828
|
+
try {
|
|
6829
|
+
const result = await this._fundOnSolanaForRedPacket?.withdraw(redPacketId);
|
|
6830
|
+
return resolve(result);
|
|
6831
|
+
} catch (error) {
|
|
6832
|
+
return reject(error);
|
|
6833
|
+
}
|
|
6834
|
+
});
|
|
6835
|
+
}
|
|
6836
|
+
// async testReSend(params: any) {
|
|
6837
|
+
// const p = getProgram(redPacketIdl, params.provider)
|
|
6838
|
+
// await testReSend({ redEnvelopeProgram: p, ...params })
|
|
6839
|
+
// }
|
|
6840
|
+
// async testReClaim(params: any) {
|
|
6841
|
+
// const resPacketP = getProgram(redPacketIdl, params.provider)
|
|
6842
|
+
// const zktlsP = getProgram(zktlsIdl, params.provider)
|
|
6843
|
+
// await testReClaim({ redEnvelopeProgram: resPacketP, zktlsProgram: zktlsP, ...params })
|
|
6844
|
+
// }
|
|
6845
|
+
// async testReSenderWithdraw(params: any) {
|
|
6846
|
+
// const resPacketP = getProgram(redPacketIdl, params.provider)
|
|
6847
|
+
// await testReSenderWithdraw({ redEnvelopeProgram: resPacketP, ...params })
|
|
6848
|
+
// }
|
|
2981
6849
|
};
|
|
2982
6850
|
export {
|
|
2983
6851
|
PrimusFund
|