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