@primuslabs/fund-js-sdk 0.1.15 → 0.1.17
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 +3725 -219
- package/dist/index.mjs +3719 -216
- 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 {
|
|
@@ -2741,235 +2787,3644 @@ var FundForRedPacket = class {
|
|
|
2741
2787
|
}
|
|
2742
2788
|
};
|
|
2743
2789
|
|
|
2744
|
-
// src/classes/
|
|
2745
|
-
var
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
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
|
+
var getTokenProgramType = async (mintAddress, connection) => {
|
|
2813
|
+
if (!connection) {
|
|
2814
|
+
return "";
|
|
2749
2815
|
}
|
|
2750
|
-
|
|
2751
|
-
|
|
2816
|
+
const mintPubkey = new import_web3.PublicKey(mintAddress);
|
|
2817
|
+
const accountInfo = await connection.getAccountInfo(mintPubkey);
|
|
2818
|
+
if (!accountInfo) {
|
|
2819
|
+
throw new Error("Mint account not found");
|
|
2752
2820
|
}
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
2762
|
-
};
|
|
2763
|
-
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
2764
|
-
platformDevice = "android";
|
|
2765
|
-
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
2766
|
-
platformDevice = "ios";
|
|
2767
|
-
}
|
|
2768
|
-
console.log("init appId", appId, platformDevice);
|
|
2769
|
-
const extensionVersion = await this.zkTlsSdk.init(
|
|
2770
|
-
appId,
|
|
2771
|
-
"",
|
|
2772
|
-
{ platform: platformDevice }
|
|
2773
|
-
);
|
|
2774
|
-
resolve(extensionVersion);
|
|
2775
|
-
} catch (error) {
|
|
2776
|
-
return reject(error);
|
|
2777
|
-
}
|
|
2778
|
-
});
|
|
2821
|
+
const TOKEN_PROGRAM_ID2 = new import_web3.PublicKey("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
|
|
2822
|
+
const TOKEN_2022_PROGRAM_ID3 = new import_web3.PublicKey("TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb");
|
|
2823
|
+
if (accountInfo.owner.equals(TOKEN_PROGRAM_ID2)) {
|
|
2824
|
+
return "Token";
|
|
2825
|
+
} else if (accountInfo.owner.equals(TOKEN_2022_PROGRAM_ID3)) {
|
|
2826
|
+
return "Token-2022";
|
|
2827
|
+
} else {
|
|
2828
|
+
return `Unknown Program: ${accountInfo.owner.toBase58()}`;
|
|
2779
2829
|
}
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
|
|
2790
|
-
attRequest.setBackUrl(backUrl);
|
|
2791
|
-
}
|
|
2792
|
-
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
2793
|
-
attRequest.setAttConditions([
|
|
2794
|
-
[
|
|
2795
|
-
{
|
|
2796
|
-
field,
|
|
2797
|
-
op: "STREQ",
|
|
2798
|
-
value: userIdentifier
|
|
2799
|
-
}
|
|
2800
|
-
]
|
|
2801
|
-
]);
|
|
2802
|
-
const signParams = attRequest.toJsonString();
|
|
2803
|
-
const signature = await signFn(signParams);
|
|
2804
|
-
if (!signature) {
|
|
2805
|
-
return reject(`appSignature is empty!`);
|
|
2806
|
-
}
|
|
2807
|
-
try {
|
|
2808
|
-
const formatAttestParams = {
|
|
2809
|
-
attRequest: {
|
|
2810
|
-
...JSON.parse(signParams)
|
|
2811
|
-
},
|
|
2812
|
-
appSignature: signature
|
|
2813
|
-
};
|
|
2814
|
-
const attestation = await this.zkTlsSdk.startAttestation(
|
|
2815
|
-
JSON.stringify(formatAttestParams)
|
|
2816
|
-
);
|
|
2817
|
-
return resolve(attestation);
|
|
2818
|
-
} catch (error) {
|
|
2819
|
-
return reject(error);
|
|
2820
|
-
}
|
|
2821
|
-
});
|
|
2830
|
+
};
|
|
2831
|
+
async function getTokenDecimals(mintAddress, connection) {
|
|
2832
|
+
const mintPubkey = new import_web3.PublicKey(mintAddress);
|
|
2833
|
+
const tokenProgramType = await getTokenProgramType(mintAddress, connection);
|
|
2834
|
+
if (tokenProgramType === "Token-2022") {
|
|
2835
|
+
const mintInfo = await (0, import_spl_token.getMint)(connection, mintPubkey, "confirmed", import_spl_token.TOKEN_2022_PROGRAM_ID);
|
|
2836
|
+
return mintInfo.decimals;
|
|
2837
|
+
} else if (tokenProgramType === "Token") {
|
|
2838
|
+
const mintInfo = await (0, import_spl_token.getMint)(connection, mintPubkey);
|
|
2839
|
+
return mintInfo.decimals;
|
|
2822
2840
|
}
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
|
|
2854
|
-
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
2841
|
+
}
|
|
2842
|
+
var hexToUint8Array = (hex) => {
|
|
2843
|
+
let hexStr = hex.startsWith("0x") ? hex.slice(2) : hex;
|
|
2844
|
+
return Buffer.from(hexStr.toLowerCase(), "hex");
|
|
2845
|
+
};
|
|
2846
|
+
function formatAttestation(attestation) {
|
|
2847
|
+
const {
|
|
2848
|
+
additionParams,
|
|
2849
|
+
attConditions,
|
|
2850
|
+
attestors,
|
|
2851
|
+
data,
|
|
2852
|
+
recipient,
|
|
2853
|
+
responseResolve,
|
|
2854
|
+
request,
|
|
2855
|
+
signatures,
|
|
2856
|
+
timestamp
|
|
2857
|
+
} = attestation;
|
|
2858
|
+
const formatAttestors = attestors.map(({ attestorAddr, url }) => {
|
|
2859
|
+
return {
|
|
2860
|
+
attestorAddr: hexToUint8Array(attestorAddr),
|
|
2861
|
+
url
|
|
2862
|
+
};
|
|
2863
|
+
});
|
|
2864
|
+
const formatSignatures = signatures.map((s) => hexToUint8Array(s));
|
|
2865
|
+
const formatAtt = {
|
|
2866
|
+
additionParams,
|
|
2867
|
+
attConditions,
|
|
2868
|
+
attestors: formatAttestors,
|
|
2869
|
+
data,
|
|
2870
|
+
recipient: new import_web3.PublicKey(recipient).toBytes(),
|
|
2871
|
+
responseResolve,
|
|
2872
|
+
request,
|
|
2873
|
+
signatures: formatSignatures,
|
|
2874
|
+
timestamp: new anchor.BN(timestamp)
|
|
2875
|
+
};
|
|
2876
|
+
return formatAtt;
|
|
2877
|
+
}
|
|
2878
|
+
async function decodeReSendEvent(eventData) {
|
|
2879
|
+
const eventBuffer = Buffer.from(eventData, "base64");
|
|
2880
|
+
const raw = eventBuffer.slice(8);
|
|
2881
|
+
console.log("eventBuffer first 8 bytes:", Array.from(eventBuffer.slice(0, 8)));
|
|
2882
|
+
class CheckParams {
|
|
2883
|
+
check_type;
|
|
2884
|
+
params;
|
|
2885
|
+
constructor(fields) {
|
|
2886
|
+
this.check_type = fields.check_type;
|
|
2887
|
+
this.params = fields.params;
|
|
2888
|
+
}
|
|
2889
|
+
}
|
|
2890
|
+
class RESendEvent {
|
|
2891
|
+
id;
|
|
2892
|
+
re_sender;
|
|
2893
|
+
token_type;
|
|
2894
|
+
token_address;
|
|
2895
|
+
amount;
|
|
2896
|
+
re_type;
|
|
2897
|
+
number;
|
|
2898
|
+
timestamp;
|
|
2899
|
+
check_params;
|
|
2900
|
+
empty_ratio;
|
|
2901
|
+
constructor(fields) {
|
|
2902
|
+
this.id = fields.id;
|
|
2903
|
+
this.re_sender = fields.re_sender;
|
|
2904
|
+
this.token_type = fields.token_type;
|
|
2905
|
+
this.token_address = fields.token_address;
|
|
2906
|
+
this.amount = fields.amount;
|
|
2907
|
+
this.re_type = fields.re_type;
|
|
2908
|
+
this.number = fields.number;
|
|
2909
|
+
this.timestamp = fields.timestamp;
|
|
2910
|
+
this.check_params = new CheckParams(fields.check_params);
|
|
2911
|
+
this.empty_ratio = fields.empty_ratio;
|
|
2912
|
+
}
|
|
2913
|
+
}
|
|
2914
|
+
const CheckParamsJson = {
|
|
2915
|
+
"kind": "struct",
|
|
2916
|
+
"fields": [
|
|
2917
|
+
["check_type", "u32"],
|
|
2918
|
+
["params", "string"]
|
|
2919
|
+
]
|
|
2920
|
+
};
|
|
2921
|
+
const RESendEventJson = {
|
|
2922
|
+
"kind": "struct",
|
|
2923
|
+
"fields": [
|
|
2924
|
+
["id", [32]],
|
|
2925
|
+
["re_sender", [32]],
|
|
2926
|
+
["token_type", "u32"],
|
|
2927
|
+
["token_address", [32]],
|
|
2928
|
+
["amount", "u64"],
|
|
2929
|
+
["re_type", "u32"],
|
|
2930
|
+
["number", "u32"],
|
|
2931
|
+
["timestamp", "u64"],
|
|
2932
|
+
["check_params", CheckParams],
|
|
2933
|
+
["empty_ratio", "u8"]
|
|
2934
|
+
]
|
|
2935
|
+
};
|
|
2936
|
+
const schema2 = /* @__PURE__ */ new Map([
|
|
2937
|
+
[CheckParams, CheckParamsJson],
|
|
2938
|
+
[RESendEvent, RESendEventJson]
|
|
2939
|
+
]);
|
|
2940
|
+
const res = deserialize(schema2, RESendEvent, raw);
|
|
2941
|
+
console.log("decodeReSendEvent=", res);
|
|
2942
|
+
return res;
|
|
2943
|
+
}
|
|
2944
|
+
async function decodeClaimEvent(eventData) {
|
|
2945
|
+
const eventBuffer = Buffer.from(eventData, "base64");
|
|
2946
|
+
const raw = eventBuffer.slice(8);
|
|
2947
|
+
console.log("eventBuffer first 8 bytes:", Array.from(eventBuffer.slice(0, 8)));
|
|
2948
|
+
class REClaimEvent {
|
|
2949
|
+
id;
|
|
2950
|
+
user;
|
|
2951
|
+
user_id;
|
|
2952
|
+
amount;
|
|
2953
|
+
index;
|
|
2954
|
+
timestamp;
|
|
2955
|
+
token_address;
|
|
2956
|
+
constructor(fields) {
|
|
2957
|
+
this.id = fields.id;
|
|
2958
|
+
this.user = fields.user;
|
|
2959
|
+
this.user_id = fields.user_id;
|
|
2960
|
+
this.amount = fields.amount;
|
|
2961
|
+
this.index = fields.index;
|
|
2962
|
+
this.timestamp = fields.timestamp;
|
|
2963
|
+
this.token_address = fields.token_address;
|
|
2964
|
+
}
|
|
2965
|
+
}
|
|
2966
|
+
const REClaimEventJson = {
|
|
2967
|
+
"kind": "struct",
|
|
2968
|
+
"fields": [
|
|
2969
|
+
["id", [32]],
|
|
2970
|
+
["user", [32]],
|
|
2971
|
+
["user_id", "string"],
|
|
2972
|
+
["amount", "u64"],
|
|
2973
|
+
["index", "u32"],
|
|
2974
|
+
["timestamp", "u64"],
|
|
2975
|
+
["token_address", [32]]
|
|
2976
|
+
]
|
|
2977
|
+
};
|
|
2978
|
+
const schema2 = /* @__PURE__ */ new Map([
|
|
2979
|
+
[REClaimEvent, REClaimEventJson]
|
|
2980
|
+
]);
|
|
2981
|
+
const res = deserialize(schema2, REClaimEvent, raw);
|
|
2982
|
+
console.log("res=", res);
|
|
2983
|
+
console.log("res=", new import_web3.PublicKey(res.user).toBase58());
|
|
2984
|
+
return res;
|
|
2985
|
+
}
|
|
2986
|
+
var getTxSigStrFromTx = (signedTx) => {
|
|
2987
|
+
if (signedTx?.signatures[0] && signedTx?.signatures[0].signature) {
|
|
2988
|
+
const signatureBytes = signedTx.signatures[0].signature;
|
|
2989
|
+
const signatureStr = (0, import_micro_base58.encode)(signatureBytes);
|
|
2990
|
+
return signatureStr;
|
|
2862
2991
|
}
|
|
2992
|
+
return "";
|
|
2863
2993
|
};
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
_fundForRedPacket;
|
|
2873
|
-
_zkTlsSdk;
|
|
2874
|
-
async init(provider, chainId, appId) {
|
|
2875
|
-
return new Promise(async (resolve, reject) => {
|
|
2876
|
-
try {
|
|
2877
|
-
if (!this.supportedChainIds.includes(chainId)) {
|
|
2878
|
-
return reject("chainId is not supported");
|
|
2879
|
-
}
|
|
2880
|
-
let formatProvider;
|
|
2881
|
-
let signer;
|
|
2882
|
-
if (provider instanceof import_ethers5.ethers.providers.JsonRpcProvider) {
|
|
2883
|
-
formatProvider = provider;
|
|
2884
|
-
} else {
|
|
2885
|
-
formatProvider = new import_ethers5.ethers.providers.Web3Provider(provider);
|
|
2886
|
-
signer = formatProvider.getSigner();
|
|
2887
|
-
}
|
|
2888
|
-
await formatProvider.ready;
|
|
2889
|
-
const network = await formatProvider.getNetwork();
|
|
2890
|
-
const providerChainId = network.chainId;
|
|
2891
|
-
console.log("init provider", provider, network);
|
|
2892
|
-
console.log("init providerChainId", providerChainId, chainId);
|
|
2893
|
-
if (providerChainId !== chainId) {
|
|
2894
|
-
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
2895
|
-
}
|
|
2896
|
-
this.provider = signer ?? formatProvider;
|
|
2897
|
-
this._fund = new Fund();
|
|
2898
|
-
const result = await this._fund.init(this.provider, chainId);
|
|
2899
|
-
this._fundForRedPacket = new FundForRedPacket();
|
|
2900
|
-
await this._fundForRedPacket.init(this.provider, chainId);
|
|
2901
|
-
if (appId) {
|
|
2902
|
-
this._zkTlsSdk = new ZktlsSdk();
|
|
2903
|
-
await this._zkTlsSdk.init(appId);
|
|
2904
|
-
}
|
|
2905
|
-
return resolve(result);
|
|
2906
|
-
} catch (error) {
|
|
2907
|
-
return reject(error);
|
|
2908
|
-
}
|
|
2909
|
-
});
|
|
2994
|
+
var getTxIsOnChain = async (signatureStr, connection) => {
|
|
2995
|
+
if (signatureStr) {
|
|
2996
|
+
const { value } = await connection.getSignatureStatus(signatureStr);
|
|
2997
|
+
if (value && value.confirmationStatus) {
|
|
2998
|
+
return true;
|
|
2999
|
+
} else {
|
|
3000
|
+
return false;
|
|
3001
|
+
}
|
|
2910
3002
|
}
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
3003
|
+
return false;
|
|
3004
|
+
};
|
|
3005
|
+
var getTxIsOnProcess = (err) => {
|
|
3006
|
+
const strArr = ["This transaction has already been processed"];
|
|
3007
|
+
const curErrorStrArr = getErrArrFn(err);
|
|
3008
|
+
const isOnProcess = hasErrorFlagFn(curErrorStrArr, strArr);
|
|
3009
|
+
return isOnProcess;
|
|
3010
|
+
};
|
|
3011
|
+
|
|
3012
|
+
// src/config/redPacketIdl.json
|
|
3013
|
+
var redPacketIdl_default = {
|
|
3014
|
+
address: "EmK8RSeeHBxb1iZUipon2QqvatcuJyJZM4cpTtSAYzud",
|
|
3015
|
+
metadata: {
|
|
3016
|
+
name: "primus_red_envelope",
|
|
3017
|
+
version: "0.1.0",
|
|
3018
|
+
spec: "0.1.0",
|
|
3019
|
+
description: "Created with Anchor"
|
|
3020
|
+
},
|
|
3021
|
+
instructions: [
|
|
3022
|
+
{
|
|
3023
|
+
name: "initialize",
|
|
3024
|
+
discriminator: [
|
|
3025
|
+
175,
|
|
3026
|
+
175,
|
|
3027
|
+
109,
|
|
3028
|
+
31,
|
|
3029
|
+
13,
|
|
3030
|
+
152,
|
|
3031
|
+
155,
|
|
3032
|
+
237
|
|
3033
|
+
],
|
|
3034
|
+
accounts: [
|
|
3035
|
+
{
|
|
3036
|
+
name: "state",
|
|
3037
|
+
writable: true,
|
|
3038
|
+
pda: {
|
|
3039
|
+
seeds: [
|
|
3040
|
+
{
|
|
3041
|
+
kind: "const",
|
|
3042
|
+
value: [
|
|
3043
|
+
114,
|
|
3044
|
+
101,
|
|
3045
|
+
100,
|
|
3046
|
+
95,
|
|
3047
|
+
101,
|
|
3048
|
+
110,
|
|
3049
|
+
118,
|
|
3050
|
+
101,
|
|
3051
|
+
108,
|
|
3052
|
+
111,
|
|
3053
|
+
112,
|
|
3054
|
+
101
|
|
3055
|
+
]
|
|
3056
|
+
}
|
|
3057
|
+
]
|
|
3058
|
+
}
|
|
3059
|
+
},
|
|
3060
|
+
{
|
|
3061
|
+
name: "owner",
|
|
3062
|
+
writable: true,
|
|
3063
|
+
signer: true
|
|
3064
|
+
},
|
|
3065
|
+
{
|
|
3066
|
+
name: "system_program",
|
|
3067
|
+
address: "11111111111111111111111111111111"
|
|
2921
3068
|
}
|
|
2922
|
-
|
|
2923
|
-
|
|
3069
|
+
],
|
|
3070
|
+
args: [
|
|
3071
|
+
{
|
|
3072
|
+
name: "primus_zktls",
|
|
3073
|
+
type: "pubkey"
|
|
3074
|
+
},
|
|
3075
|
+
{
|
|
3076
|
+
name: "fee_recipient",
|
|
3077
|
+
type: "pubkey"
|
|
3078
|
+
},
|
|
3079
|
+
{
|
|
3080
|
+
name: "claim_fee",
|
|
3081
|
+
type: "u64"
|
|
2924
3082
|
}
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
3083
|
+
]
|
|
3084
|
+
},
|
|
3085
|
+
{
|
|
3086
|
+
name: "re_claim",
|
|
3087
|
+
discriminator: [
|
|
3088
|
+
105,
|
|
3089
|
+
179,
|
|
3090
|
+
220,
|
|
3091
|
+
94,
|
|
3092
|
+
121,
|
|
3093
|
+
140,
|
|
3094
|
+
144,
|
|
3095
|
+
24
|
|
3096
|
+
],
|
|
3097
|
+
accounts: [
|
|
3098
|
+
{
|
|
3099
|
+
name: "state",
|
|
3100
|
+
writable: true
|
|
3101
|
+
},
|
|
3102
|
+
{
|
|
3103
|
+
name: "re_record",
|
|
3104
|
+
writable: true,
|
|
3105
|
+
pda: {
|
|
3106
|
+
seeds: [
|
|
3107
|
+
{
|
|
3108
|
+
kind: "const",
|
|
3109
|
+
value: [
|
|
3110
|
+
114,
|
|
3111
|
+
101,
|
|
3112
|
+
95,
|
|
3113
|
+
114,
|
|
3114
|
+
101,
|
|
3115
|
+
99,
|
|
3116
|
+
111,
|
|
3117
|
+
114,
|
|
3118
|
+
100
|
|
3119
|
+
]
|
|
3120
|
+
},
|
|
3121
|
+
{
|
|
3122
|
+
kind: "arg",
|
|
3123
|
+
path: "re_id"
|
|
3124
|
+
}
|
|
3125
|
+
]
|
|
2930
3126
|
}
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
}
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
3127
|
+
},
|
|
3128
|
+
{
|
|
3129
|
+
name: "re_record_data",
|
|
3130
|
+
writable: true
|
|
3131
|
+
},
|
|
3132
|
+
{
|
|
3133
|
+
name: "claimer",
|
|
3134
|
+
writable: true,
|
|
3135
|
+
signer: true
|
|
3136
|
+
},
|
|
3137
|
+
{
|
|
3138
|
+
name: "system_program",
|
|
3139
|
+
address: "11111111111111111111111111111111"
|
|
3140
|
+
},
|
|
3141
|
+
{
|
|
3142
|
+
name: "primus_zktls_state",
|
|
3143
|
+
writable: true
|
|
3144
|
+
},
|
|
3145
|
+
{
|
|
3146
|
+
name: "primus_zktls_program",
|
|
3147
|
+
address: "3qG9pUbAHfizoqnvj9GxnTPaVgkyb7Ry6Q5vozMYdVAA"
|
|
3148
|
+
},
|
|
3149
|
+
{
|
|
3150
|
+
name: "fee_recipient",
|
|
3151
|
+
writable: true
|
|
3152
|
+
},
|
|
3153
|
+
{
|
|
3154
|
+
name: "att_recipient",
|
|
3155
|
+
writable: true
|
|
3156
|
+
},
|
|
3157
|
+
{
|
|
3158
|
+
name: "data_buffer",
|
|
3159
|
+
writable: true,
|
|
3160
|
+
optional: true
|
|
3161
|
+
},
|
|
3162
|
+
{
|
|
3163
|
+
name: "from_token_account",
|
|
3164
|
+
writable: true,
|
|
3165
|
+
optional: true,
|
|
3166
|
+
pda: {
|
|
3167
|
+
seeds: [
|
|
3168
|
+
{
|
|
3169
|
+
kind: "account",
|
|
3170
|
+
path: "state"
|
|
3171
|
+
},
|
|
3172
|
+
{
|
|
3173
|
+
kind: "account",
|
|
3174
|
+
path: "token_program"
|
|
3175
|
+
},
|
|
3176
|
+
{
|
|
3177
|
+
kind: "account",
|
|
3178
|
+
path: "mint"
|
|
3179
|
+
}
|
|
3180
|
+
],
|
|
3181
|
+
program: {
|
|
3182
|
+
kind: "const",
|
|
3183
|
+
value: [
|
|
3184
|
+
140,
|
|
3185
|
+
151,
|
|
3186
|
+
37,
|
|
3187
|
+
143,
|
|
3188
|
+
78,
|
|
3189
|
+
36,
|
|
3190
|
+
137,
|
|
3191
|
+
241,
|
|
3192
|
+
187,
|
|
3193
|
+
61,
|
|
3194
|
+
16,
|
|
3195
|
+
41,
|
|
3196
|
+
20,
|
|
3197
|
+
142,
|
|
3198
|
+
13,
|
|
3199
|
+
131,
|
|
3200
|
+
11,
|
|
3201
|
+
90,
|
|
3202
|
+
19,
|
|
3203
|
+
153,
|
|
3204
|
+
218,
|
|
3205
|
+
255,
|
|
3206
|
+
16,
|
|
3207
|
+
132,
|
|
3208
|
+
4,
|
|
3209
|
+
142,
|
|
3210
|
+
123,
|
|
3211
|
+
216,
|
|
3212
|
+
219,
|
|
3213
|
+
233,
|
|
3214
|
+
248,
|
|
3215
|
+
89
|
|
3216
|
+
]
|
|
3217
|
+
}
|
|
3218
|
+
}
|
|
3219
|
+
},
|
|
3220
|
+
{
|
|
3221
|
+
name: "to_token_account",
|
|
3222
|
+
writable: true,
|
|
3223
|
+
optional: true,
|
|
3224
|
+
pda: {
|
|
3225
|
+
seeds: [
|
|
3226
|
+
{
|
|
3227
|
+
kind: "account",
|
|
3228
|
+
path: "att_recipient"
|
|
3229
|
+
},
|
|
3230
|
+
{
|
|
3231
|
+
kind: "account",
|
|
3232
|
+
path: "token_program"
|
|
3233
|
+
},
|
|
3234
|
+
{
|
|
3235
|
+
kind: "account",
|
|
3236
|
+
path: "mint"
|
|
3237
|
+
}
|
|
3238
|
+
],
|
|
3239
|
+
program: {
|
|
3240
|
+
kind: "const",
|
|
3241
|
+
value: [
|
|
3242
|
+
140,
|
|
3243
|
+
151,
|
|
3244
|
+
37,
|
|
3245
|
+
143,
|
|
3246
|
+
78,
|
|
3247
|
+
36,
|
|
3248
|
+
137,
|
|
3249
|
+
241,
|
|
3250
|
+
187,
|
|
3251
|
+
61,
|
|
3252
|
+
16,
|
|
3253
|
+
41,
|
|
3254
|
+
20,
|
|
3255
|
+
142,
|
|
3256
|
+
13,
|
|
3257
|
+
131,
|
|
3258
|
+
11,
|
|
3259
|
+
90,
|
|
3260
|
+
19,
|
|
3261
|
+
153,
|
|
3262
|
+
218,
|
|
3263
|
+
255,
|
|
3264
|
+
16,
|
|
3265
|
+
132,
|
|
3266
|
+
4,
|
|
3267
|
+
142,
|
|
3268
|
+
123,
|
|
3269
|
+
216,
|
|
3270
|
+
219,
|
|
3271
|
+
233,
|
|
3272
|
+
248,
|
|
3273
|
+
89
|
|
3274
|
+
]
|
|
3275
|
+
}
|
|
3276
|
+
}
|
|
3277
|
+
},
|
|
3278
|
+
{
|
|
3279
|
+
name: "mint",
|
|
3280
|
+
optional: true
|
|
3281
|
+
},
|
|
3282
|
+
{
|
|
3283
|
+
name: "token_program"
|
|
3284
|
+
},
|
|
3285
|
+
{
|
|
3286
|
+
name: "associated_token_program",
|
|
3287
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
2956
3288
|
}
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
3289
|
+
],
|
|
3290
|
+
args: [
|
|
3291
|
+
{
|
|
3292
|
+
name: "_re_id",
|
|
3293
|
+
type: {
|
|
3294
|
+
array: [
|
|
3295
|
+
"u8",
|
|
3296
|
+
32
|
|
3297
|
+
]
|
|
3298
|
+
}
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
name: "_att",
|
|
3302
|
+
type: {
|
|
3303
|
+
option: {
|
|
3304
|
+
defined: {
|
|
3305
|
+
name: "Attestation"
|
|
3306
|
+
}
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
2960
3309
|
}
|
|
2961
|
-
|
|
2962
|
-
|
|
3310
|
+
]
|
|
3311
|
+
},
|
|
3312
|
+
{
|
|
3313
|
+
name: "re_record_data_init",
|
|
3314
|
+
discriminator: [
|
|
3315
|
+
211,
|
|
3316
|
+
91,
|
|
3317
|
+
95,
|
|
3318
|
+
249,
|
|
3319
|
+
111,
|
|
3320
|
+
81,
|
|
3321
|
+
103,
|
|
3322
|
+
124
|
|
3323
|
+
],
|
|
3324
|
+
accounts: [
|
|
3325
|
+
{
|
|
3326
|
+
name: "re_record_data",
|
|
3327
|
+
writable: true
|
|
3328
|
+
},
|
|
3329
|
+
{
|
|
3330
|
+
name: "sender",
|
|
3331
|
+
writable: true,
|
|
3332
|
+
signer: true
|
|
3333
|
+
},
|
|
3334
|
+
{
|
|
3335
|
+
name: "system_program",
|
|
3336
|
+
address: "11111111111111111111111111111111"
|
|
2963
3337
|
}
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
3338
|
+
],
|
|
3339
|
+
args: []
|
|
3340
|
+
},
|
|
3341
|
+
{
|
|
3342
|
+
name: "re_send",
|
|
3343
|
+
discriminator: [
|
|
3344
|
+
31,
|
|
3345
|
+
123,
|
|
3346
|
+
130,
|
|
3347
|
+
212,
|
|
3348
|
+
113,
|
|
3349
|
+
174,
|
|
3350
|
+
167,
|
|
3351
|
+
63
|
|
3352
|
+
],
|
|
3353
|
+
accounts: [
|
|
3354
|
+
{
|
|
3355
|
+
name: "state",
|
|
3356
|
+
writable: true,
|
|
3357
|
+
pda: {
|
|
3358
|
+
seeds: [
|
|
3359
|
+
{
|
|
3360
|
+
kind: "const",
|
|
3361
|
+
value: [
|
|
3362
|
+
114,
|
|
3363
|
+
101,
|
|
3364
|
+
100,
|
|
3365
|
+
95,
|
|
3366
|
+
101,
|
|
3367
|
+
110,
|
|
3368
|
+
118,
|
|
3369
|
+
101,
|
|
3370
|
+
108,
|
|
3371
|
+
111,
|
|
3372
|
+
112,
|
|
3373
|
+
101
|
|
3374
|
+
]
|
|
3375
|
+
}
|
|
3376
|
+
]
|
|
2969
3377
|
}
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
3378
|
+
},
|
|
3379
|
+
{
|
|
3380
|
+
name: "re_record",
|
|
3381
|
+
writable: true,
|
|
3382
|
+
pda: {
|
|
3383
|
+
seeds: [
|
|
3384
|
+
{
|
|
3385
|
+
kind: "const",
|
|
3386
|
+
value: [
|
|
3387
|
+
114,
|
|
3388
|
+
101,
|
|
3389
|
+
95,
|
|
3390
|
+
114,
|
|
3391
|
+
101,
|
|
3392
|
+
99,
|
|
3393
|
+
111,
|
|
3394
|
+
114,
|
|
3395
|
+
100
|
|
3396
|
+
]
|
|
3397
|
+
},
|
|
3398
|
+
{
|
|
3399
|
+
kind: "arg",
|
|
3400
|
+
path: "re_id"
|
|
3401
|
+
}
|
|
3402
|
+
]
|
|
3403
|
+
}
|
|
3404
|
+
},
|
|
3405
|
+
{
|
|
3406
|
+
name: "re_record_data",
|
|
3407
|
+
writable: true
|
|
3408
|
+
},
|
|
3409
|
+
{
|
|
3410
|
+
name: "sender",
|
|
3411
|
+
writable: true,
|
|
3412
|
+
signer: true
|
|
3413
|
+
},
|
|
3414
|
+
{
|
|
3415
|
+
name: "system_program",
|
|
3416
|
+
address: "11111111111111111111111111111111"
|
|
3417
|
+
},
|
|
3418
|
+
{
|
|
3419
|
+
name: "from_token_account",
|
|
3420
|
+
writable: true,
|
|
3421
|
+
optional: true,
|
|
3422
|
+
pda: {
|
|
3423
|
+
seeds: [
|
|
3424
|
+
{
|
|
3425
|
+
kind: "account",
|
|
3426
|
+
path: "sender"
|
|
3427
|
+
},
|
|
3428
|
+
{
|
|
3429
|
+
kind: "account",
|
|
3430
|
+
path: "token_program"
|
|
3431
|
+
},
|
|
3432
|
+
{
|
|
3433
|
+
kind: "account",
|
|
3434
|
+
path: "mint"
|
|
3435
|
+
}
|
|
3436
|
+
],
|
|
3437
|
+
program: {
|
|
3438
|
+
kind: "const",
|
|
3439
|
+
value: [
|
|
3440
|
+
140,
|
|
3441
|
+
151,
|
|
3442
|
+
37,
|
|
3443
|
+
143,
|
|
3444
|
+
78,
|
|
3445
|
+
36,
|
|
3446
|
+
137,
|
|
3447
|
+
241,
|
|
3448
|
+
187,
|
|
3449
|
+
61,
|
|
3450
|
+
16,
|
|
3451
|
+
41,
|
|
3452
|
+
20,
|
|
3453
|
+
142,
|
|
3454
|
+
13,
|
|
3455
|
+
131,
|
|
3456
|
+
11,
|
|
3457
|
+
90,
|
|
3458
|
+
19,
|
|
3459
|
+
153,
|
|
3460
|
+
218,
|
|
3461
|
+
255,
|
|
3462
|
+
16,
|
|
3463
|
+
132,
|
|
3464
|
+
4,
|
|
3465
|
+
142,
|
|
3466
|
+
123,
|
|
3467
|
+
216,
|
|
3468
|
+
219,
|
|
3469
|
+
233,
|
|
3470
|
+
248,
|
|
3471
|
+
89
|
|
3472
|
+
]
|
|
3473
|
+
}
|
|
3474
|
+
}
|
|
3475
|
+
},
|
|
3476
|
+
{
|
|
3477
|
+
name: "to_token_account",
|
|
3478
|
+
writable: true,
|
|
3479
|
+
optional: true,
|
|
3480
|
+
pda: {
|
|
3481
|
+
seeds: [
|
|
3482
|
+
{
|
|
3483
|
+
kind: "account",
|
|
3484
|
+
path: "state"
|
|
3485
|
+
},
|
|
3486
|
+
{
|
|
3487
|
+
kind: "account",
|
|
3488
|
+
path: "token_program"
|
|
3489
|
+
},
|
|
3490
|
+
{
|
|
3491
|
+
kind: "account",
|
|
3492
|
+
path: "mint"
|
|
3493
|
+
}
|
|
3494
|
+
],
|
|
3495
|
+
program: {
|
|
3496
|
+
kind: "const",
|
|
3497
|
+
value: [
|
|
3498
|
+
140,
|
|
3499
|
+
151,
|
|
3500
|
+
37,
|
|
3501
|
+
143,
|
|
3502
|
+
78,
|
|
3503
|
+
36,
|
|
3504
|
+
137,
|
|
3505
|
+
241,
|
|
3506
|
+
187,
|
|
3507
|
+
61,
|
|
3508
|
+
16,
|
|
3509
|
+
41,
|
|
3510
|
+
20,
|
|
3511
|
+
142,
|
|
3512
|
+
13,
|
|
3513
|
+
131,
|
|
3514
|
+
11,
|
|
3515
|
+
90,
|
|
3516
|
+
19,
|
|
3517
|
+
153,
|
|
3518
|
+
218,
|
|
3519
|
+
255,
|
|
3520
|
+
16,
|
|
3521
|
+
132,
|
|
3522
|
+
4,
|
|
3523
|
+
142,
|
|
3524
|
+
123,
|
|
3525
|
+
216,
|
|
3526
|
+
219,
|
|
3527
|
+
233,
|
|
3528
|
+
248,
|
|
3529
|
+
89
|
|
3530
|
+
]
|
|
3531
|
+
}
|
|
3532
|
+
}
|
|
3533
|
+
},
|
|
3534
|
+
{
|
|
3535
|
+
name: "mint",
|
|
3536
|
+
optional: true
|
|
3537
|
+
},
|
|
3538
|
+
{
|
|
3539
|
+
name: "token_program"
|
|
3540
|
+
},
|
|
3541
|
+
{
|
|
3542
|
+
name: "associated_token_program",
|
|
3543
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3544
|
+
}
|
|
3545
|
+
],
|
|
3546
|
+
args: [
|
|
3547
|
+
{
|
|
3548
|
+
name: "re_id",
|
|
3549
|
+
type: {
|
|
3550
|
+
array: [
|
|
3551
|
+
"u8",
|
|
3552
|
+
32
|
|
3553
|
+
]
|
|
3554
|
+
}
|
|
3555
|
+
},
|
|
3556
|
+
{
|
|
3557
|
+
name: "token",
|
|
3558
|
+
type: {
|
|
3559
|
+
defined: {
|
|
3560
|
+
name: "TipToken"
|
|
3561
|
+
}
|
|
3562
|
+
}
|
|
3563
|
+
},
|
|
3564
|
+
{
|
|
3565
|
+
name: "send_param",
|
|
3566
|
+
type: {
|
|
3567
|
+
defined: {
|
|
3568
|
+
name: "RESendParam"
|
|
3569
|
+
}
|
|
3570
|
+
}
|
|
3571
|
+
}
|
|
3572
|
+
]
|
|
3573
|
+
},
|
|
3574
|
+
{
|
|
3575
|
+
name: "re_sender_withdraw",
|
|
3576
|
+
discriminator: [
|
|
3577
|
+
231,
|
|
3578
|
+
140,
|
|
3579
|
+
27,
|
|
3580
|
+
36,
|
|
3581
|
+
175,
|
|
3582
|
+
206,
|
|
3583
|
+
105,
|
|
3584
|
+
68
|
|
3585
|
+
],
|
|
3586
|
+
accounts: [
|
|
3587
|
+
{
|
|
3588
|
+
name: "state",
|
|
3589
|
+
writable: true
|
|
3590
|
+
},
|
|
3591
|
+
{
|
|
3592
|
+
name: "re_record",
|
|
3593
|
+
writable: true,
|
|
3594
|
+
pda: {
|
|
3595
|
+
seeds: [
|
|
3596
|
+
{
|
|
3597
|
+
kind: "const",
|
|
3598
|
+
value: [
|
|
3599
|
+
114,
|
|
3600
|
+
101,
|
|
3601
|
+
95,
|
|
3602
|
+
114,
|
|
3603
|
+
101,
|
|
3604
|
+
99,
|
|
3605
|
+
111,
|
|
3606
|
+
114,
|
|
3607
|
+
100
|
|
3608
|
+
]
|
|
3609
|
+
},
|
|
3610
|
+
{
|
|
3611
|
+
kind: "arg",
|
|
3612
|
+
path: "re_id"
|
|
3613
|
+
}
|
|
3614
|
+
]
|
|
3615
|
+
}
|
|
3616
|
+
},
|
|
3617
|
+
{
|
|
3618
|
+
name: "re_sender",
|
|
3619
|
+
writable: true,
|
|
3620
|
+
signer: true,
|
|
3621
|
+
relations: [
|
|
3622
|
+
"re_record"
|
|
3623
|
+
]
|
|
3624
|
+
},
|
|
3625
|
+
{
|
|
3626
|
+
name: "system_program",
|
|
3627
|
+
address: "11111111111111111111111111111111"
|
|
3628
|
+
},
|
|
3629
|
+
{
|
|
3630
|
+
name: "from_token_account",
|
|
3631
|
+
writable: true,
|
|
3632
|
+
optional: true,
|
|
3633
|
+
pda: {
|
|
3634
|
+
seeds: [
|
|
3635
|
+
{
|
|
3636
|
+
kind: "account",
|
|
3637
|
+
path: "state"
|
|
3638
|
+
},
|
|
3639
|
+
{
|
|
3640
|
+
kind: "account",
|
|
3641
|
+
path: "token_program"
|
|
3642
|
+
},
|
|
3643
|
+
{
|
|
3644
|
+
kind: "account",
|
|
3645
|
+
path: "mint"
|
|
3646
|
+
}
|
|
3647
|
+
],
|
|
3648
|
+
program: {
|
|
3649
|
+
kind: "const",
|
|
3650
|
+
value: [
|
|
3651
|
+
140,
|
|
3652
|
+
151,
|
|
3653
|
+
37,
|
|
3654
|
+
143,
|
|
3655
|
+
78,
|
|
3656
|
+
36,
|
|
3657
|
+
137,
|
|
3658
|
+
241,
|
|
3659
|
+
187,
|
|
3660
|
+
61,
|
|
3661
|
+
16,
|
|
3662
|
+
41,
|
|
3663
|
+
20,
|
|
3664
|
+
142,
|
|
3665
|
+
13,
|
|
3666
|
+
131,
|
|
3667
|
+
11,
|
|
3668
|
+
90,
|
|
3669
|
+
19,
|
|
3670
|
+
153,
|
|
3671
|
+
218,
|
|
3672
|
+
255,
|
|
3673
|
+
16,
|
|
3674
|
+
132,
|
|
3675
|
+
4,
|
|
3676
|
+
142,
|
|
3677
|
+
123,
|
|
3678
|
+
216,
|
|
3679
|
+
219,
|
|
3680
|
+
233,
|
|
3681
|
+
248,
|
|
3682
|
+
89
|
|
3683
|
+
]
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
},
|
|
3687
|
+
{
|
|
3688
|
+
name: "to_token_account",
|
|
3689
|
+
writable: true,
|
|
3690
|
+
optional: true,
|
|
3691
|
+
pda: {
|
|
3692
|
+
seeds: [
|
|
3693
|
+
{
|
|
3694
|
+
kind: "account",
|
|
3695
|
+
path: "re_sender"
|
|
3696
|
+
},
|
|
3697
|
+
{
|
|
3698
|
+
kind: "account",
|
|
3699
|
+
path: "token_program"
|
|
3700
|
+
},
|
|
3701
|
+
{
|
|
3702
|
+
kind: "account",
|
|
3703
|
+
path: "mint"
|
|
3704
|
+
}
|
|
3705
|
+
],
|
|
3706
|
+
program: {
|
|
3707
|
+
kind: "const",
|
|
3708
|
+
value: [
|
|
3709
|
+
140,
|
|
3710
|
+
151,
|
|
3711
|
+
37,
|
|
3712
|
+
143,
|
|
3713
|
+
78,
|
|
3714
|
+
36,
|
|
3715
|
+
137,
|
|
3716
|
+
241,
|
|
3717
|
+
187,
|
|
3718
|
+
61,
|
|
3719
|
+
16,
|
|
3720
|
+
41,
|
|
3721
|
+
20,
|
|
3722
|
+
142,
|
|
3723
|
+
13,
|
|
3724
|
+
131,
|
|
3725
|
+
11,
|
|
3726
|
+
90,
|
|
3727
|
+
19,
|
|
3728
|
+
153,
|
|
3729
|
+
218,
|
|
3730
|
+
255,
|
|
3731
|
+
16,
|
|
3732
|
+
132,
|
|
3733
|
+
4,
|
|
3734
|
+
142,
|
|
3735
|
+
123,
|
|
3736
|
+
216,
|
|
3737
|
+
219,
|
|
3738
|
+
233,
|
|
3739
|
+
248,
|
|
3740
|
+
89
|
|
3741
|
+
]
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3744
|
+
},
|
|
3745
|
+
{
|
|
3746
|
+
name: "mint",
|
|
3747
|
+
optional: true
|
|
3748
|
+
},
|
|
3749
|
+
{
|
|
3750
|
+
name: "token_program"
|
|
3751
|
+
},
|
|
3752
|
+
{
|
|
3753
|
+
name: "associated_token_program",
|
|
3754
|
+
address: "ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"
|
|
3755
|
+
}
|
|
3756
|
+
],
|
|
3757
|
+
args: [
|
|
3758
|
+
{
|
|
3759
|
+
name: "_re_id",
|
|
3760
|
+
type: {
|
|
3761
|
+
array: [
|
|
3762
|
+
"u8",
|
|
3763
|
+
32
|
|
3764
|
+
]
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
]
|
|
3768
|
+
},
|
|
3769
|
+
{
|
|
3770
|
+
name: "set_claim_fee",
|
|
3771
|
+
discriminator: [
|
|
3772
|
+
124,
|
|
3773
|
+
3,
|
|
3774
|
+
184,
|
|
3775
|
+
17,
|
|
3776
|
+
133,
|
|
3777
|
+
67,
|
|
3778
|
+
255,
|
|
3779
|
+
50
|
|
3780
|
+
],
|
|
3781
|
+
accounts: [
|
|
3782
|
+
{
|
|
3783
|
+
name: "state",
|
|
3784
|
+
writable: true,
|
|
3785
|
+
pda: {
|
|
3786
|
+
seeds: [
|
|
3787
|
+
{
|
|
3788
|
+
kind: "const",
|
|
3789
|
+
value: [
|
|
3790
|
+
114,
|
|
3791
|
+
101,
|
|
3792
|
+
100,
|
|
3793
|
+
95,
|
|
3794
|
+
101,
|
|
3795
|
+
110,
|
|
3796
|
+
118,
|
|
3797
|
+
101,
|
|
3798
|
+
108,
|
|
3799
|
+
111,
|
|
3800
|
+
112,
|
|
3801
|
+
101
|
|
3802
|
+
]
|
|
3803
|
+
}
|
|
3804
|
+
]
|
|
3805
|
+
}
|
|
3806
|
+
},
|
|
3807
|
+
{
|
|
3808
|
+
name: "owner",
|
|
3809
|
+
writable: true,
|
|
3810
|
+
signer: true,
|
|
3811
|
+
relations: [
|
|
3812
|
+
"state"
|
|
3813
|
+
]
|
|
3814
|
+
},
|
|
3815
|
+
{
|
|
3816
|
+
name: "system_program",
|
|
3817
|
+
address: "11111111111111111111111111111111"
|
|
3818
|
+
}
|
|
3819
|
+
],
|
|
3820
|
+
args: [
|
|
3821
|
+
{
|
|
3822
|
+
name: "claim_fee",
|
|
3823
|
+
type: "u64"
|
|
3824
|
+
}
|
|
3825
|
+
]
|
|
3826
|
+
},
|
|
3827
|
+
{
|
|
3828
|
+
name: "set_fee_recipient",
|
|
3829
|
+
discriminator: [
|
|
3830
|
+
227,
|
|
3831
|
+
18,
|
|
3832
|
+
215,
|
|
3833
|
+
42,
|
|
3834
|
+
237,
|
|
3835
|
+
246,
|
|
3836
|
+
151,
|
|
3837
|
+
66
|
|
3838
|
+
],
|
|
3839
|
+
accounts: [
|
|
3840
|
+
{
|
|
3841
|
+
name: "state",
|
|
3842
|
+
writable: true,
|
|
3843
|
+
pda: {
|
|
3844
|
+
seeds: [
|
|
3845
|
+
{
|
|
3846
|
+
kind: "const",
|
|
3847
|
+
value: [
|
|
3848
|
+
114,
|
|
3849
|
+
101,
|
|
3850
|
+
100,
|
|
3851
|
+
95,
|
|
3852
|
+
101,
|
|
3853
|
+
110,
|
|
3854
|
+
118,
|
|
3855
|
+
101,
|
|
3856
|
+
108,
|
|
3857
|
+
111,
|
|
3858
|
+
112,
|
|
3859
|
+
101
|
|
3860
|
+
]
|
|
3861
|
+
}
|
|
3862
|
+
]
|
|
3863
|
+
}
|
|
3864
|
+
},
|
|
3865
|
+
{
|
|
3866
|
+
name: "owner",
|
|
3867
|
+
writable: true,
|
|
3868
|
+
signer: true,
|
|
3869
|
+
relations: [
|
|
3870
|
+
"state"
|
|
3871
|
+
]
|
|
3872
|
+
},
|
|
3873
|
+
{
|
|
3874
|
+
name: "system_program",
|
|
3875
|
+
address: "11111111111111111111111111111111"
|
|
3876
|
+
}
|
|
3877
|
+
],
|
|
3878
|
+
args: [
|
|
3879
|
+
{
|
|
3880
|
+
name: "fee_recipient",
|
|
3881
|
+
type: "pubkey"
|
|
3882
|
+
}
|
|
3883
|
+
]
|
|
3884
|
+
},
|
|
3885
|
+
{
|
|
3886
|
+
name: "set_primus_zktls",
|
|
3887
|
+
discriminator: [
|
|
3888
|
+
248,
|
|
3889
|
+
182,
|
|
3890
|
+
45,
|
|
3891
|
+
229,
|
|
3892
|
+
46,
|
|
3893
|
+
5,
|
|
3894
|
+
95,
|
|
3895
|
+
71
|
|
3896
|
+
],
|
|
3897
|
+
accounts: [
|
|
3898
|
+
{
|
|
3899
|
+
name: "state",
|
|
3900
|
+
writable: true,
|
|
3901
|
+
pda: {
|
|
3902
|
+
seeds: [
|
|
3903
|
+
{
|
|
3904
|
+
kind: "const",
|
|
3905
|
+
value: [
|
|
3906
|
+
114,
|
|
3907
|
+
101,
|
|
3908
|
+
100,
|
|
3909
|
+
95,
|
|
3910
|
+
101,
|
|
3911
|
+
110,
|
|
3912
|
+
118,
|
|
3913
|
+
101,
|
|
3914
|
+
108,
|
|
3915
|
+
111,
|
|
3916
|
+
112,
|
|
3917
|
+
101
|
|
3918
|
+
]
|
|
3919
|
+
}
|
|
3920
|
+
]
|
|
3921
|
+
}
|
|
3922
|
+
},
|
|
3923
|
+
{
|
|
3924
|
+
name: "owner",
|
|
3925
|
+
writable: true,
|
|
3926
|
+
signer: true,
|
|
3927
|
+
relations: [
|
|
3928
|
+
"state"
|
|
3929
|
+
]
|
|
3930
|
+
},
|
|
3931
|
+
{
|
|
3932
|
+
name: "system_program",
|
|
3933
|
+
address: "11111111111111111111111111111111"
|
|
3934
|
+
}
|
|
3935
|
+
],
|
|
3936
|
+
args: [
|
|
3937
|
+
{
|
|
3938
|
+
name: "primus_zktls",
|
|
3939
|
+
type: "pubkey"
|
|
3940
|
+
}
|
|
3941
|
+
]
|
|
3942
|
+
},
|
|
3943
|
+
{
|
|
3944
|
+
name: "set_withdraw_delay",
|
|
3945
|
+
discriminator: [
|
|
3946
|
+
184,
|
|
3947
|
+
89,
|
|
3948
|
+
21,
|
|
3949
|
+
192,
|
|
3950
|
+
34,
|
|
3951
|
+
24,
|
|
3952
|
+
3,
|
|
3953
|
+
142
|
|
3954
|
+
],
|
|
3955
|
+
accounts: [
|
|
3956
|
+
{
|
|
3957
|
+
name: "state",
|
|
3958
|
+
writable: true,
|
|
3959
|
+
pda: {
|
|
3960
|
+
seeds: [
|
|
3961
|
+
{
|
|
3962
|
+
kind: "const",
|
|
3963
|
+
value: [
|
|
3964
|
+
114,
|
|
3965
|
+
101,
|
|
3966
|
+
100,
|
|
3967
|
+
95,
|
|
3968
|
+
101,
|
|
3969
|
+
110,
|
|
3970
|
+
118,
|
|
3971
|
+
101,
|
|
3972
|
+
108,
|
|
3973
|
+
111,
|
|
3974
|
+
112,
|
|
3975
|
+
101
|
|
3976
|
+
]
|
|
3977
|
+
}
|
|
3978
|
+
]
|
|
3979
|
+
}
|
|
3980
|
+
},
|
|
3981
|
+
{
|
|
3982
|
+
name: "owner",
|
|
3983
|
+
writable: true,
|
|
3984
|
+
signer: true,
|
|
3985
|
+
relations: [
|
|
3986
|
+
"state"
|
|
3987
|
+
]
|
|
3988
|
+
},
|
|
3989
|
+
{
|
|
3990
|
+
name: "system_program",
|
|
3991
|
+
address: "11111111111111111111111111111111"
|
|
3992
|
+
}
|
|
3993
|
+
],
|
|
3994
|
+
args: [
|
|
3995
|
+
{
|
|
3996
|
+
name: "withdraw_delay",
|
|
3997
|
+
type: "u64"
|
|
3998
|
+
}
|
|
3999
|
+
]
|
|
4000
|
+
}
|
|
4001
|
+
],
|
|
4002
|
+
accounts: [
|
|
4003
|
+
{
|
|
4004
|
+
name: "DataBuffer",
|
|
4005
|
+
discriminator: [
|
|
4006
|
+
235,
|
|
4007
|
+
220,
|
|
4008
|
+
51,
|
|
4009
|
+
248,
|
|
4010
|
+
56,
|
|
4011
|
+
77,
|
|
4012
|
+
241,
|
|
4013
|
+
89
|
|
4014
|
+
]
|
|
4015
|
+
},
|
|
4016
|
+
{
|
|
4017
|
+
name: "PrimusState",
|
|
4018
|
+
discriminator: [
|
|
4019
|
+
200,
|
|
4020
|
+
136,
|
|
4021
|
+
35,
|
|
4022
|
+
84,
|
|
4023
|
+
173,
|
|
4024
|
+
237,
|
|
4025
|
+
163,
|
|
4026
|
+
179
|
|
4027
|
+
]
|
|
4028
|
+
},
|
|
4029
|
+
{
|
|
4030
|
+
name: "RERecord",
|
|
4031
|
+
discriminator: [
|
|
4032
|
+
242,
|
|
4033
|
+
171,
|
|
4034
|
+
141,
|
|
4035
|
+
17,
|
|
4036
|
+
123,
|
|
4037
|
+
107,
|
|
4038
|
+
153,
|
|
4039
|
+
15
|
|
4040
|
+
]
|
|
4041
|
+
},
|
|
4042
|
+
{
|
|
4043
|
+
name: "RERecordData",
|
|
4044
|
+
discriminator: [
|
|
4045
|
+
165,
|
|
4046
|
+
107,
|
|
4047
|
+
251,
|
|
4048
|
+
115,
|
|
4049
|
+
50,
|
|
4050
|
+
118,
|
|
4051
|
+
32,
|
|
4052
|
+
148
|
|
4053
|
+
]
|
|
4054
|
+
},
|
|
4055
|
+
{
|
|
4056
|
+
name: "RedEnvelopeState",
|
|
4057
|
+
discriminator: [
|
|
4058
|
+
89,
|
|
4059
|
+
134,
|
|
4060
|
+
184,
|
|
4061
|
+
61,
|
|
4062
|
+
201,
|
|
4063
|
+
123,
|
|
4064
|
+
226,
|
|
4065
|
+
180
|
|
4066
|
+
]
|
|
4067
|
+
}
|
|
4068
|
+
],
|
|
4069
|
+
events: [
|
|
4070
|
+
{
|
|
4071
|
+
name: "REClaimEvent",
|
|
4072
|
+
discriminator: [
|
|
4073
|
+
214,
|
|
4074
|
+
100,
|
|
4075
|
+
41,
|
|
4076
|
+
0,
|
|
4077
|
+
45,
|
|
4078
|
+
92,
|
|
4079
|
+
31,
|
|
4080
|
+
248
|
|
4081
|
+
]
|
|
4082
|
+
},
|
|
4083
|
+
{
|
|
4084
|
+
name: "RESWithdrawEvent",
|
|
4085
|
+
discriminator: [
|
|
4086
|
+
26,
|
|
4087
|
+
207,
|
|
4088
|
+
42,
|
|
4089
|
+
68,
|
|
4090
|
+
36,
|
|
4091
|
+
174,
|
|
4092
|
+
127,
|
|
4093
|
+
205
|
|
4094
|
+
]
|
|
4095
|
+
},
|
|
4096
|
+
{
|
|
4097
|
+
name: "RESendEvent",
|
|
4098
|
+
discriminator: [
|
|
4099
|
+
147,
|
|
4100
|
+
8,
|
|
4101
|
+
237,
|
|
4102
|
+
225,
|
|
4103
|
+
123,
|
|
4104
|
+
64,
|
|
4105
|
+
157,
|
|
4106
|
+
199
|
|
4107
|
+
]
|
|
4108
|
+
}
|
|
4109
|
+
],
|
|
4110
|
+
errors: [
|
|
4111
|
+
{
|
|
4112
|
+
code: 6e3,
|
|
4113
|
+
name: "InvalidZktlsProgram",
|
|
4114
|
+
msg: "Invalid Zktls Program"
|
|
4115
|
+
},
|
|
4116
|
+
{
|
|
4117
|
+
code: 6001,
|
|
4118
|
+
name: "InvalidTokenProgram",
|
|
4119
|
+
msg: "Invalid token program"
|
|
4120
|
+
},
|
|
4121
|
+
{
|
|
4122
|
+
code: 6002,
|
|
4123
|
+
name: "InvalidTokenType",
|
|
4124
|
+
msg: "Invalid token type"
|
|
4125
|
+
},
|
|
4126
|
+
{
|
|
4127
|
+
code: 6003,
|
|
4128
|
+
name: "InvalidREType",
|
|
4129
|
+
msg: "Invalid red envelope type"
|
|
4130
|
+
},
|
|
4131
|
+
{
|
|
4132
|
+
code: 6004,
|
|
4133
|
+
name: "InvalidNumber",
|
|
4134
|
+
msg: "Invalid number"
|
|
4135
|
+
},
|
|
4136
|
+
{
|
|
4137
|
+
code: 6005,
|
|
4138
|
+
name: "InvalidEmptyRatio",
|
|
4139
|
+
msg: "Invalid empty ratio"
|
|
4140
|
+
},
|
|
4141
|
+
{
|
|
4142
|
+
code: 6006,
|
|
4143
|
+
name: "AmountTooLow",
|
|
4144
|
+
msg: "Amount too low"
|
|
4145
|
+
},
|
|
4146
|
+
{
|
|
4147
|
+
code: 6007,
|
|
4148
|
+
name: "WrongAmount",
|
|
4149
|
+
msg: "Wrong amount"
|
|
4150
|
+
},
|
|
4151
|
+
{
|
|
4152
|
+
code: 6008,
|
|
4153
|
+
name: "NoReId",
|
|
4154
|
+
msg: "Red envelope ID does not exist"
|
|
4155
|
+
},
|
|
4156
|
+
{
|
|
4157
|
+
code: 6009,
|
|
4158
|
+
name: "AllClaimed",
|
|
4159
|
+
msg: "All envelopes claimed"
|
|
4160
|
+
},
|
|
4161
|
+
{
|
|
4162
|
+
code: 6010,
|
|
4163
|
+
name: "UserIdEmpty",
|
|
4164
|
+
msg: "User ID empty"
|
|
4165
|
+
},
|
|
4166
|
+
{
|
|
4167
|
+
code: 6011,
|
|
4168
|
+
name: "InvalidUserAddress",
|
|
4169
|
+
msg: "Invalid User Address"
|
|
4170
|
+
},
|
|
4171
|
+
{
|
|
4172
|
+
code: 6012,
|
|
4173
|
+
name: "AlreadyClaimed",
|
|
4174
|
+
msg: "Already claimed"
|
|
4175
|
+
},
|
|
4176
|
+
{
|
|
4177
|
+
code: 6013,
|
|
4178
|
+
name: "AmountUnderflow",
|
|
4179
|
+
msg: "Amount underflow"
|
|
4180
|
+
},
|
|
4181
|
+
{
|
|
4182
|
+
code: 6014,
|
|
4183
|
+
name: "InvalidFeeRecipient",
|
|
4184
|
+
msg: "Invalid fee recipient"
|
|
4185
|
+
},
|
|
4186
|
+
{
|
|
4187
|
+
code: 6015,
|
|
4188
|
+
name: "InvalidStateAccount",
|
|
4189
|
+
msg: "Invalid state account"
|
|
4190
|
+
},
|
|
4191
|
+
{
|
|
4192
|
+
code: 6016,
|
|
4193
|
+
name: "RecipientIsZero",
|
|
4194
|
+
msg: "Recipient cannot be zero"
|
|
4195
|
+
},
|
|
4196
|
+
{
|
|
4197
|
+
code: 6017,
|
|
4198
|
+
name: "InvalidCheckType",
|
|
4199
|
+
msg: "Invalid checkType"
|
|
4200
|
+
},
|
|
4201
|
+
{
|
|
4202
|
+
code: 6018,
|
|
4203
|
+
name: "InvalidCheckParams",
|
|
4204
|
+
msg: "CheckParams decode failed"
|
|
4205
|
+
},
|
|
4206
|
+
{
|
|
4207
|
+
code: 6019,
|
|
4208
|
+
name: "NoFund",
|
|
4209
|
+
msg: "No fund"
|
|
4210
|
+
},
|
|
4211
|
+
{
|
|
4212
|
+
code: 6020,
|
|
4213
|
+
name: "NotOwner",
|
|
4214
|
+
msg: "Not owner"
|
|
4215
|
+
},
|
|
4216
|
+
{
|
|
4217
|
+
code: 6021,
|
|
4218
|
+
name: "NotExpired",
|
|
4219
|
+
msg: "Not expired"
|
|
4220
|
+
},
|
|
4221
|
+
{
|
|
4222
|
+
code: 6022,
|
|
4223
|
+
name: "UnsupportedTokenType",
|
|
4224
|
+
msg: "Unsupported Token Type"
|
|
4225
|
+
},
|
|
4226
|
+
{
|
|
4227
|
+
code: 6023,
|
|
4228
|
+
name: "InsufficientSOL",
|
|
4229
|
+
msg: "Insufficient SOL"
|
|
4230
|
+
},
|
|
4231
|
+
{
|
|
4232
|
+
code: 6024,
|
|
4233
|
+
name: "WrongTokenMint",
|
|
4234
|
+
msg: "Wrong token mint"
|
|
4235
|
+
},
|
|
4236
|
+
{
|
|
4237
|
+
code: 6025,
|
|
4238
|
+
name: "DeserializationFailed",
|
|
4239
|
+
msg: "Deserialization Failed"
|
|
4240
|
+
},
|
|
4241
|
+
{
|
|
4242
|
+
code: 6026,
|
|
4243
|
+
name: "JsonParseError",
|
|
4244
|
+
msg: "JSON Parse Error"
|
|
4245
|
+
},
|
|
4246
|
+
{
|
|
4247
|
+
code: 6027,
|
|
4248
|
+
name: "ResponseLengthError",
|
|
4249
|
+
msg: "response length error"
|
|
4250
|
+
},
|
|
4251
|
+
{
|
|
4252
|
+
code: 6028,
|
|
4253
|
+
name: "AttUrlError",
|
|
4254
|
+
msg: "att url error"
|
|
4255
|
+
},
|
|
4256
|
+
{
|
|
4257
|
+
code: 6029,
|
|
4258
|
+
name: "AttSuffixUrlError",
|
|
4259
|
+
msg: "att suffix url error"
|
|
4260
|
+
},
|
|
4261
|
+
{
|
|
4262
|
+
code: 6030,
|
|
4263
|
+
name: "JsonPathError",
|
|
4264
|
+
msg: "json path error"
|
|
4265
|
+
},
|
|
4266
|
+
{
|
|
4267
|
+
code: 6031,
|
|
4268
|
+
name: "UsernameKeyError",
|
|
4269
|
+
msg: "username key error"
|
|
4270
|
+
},
|
|
4271
|
+
{
|
|
4272
|
+
code: 6032,
|
|
4273
|
+
name: "FollowingError",
|
|
4274
|
+
msg: "following error"
|
|
4275
|
+
},
|
|
4276
|
+
{
|
|
4277
|
+
code: 6033,
|
|
4278
|
+
name: "FollowingNameError",
|
|
4279
|
+
msg: "following name error"
|
|
4280
|
+
},
|
|
4281
|
+
{
|
|
4282
|
+
code: 6034,
|
|
4283
|
+
name: "NameOpError",
|
|
4284
|
+
msg: "name op error"
|
|
4285
|
+
},
|
|
4286
|
+
{
|
|
4287
|
+
code: 6035,
|
|
4288
|
+
name: "AttConditionsError",
|
|
4289
|
+
msg: "att conditions error"
|
|
4290
|
+
},
|
|
4291
|
+
{
|
|
4292
|
+
code: 6036,
|
|
4293
|
+
name: "TooManyUrls",
|
|
4294
|
+
msg: "too many urls"
|
|
4295
|
+
},
|
|
4296
|
+
{
|
|
4297
|
+
code: 6037,
|
|
4298
|
+
name: "TooManyResponseresolve",
|
|
4299
|
+
msg: "too many responseResolve"
|
|
4300
|
+
},
|
|
4301
|
+
{
|
|
4302
|
+
code: 6038,
|
|
4303
|
+
name: "UserNameEmpty",
|
|
4304
|
+
msg: "user name empty"
|
|
4305
|
+
},
|
|
4306
|
+
{
|
|
4307
|
+
code: 6039,
|
|
4308
|
+
name: "SourceError",
|
|
4309
|
+
msg: "source error"
|
|
4310
|
+
},
|
|
4311
|
+
{
|
|
4312
|
+
code: 6040,
|
|
4313
|
+
name: "AccountResponseLengthError",
|
|
4314
|
+
msg: "account response length error"
|
|
4315
|
+
},
|
|
4316
|
+
{
|
|
4317
|
+
code: 6041,
|
|
4318
|
+
name: "TiktokAttUrlError",
|
|
4319
|
+
msg: "tiktok att url error"
|
|
4320
|
+
},
|
|
4321
|
+
{
|
|
4322
|
+
code: 6042,
|
|
4323
|
+
name: "TiktokJsonPathError",
|
|
4324
|
+
msg: "tiktok json path error"
|
|
4325
|
+
},
|
|
4326
|
+
{
|
|
4327
|
+
code: 6043,
|
|
4328
|
+
name: "XAttUrlError",
|
|
4329
|
+
msg: "x att url error"
|
|
4330
|
+
},
|
|
4331
|
+
{
|
|
4332
|
+
code: 6044,
|
|
4333
|
+
name: "XJsonPathError",
|
|
4334
|
+
msg: "x json path error"
|
|
4335
|
+
},
|
|
4336
|
+
{
|
|
4337
|
+
code: 6045,
|
|
4338
|
+
name: "GoogleAttUrlError",
|
|
4339
|
+
msg: "google att url error"
|
|
4340
|
+
},
|
|
4341
|
+
{
|
|
4342
|
+
code: 6046,
|
|
4343
|
+
name: "GoogleJsonPathError",
|
|
4344
|
+
msg: "google json path error"
|
|
4345
|
+
},
|
|
4346
|
+
{
|
|
4347
|
+
code: 6047,
|
|
4348
|
+
name: "XiaohongshuAttUrlError",
|
|
4349
|
+
msg: "xiaohongshu att url error"
|
|
4350
|
+
},
|
|
4351
|
+
{
|
|
4352
|
+
code: 6048,
|
|
4353
|
+
name: "XiaohongshuJsonPathError",
|
|
4354
|
+
msg: "xiaohongshu json path error"
|
|
4355
|
+
}
|
|
4356
|
+
],
|
|
4357
|
+
types: [
|
|
4358
|
+
{
|
|
4359
|
+
name: "AttNetworkRequest",
|
|
4360
|
+
type: {
|
|
4361
|
+
kind: "struct",
|
|
4362
|
+
fields: [
|
|
4363
|
+
{
|
|
4364
|
+
name: "url",
|
|
4365
|
+
type: "string"
|
|
4366
|
+
},
|
|
4367
|
+
{
|
|
4368
|
+
name: "header",
|
|
4369
|
+
type: "string"
|
|
4370
|
+
},
|
|
4371
|
+
{
|
|
4372
|
+
name: "method",
|
|
4373
|
+
type: "string"
|
|
4374
|
+
},
|
|
4375
|
+
{
|
|
4376
|
+
name: "body",
|
|
4377
|
+
type: "string"
|
|
4378
|
+
}
|
|
4379
|
+
]
|
|
4380
|
+
}
|
|
4381
|
+
},
|
|
4382
|
+
{
|
|
4383
|
+
name: "AttNetworkResponseResolve",
|
|
4384
|
+
type: {
|
|
4385
|
+
kind: "struct",
|
|
4386
|
+
fields: [
|
|
4387
|
+
{
|
|
4388
|
+
name: "key_name",
|
|
4389
|
+
type: "string"
|
|
4390
|
+
},
|
|
4391
|
+
{
|
|
4392
|
+
name: "parse_type",
|
|
4393
|
+
type: "string"
|
|
4394
|
+
},
|
|
4395
|
+
{
|
|
4396
|
+
name: "parse_path",
|
|
4397
|
+
type: "string"
|
|
4398
|
+
}
|
|
4399
|
+
]
|
|
4400
|
+
}
|
|
4401
|
+
},
|
|
4402
|
+
{
|
|
4403
|
+
name: "Attestation",
|
|
4404
|
+
type: {
|
|
4405
|
+
kind: "struct",
|
|
4406
|
+
fields: [
|
|
4407
|
+
{
|
|
4408
|
+
name: "recipient",
|
|
4409
|
+
type: {
|
|
4410
|
+
array: [
|
|
4411
|
+
"u8",
|
|
4412
|
+
32
|
|
4413
|
+
]
|
|
4414
|
+
}
|
|
4415
|
+
},
|
|
4416
|
+
{
|
|
4417
|
+
name: "request",
|
|
4418
|
+
type: {
|
|
4419
|
+
defined: {
|
|
4420
|
+
name: "AttNetworkRequest"
|
|
4421
|
+
}
|
|
4422
|
+
}
|
|
4423
|
+
},
|
|
4424
|
+
{
|
|
4425
|
+
name: "response_resolve",
|
|
4426
|
+
type: {
|
|
4427
|
+
vec: {
|
|
4428
|
+
defined: {
|
|
4429
|
+
name: "AttNetworkResponseResolve"
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
}
|
|
4433
|
+
},
|
|
4434
|
+
{
|
|
4435
|
+
name: "data",
|
|
4436
|
+
type: "string"
|
|
4437
|
+
},
|
|
4438
|
+
{
|
|
4439
|
+
name: "att_conditions",
|
|
4440
|
+
type: "string"
|
|
4441
|
+
},
|
|
4442
|
+
{
|
|
4443
|
+
name: "timestamp",
|
|
4444
|
+
type: "u64"
|
|
4445
|
+
},
|
|
4446
|
+
{
|
|
4447
|
+
name: "addition_params",
|
|
4448
|
+
type: "string"
|
|
4449
|
+
},
|
|
4450
|
+
{
|
|
4451
|
+
name: "attestors",
|
|
4452
|
+
type: {
|
|
4453
|
+
vec: {
|
|
4454
|
+
defined: {
|
|
4455
|
+
name: "Attestor"
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
}
|
|
4459
|
+
},
|
|
4460
|
+
{
|
|
4461
|
+
name: "signatures",
|
|
4462
|
+
type: {
|
|
4463
|
+
vec: "bytes"
|
|
4464
|
+
}
|
|
4465
|
+
}
|
|
4466
|
+
]
|
|
4467
|
+
}
|
|
4468
|
+
},
|
|
4469
|
+
{
|
|
4470
|
+
name: "Attestor",
|
|
4471
|
+
type: {
|
|
4472
|
+
kind: "struct",
|
|
4473
|
+
fields: [
|
|
4474
|
+
{
|
|
4475
|
+
name: "attestor_addr",
|
|
4476
|
+
type: {
|
|
4477
|
+
array: [
|
|
4478
|
+
"u8",
|
|
4479
|
+
20
|
|
4480
|
+
]
|
|
4481
|
+
}
|
|
4482
|
+
},
|
|
4483
|
+
{
|
|
4484
|
+
name: "url",
|
|
4485
|
+
type: "string"
|
|
4486
|
+
}
|
|
4487
|
+
]
|
|
4488
|
+
}
|
|
4489
|
+
},
|
|
4490
|
+
{
|
|
4491
|
+
name: "CheckParams",
|
|
4492
|
+
type: {
|
|
4493
|
+
kind: "struct",
|
|
4494
|
+
fields: [
|
|
4495
|
+
{
|
|
4496
|
+
name: "check_type",
|
|
4497
|
+
type: "u32"
|
|
4498
|
+
},
|
|
4499
|
+
{
|
|
4500
|
+
name: "params",
|
|
4501
|
+
type: "string"
|
|
4502
|
+
}
|
|
4503
|
+
]
|
|
4504
|
+
}
|
|
4505
|
+
},
|
|
4506
|
+
{
|
|
4507
|
+
name: "DataBuffer",
|
|
4508
|
+
type: {
|
|
4509
|
+
kind: "struct",
|
|
4510
|
+
fields: [
|
|
4511
|
+
{
|
|
4512
|
+
name: "user",
|
|
4513
|
+
type: "pubkey"
|
|
4514
|
+
},
|
|
4515
|
+
{
|
|
4516
|
+
name: "length",
|
|
4517
|
+
type: "u32"
|
|
4518
|
+
},
|
|
4519
|
+
{
|
|
4520
|
+
name: "data",
|
|
4521
|
+
type: "bytes"
|
|
4522
|
+
}
|
|
4523
|
+
]
|
|
4524
|
+
}
|
|
4525
|
+
},
|
|
4526
|
+
{
|
|
4527
|
+
name: "PrimusState",
|
|
4528
|
+
type: {
|
|
4529
|
+
kind: "struct",
|
|
4530
|
+
fields: [
|
|
4531
|
+
{
|
|
4532
|
+
name: "owner",
|
|
4533
|
+
type: "pubkey"
|
|
4534
|
+
},
|
|
4535
|
+
{
|
|
4536
|
+
name: "attestors",
|
|
4537
|
+
type: {
|
|
4538
|
+
vec: {
|
|
4539
|
+
defined: {
|
|
4540
|
+
name: "Attestor"
|
|
4541
|
+
}
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
},
|
|
4545
|
+
{
|
|
4546
|
+
name: "bump",
|
|
4547
|
+
type: "u8"
|
|
4548
|
+
}
|
|
4549
|
+
]
|
|
4550
|
+
}
|
|
4551
|
+
},
|
|
4552
|
+
{
|
|
4553
|
+
name: "REClaimEvent",
|
|
4554
|
+
type: {
|
|
4555
|
+
kind: "struct",
|
|
4556
|
+
fields: [
|
|
4557
|
+
{
|
|
4558
|
+
name: "id",
|
|
4559
|
+
type: {
|
|
4560
|
+
array: [
|
|
4561
|
+
"u8",
|
|
4562
|
+
32
|
|
4563
|
+
]
|
|
4564
|
+
}
|
|
4565
|
+
},
|
|
4566
|
+
{
|
|
4567
|
+
name: "user",
|
|
4568
|
+
type: "pubkey"
|
|
4569
|
+
},
|
|
4570
|
+
{
|
|
4571
|
+
name: "user_id",
|
|
4572
|
+
type: "string"
|
|
4573
|
+
},
|
|
4574
|
+
{
|
|
4575
|
+
name: "amount",
|
|
4576
|
+
type: "u64"
|
|
4577
|
+
},
|
|
4578
|
+
{
|
|
4579
|
+
name: "index",
|
|
4580
|
+
type: "u32"
|
|
4581
|
+
},
|
|
4582
|
+
{
|
|
4583
|
+
name: "timestamp",
|
|
4584
|
+
type: "u64"
|
|
4585
|
+
},
|
|
4586
|
+
{
|
|
4587
|
+
name: "token_address",
|
|
4588
|
+
type: "pubkey"
|
|
4589
|
+
}
|
|
4590
|
+
]
|
|
4591
|
+
}
|
|
4592
|
+
},
|
|
4593
|
+
{
|
|
4594
|
+
name: "RERecord",
|
|
4595
|
+
type: {
|
|
4596
|
+
kind: "struct",
|
|
4597
|
+
fields: [
|
|
4598
|
+
{
|
|
4599
|
+
name: "id",
|
|
4600
|
+
docs: [
|
|
4601
|
+
"Red envelope ID"
|
|
4602
|
+
],
|
|
4603
|
+
type: {
|
|
4604
|
+
array: [
|
|
4605
|
+
"u8",
|
|
4606
|
+
32
|
|
4607
|
+
]
|
|
4608
|
+
}
|
|
4609
|
+
},
|
|
4610
|
+
{
|
|
4611
|
+
name: "token_type",
|
|
4612
|
+
docs: [
|
|
4613
|
+
"Token type (ERC20 / NATIVE)"
|
|
4614
|
+
],
|
|
4615
|
+
type: "u32"
|
|
4616
|
+
},
|
|
4617
|
+
{
|
|
4618
|
+
name: "re_type",
|
|
4619
|
+
docs: [
|
|
4620
|
+
"Red envelope type"
|
|
4621
|
+
],
|
|
4622
|
+
type: "u32"
|
|
4623
|
+
},
|
|
4624
|
+
{
|
|
4625
|
+
name: "number",
|
|
4626
|
+
docs: [
|
|
4627
|
+
"Number of recipients"
|
|
4628
|
+
],
|
|
4629
|
+
type: "u32"
|
|
4630
|
+
},
|
|
4631
|
+
{
|
|
4632
|
+
name: "remaining_number",
|
|
4633
|
+
docs: [
|
|
4634
|
+
"Remaining recipients"
|
|
4635
|
+
],
|
|
4636
|
+
type: "u32"
|
|
4637
|
+
},
|
|
4638
|
+
{
|
|
4639
|
+
name: "timestamp",
|
|
4640
|
+
docs: [
|
|
4641
|
+
"Timestamp sent"
|
|
4642
|
+
],
|
|
4643
|
+
type: "u64"
|
|
4644
|
+
},
|
|
4645
|
+
{
|
|
4646
|
+
name: "token_address",
|
|
4647
|
+
docs: [
|
|
4648
|
+
"Token address"
|
|
4649
|
+
],
|
|
4650
|
+
type: "pubkey"
|
|
4651
|
+
},
|
|
4652
|
+
{
|
|
4653
|
+
name: "re_sender",
|
|
4654
|
+
docs: [
|
|
4655
|
+
"Sender address"
|
|
4656
|
+
],
|
|
4657
|
+
type: "pubkey"
|
|
4658
|
+
},
|
|
4659
|
+
{
|
|
4660
|
+
name: "check_contract",
|
|
4661
|
+
docs: [
|
|
4662
|
+
"Eligibility check contract"
|
|
4663
|
+
],
|
|
4664
|
+
type: "pubkey"
|
|
4665
|
+
},
|
|
4666
|
+
{
|
|
4667
|
+
name: "amount",
|
|
4668
|
+
docs: [
|
|
4669
|
+
"Total amount"
|
|
4670
|
+
],
|
|
4671
|
+
type: "u64"
|
|
4672
|
+
},
|
|
4673
|
+
{
|
|
4674
|
+
name: "remaining_amount",
|
|
4675
|
+
docs: [
|
|
4676
|
+
"Remaining amount"
|
|
4677
|
+
],
|
|
4678
|
+
type: "u64"
|
|
4679
|
+
},
|
|
4680
|
+
{
|
|
4681
|
+
name: "check_params",
|
|
4682
|
+
docs: [
|
|
4683
|
+
"Eligibility check params"
|
|
4684
|
+
],
|
|
4685
|
+
type: {
|
|
4686
|
+
defined: {
|
|
4687
|
+
name: "CheckParams"
|
|
4688
|
+
}
|
|
4689
|
+
}
|
|
4690
|
+
},
|
|
4691
|
+
{
|
|
4692
|
+
name: "empty_ratio",
|
|
4693
|
+
docs: [
|
|
4694
|
+
"Empty red envelope ratio, 0\u2013100"
|
|
4695
|
+
],
|
|
4696
|
+
type: "u8"
|
|
4697
|
+
},
|
|
4698
|
+
{
|
|
4699
|
+
name: "record_data",
|
|
4700
|
+
docs: [
|
|
4701
|
+
"RE Record account, refer to Account<RERecordData>"
|
|
4702
|
+
],
|
|
4703
|
+
type: "pubkey"
|
|
4704
|
+
}
|
|
4705
|
+
]
|
|
4706
|
+
}
|
|
4707
|
+
},
|
|
4708
|
+
{
|
|
4709
|
+
name: "RERecordData",
|
|
4710
|
+
type: {
|
|
4711
|
+
kind: "struct",
|
|
4712
|
+
fields: [
|
|
4713
|
+
{
|
|
4714
|
+
name: "id",
|
|
4715
|
+
docs: [
|
|
4716
|
+
"Red envelope ID"
|
|
4717
|
+
],
|
|
4718
|
+
type: {
|
|
4719
|
+
array: [
|
|
4720
|
+
"u8",
|
|
4721
|
+
32
|
|
4722
|
+
]
|
|
4723
|
+
}
|
|
4724
|
+
},
|
|
4725
|
+
{
|
|
4726
|
+
name: "amounts",
|
|
4727
|
+
docs: [
|
|
4728
|
+
"Red envelope amount array, containing 0 amounts."
|
|
4729
|
+
],
|
|
4730
|
+
type: {
|
|
4731
|
+
vec: "u64"
|
|
4732
|
+
}
|
|
4733
|
+
},
|
|
4734
|
+
{
|
|
4735
|
+
name: "re_claimed",
|
|
4736
|
+
type: {
|
|
4737
|
+
vec: {
|
|
4738
|
+
array: [
|
|
4739
|
+
"u8",
|
|
4740
|
+
8
|
|
4741
|
+
]
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
}
|
|
4745
|
+
]
|
|
4746
|
+
}
|
|
4747
|
+
},
|
|
4748
|
+
{
|
|
4749
|
+
name: "RESWithdrawEvent",
|
|
4750
|
+
type: {
|
|
4751
|
+
kind: "struct",
|
|
4752
|
+
fields: [
|
|
4753
|
+
{
|
|
4754
|
+
name: "re_id",
|
|
4755
|
+
type: {
|
|
4756
|
+
array: [
|
|
4757
|
+
"u8",
|
|
4758
|
+
32
|
|
4759
|
+
]
|
|
4760
|
+
}
|
|
4761
|
+
},
|
|
4762
|
+
{
|
|
4763
|
+
name: "sender",
|
|
4764
|
+
type: "pubkey"
|
|
4765
|
+
},
|
|
4766
|
+
{
|
|
4767
|
+
name: "amount",
|
|
4768
|
+
type: "u64"
|
|
4769
|
+
},
|
|
4770
|
+
{
|
|
4771
|
+
name: "remaining_number",
|
|
4772
|
+
type: "u32"
|
|
4773
|
+
},
|
|
4774
|
+
{
|
|
4775
|
+
name: "timestamp",
|
|
4776
|
+
type: "u64"
|
|
4777
|
+
}
|
|
4778
|
+
]
|
|
4779
|
+
}
|
|
4780
|
+
},
|
|
4781
|
+
{
|
|
4782
|
+
name: "RESendEvent",
|
|
4783
|
+
type: {
|
|
4784
|
+
kind: "struct",
|
|
4785
|
+
fields: [
|
|
4786
|
+
{
|
|
4787
|
+
name: "id",
|
|
4788
|
+
type: {
|
|
4789
|
+
array: [
|
|
4790
|
+
"u8",
|
|
4791
|
+
32
|
|
4792
|
+
]
|
|
4793
|
+
}
|
|
4794
|
+
},
|
|
4795
|
+
{
|
|
4796
|
+
name: "re_sender",
|
|
4797
|
+
type: "pubkey"
|
|
4798
|
+
},
|
|
4799
|
+
{
|
|
4800
|
+
name: "token_type",
|
|
4801
|
+
type: "u32"
|
|
4802
|
+
},
|
|
4803
|
+
{
|
|
4804
|
+
name: "token_address",
|
|
4805
|
+
type: "pubkey"
|
|
4806
|
+
},
|
|
4807
|
+
{
|
|
4808
|
+
name: "amount",
|
|
4809
|
+
type: "u64"
|
|
4810
|
+
},
|
|
4811
|
+
{
|
|
4812
|
+
name: "re_type",
|
|
4813
|
+
type: "u32"
|
|
4814
|
+
},
|
|
4815
|
+
{
|
|
4816
|
+
name: "number",
|
|
4817
|
+
type: "u32"
|
|
4818
|
+
},
|
|
4819
|
+
{
|
|
4820
|
+
name: "timestamp",
|
|
4821
|
+
type: "u64"
|
|
4822
|
+
},
|
|
4823
|
+
{
|
|
4824
|
+
name: "check_params",
|
|
4825
|
+
type: {
|
|
4826
|
+
defined: {
|
|
4827
|
+
name: "CheckParams"
|
|
4828
|
+
}
|
|
4829
|
+
}
|
|
4830
|
+
},
|
|
4831
|
+
{
|
|
4832
|
+
name: "empty_ratio",
|
|
4833
|
+
type: "u8"
|
|
4834
|
+
}
|
|
4835
|
+
]
|
|
4836
|
+
}
|
|
4837
|
+
},
|
|
4838
|
+
{
|
|
4839
|
+
name: "RESendParam",
|
|
4840
|
+
type: {
|
|
4841
|
+
kind: "struct",
|
|
4842
|
+
fields: [
|
|
4843
|
+
{
|
|
4844
|
+
name: "re_type",
|
|
4845
|
+
docs: [
|
|
4846
|
+
"Red envelope type: 0 = random, 1 = average"
|
|
4847
|
+
],
|
|
4848
|
+
type: "u32"
|
|
4849
|
+
},
|
|
4850
|
+
{
|
|
4851
|
+
name: "number",
|
|
4852
|
+
docs: [
|
|
4853
|
+
"Number of recipients"
|
|
4854
|
+
],
|
|
4855
|
+
type: "u32"
|
|
4856
|
+
},
|
|
4857
|
+
{
|
|
4858
|
+
name: "amount",
|
|
4859
|
+
docs: [
|
|
4860
|
+
"Total amount, the smallest unit"
|
|
4861
|
+
],
|
|
4862
|
+
type: "u64"
|
|
4863
|
+
},
|
|
4864
|
+
{
|
|
4865
|
+
name: "check_contract",
|
|
4866
|
+
docs: [
|
|
4867
|
+
"Eligibility check contract"
|
|
4868
|
+
],
|
|
4869
|
+
type: "pubkey"
|
|
4870
|
+
},
|
|
4871
|
+
{
|
|
4872
|
+
name: "check_params",
|
|
4873
|
+
docs: [
|
|
4874
|
+
"Params passed to check_contract"
|
|
4875
|
+
],
|
|
4876
|
+
type: {
|
|
4877
|
+
defined: {
|
|
4878
|
+
name: "CheckParams"
|
|
4879
|
+
}
|
|
4880
|
+
}
|
|
4881
|
+
},
|
|
4882
|
+
{
|
|
4883
|
+
name: "empty_ratio",
|
|
4884
|
+
docs: [
|
|
4885
|
+
"Empty red envelope ratio, 0\u2013100"
|
|
4886
|
+
],
|
|
4887
|
+
type: "u8"
|
|
4888
|
+
}
|
|
4889
|
+
]
|
|
4890
|
+
}
|
|
4891
|
+
},
|
|
4892
|
+
{
|
|
4893
|
+
name: "RedEnvelopeState",
|
|
4894
|
+
type: {
|
|
4895
|
+
kind: "struct",
|
|
4896
|
+
fields: [
|
|
4897
|
+
{
|
|
4898
|
+
name: "owner",
|
|
4899
|
+
type: "pubkey"
|
|
4900
|
+
},
|
|
4901
|
+
{
|
|
4902
|
+
name: "id_counter",
|
|
4903
|
+
type: "u128"
|
|
4904
|
+
},
|
|
4905
|
+
{
|
|
4906
|
+
name: "primus_zktls",
|
|
4907
|
+
type: "pubkey"
|
|
4908
|
+
},
|
|
4909
|
+
{
|
|
4910
|
+
name: "claim_fee",
|
|
4911
|
+
type: "u64"
|
|
4912
|
+
},
|
|
4913
|
+
{
|
|
4914
|
+
name: "fee_recipient",
|
|
4915
|
+
type: "pubkey"
|
|
4916
|
+
},
|
|
4917
|
+
{
|
|
4918
|
+
name: "withdraw_delay",
|
|
4919
|
+
type: "u64"
|
|
4920
|
+
},
|
|
4921
|
+
{
|
|
4922
|
+
name: "bump",
|
|
4923
|
+
type: "u8"
|
|
4924
|
+
}
|
|
4925
|
+
]
|
|
4926
|
+
}
|
|
4927
|
+
},
|
|
4928
|
+
{
|
|
4929
|
+
name: "TipToken",
|
|
4930
|
+
type: {
|
|
4931
|
+
kind: "struct",
|
|
4932
|
+
fields: [
|
|
4933
|
+
{
|
|
4934
|
+
name: "token_type",
|
|
4935
|
+
docs: [
|
|
4936
|
+
"tokenType is erc20, native or nft. 0 means erc20, 1 means native and 2 means nft."
|
|
4937
|
+
],
|
|
4938
|
+
type: "u32"
|
|
4939
|
+
},
|
|
4940
|
+
{
|
|
4941
|
+
name: "token_address",
|
|
4942
|
+
docs: [
|
|
4943
|
+
"Token address"
|
|
4944
|
+
],
|
|
4945
|
+
type: "pubkey"
|
|
4946
|
+
}
|
|
4947
|
+
]
|
|
4948
|
+
}
|
|
4949
|
+
}
|
|
4950
|
+
]
|
|
4951
|
+
};
|
|
4952
|
+
|
|
4953
|
+
// src/config/zktlsIdl.json
|
|
4954
|
+
var zktlsIdl_default = {
|
|
4955
|
+
address: "3qG9pUbAHfizoqnvj9GxnTPaVgkyb7Ry6Q5vozMYdVAA",
|
|
4956
|
+
metadata: {
|
|
4957
|
+
name: "primus_zktls",
|
|
4958
|
+
version: "0.1.0",
|
|
4959
|
+
spec: "0.1.0",
|
|
4960
|
+
description: "Created with Anchor"
|
|
4961
|
+
},
|
|
4962
|
+
instructions: [
|
|
4963
|
+
{
|
|
4964
|
+
name: "initialize",
|
|
4965
|
+
discriminator: [
|
|
4966
|
+
175,
|
|
4967
|
+
175,
|
|
4968
|
+
109,
|
|
4969
|
+
31,
|
|
4970
|
+
13,
|
|
4971
|
+
152,
|
|
4972
|
+
155,
|
|
4973
|
+
237
|
|
4974
|
+
],
|
|
4975
|
+
accounts: [
|
|
4976
|
+
{
|
|
4977
|
+
name: "state",
|
|
4978
|
+
writable: true,
|
|
4979
|
+
pda: {
|
|
4980
|
+
seeds: [
|
|
4981
|
+
{
|
|
4982
|
+
kind: "const",
|
|
4983
|
+
value: [
|
|
4984
|
+
112,
|
|
4985
|
+
114,
|
|
4986
|
+
105,
|
|
4987
|
+
109,
|
|
4988
|
+
117,
|
|
4989
|
+
115,
|
|
4990
|
+
95,
|
|
4991
|
+
115,
|
|
4992
|
+
116,
|
|
4993
|
+
97,
|
|
4994
|
+
116,
|
|
4995
|
+
101
|
|
4996
|
+
]
|
|
4997
|
+
}
|
|
4998
|
+
]
|
|
4999
|
+
}
|
|
5000
|
+
},
|
|
5001
|
+
{
|
|
5002
|
+
name: "owner",
|
|
5003
|
+
writable: true,
|
|
5004
|
+
signer: true
|
|
5005
|
+
},
|
|
5006
|
+
{
|
|
5007
|
+
name: "system_program",
|
|
5008
|
+
address: "11111111111111111111111111111111"
|
|
5009
|
+
}
|
|
5010
|
+
],
|
|
5011
|
+
args: [
|
|
5012
|
+
{
|
|
5013
|
+
name: "default_addr",
|
|
5014
|
+
type: {
|
|
5015
|
+
array: [
|
|
5016
|
+
"u8",
|
|
5017
|
+
20
|
|
5018
|
+
]
|
|
5019
|
+
}
|
|
5020
|
+
}
|
|
5021
|
+
]
|
|
5022
|
+
},
|
|
5023
|
+
{
|
|
5024
|
+
name: "remove_attestor",
|
|
5025
|
+
discriminator: [
|
|
5026
|
+
108,
|
|
5027
|
+
232,
|
|
5028
|
+
239,
|
|
5029
|
+
229,
|
|
5030
|
+
84,
|
|
5031
|
+
249,
|
|
5032
|
+
29,
|
|
5033
|
+
22
|
|
5034
|
+
],
|
|
5035
|
+
accounts: [
|
|
5036
|
+
{
|
|
5037
|
+
name: "state",
|
|
5038
|
+
writable: true
|
|
5039
|
+
},
|
|
5040
|
+
{
|
|
5041
|
+
name: "owner",
|
|
5042
|
+
writable: true,
|
|
5043
|
+
signer: true,
|
|
5044
|
+
relations: [
|
|
5045
|
+
"state"
|
|
5046
|
+
]
|
|
5047
|
+
}
|
|
5048
|
+
],
|
|
5049
|
+
args: [
|
|
5050
|
+
{
|
|
5051
|
+
name: "target_addr",
|
|
5052
|
+
type: {
|
|
5053
|
+
array: [
|
|
5054
|
+
"u8",
|
|
5055
|
+
20
|
|
5056
|
+
]
|
|
5057
|
+
}
|
|
5058
|
+
}
|
|
5059
|
+
]
|
|
5060
|
+
},
|
|
5061
|
+
{
|
|
5062
|
+
name: "set_attestor",
|
|
5063
|
+
discriminator: [
|
|
5064
|
+
95,
|
|
5065
|
+
11,
|
|
5066
|
+
236,
|
|
5067
|
+
157,
|
|
5068
|
+
234,
|
|
5069
|
+
146,
|
|
5070
|
+
163,
|
|
5071
|
+
237
|
|
5072
|
+
],
|
|
5073
|
+
accounts: [
|
|
5074
|
+
{
|
|
5075
|
+
name: "state",
|
|
5076
|
+
writable: true
|
|
5077
|
+
},
|
|
5078
|
+
{
|
|
5079
|
+
name: "owner",
|
|
5080
|
+
writable: true,
|
|
5081
|
+
signer: true,
|
|
5082
|
+
relations: [
|
|
5083
|
+
"state"
|
|
5084
|
+
]
|
|
5085
|
+
},
|
|
5086
|
+
{
|
|
5087
|
+
name: "system_program",
|
|
5088
|
+
address: "11111111111111111111111111111111"
|
|
5089
|
+
}
|
|
5090
|
+
],
|
|
5091
|
+
args: [
|
|
5092
|
+
{
|
|
5093
|
+
name: "attestor",
|
|
5094
|
+
type: {
|
|
5095
|
+
defined: {
|
|
5096
|
+
name: "Attestor"
|
|
5097
|
+
}
|
|
5098
|
+
}
|
|
5099
|
+
}
|
|
5100
|
+
]
|
|
5101
|
+
},
|
|
5102
|
+
{
|
|
5103
|
+
name: "store_chunk",
|
|
5104
|
+
discriminator: [
|
|
5105
|
+
100,
|
|
5106
|
+
147,
|
|
5107
|
+
78,
|
|
5108
|
+
157,
|
|
5109
|
+
82,
|
|
5110
|
+
197,
|
|
5111
|
+
253,
|
|
5112
|
+
165
|
|
5113
|
+
],
|
|
5114
|
+
accounts: [
|
|
5115
|
+
{
|
|
5116
|
+
name: "data_buffer",
|
|
5117
|
+
writable: true
|
|
5118
|
+
},
|
|
5119
|
+
{
|
|
5120
|
+
name: "user",
|
|
5121
|
+
signer: true,
|
|
5122
|
+
relations: [
|
|
5123
|
+
"data_buffer"
|
|
5124
|
+
]
|
|
5125
|
+
}
|
|
5126
|
+
],
|
|
5127
|
+
args: [
|
|
5128
|
+
{
|
|
5129
|
+
name: "chunk",
|
|
5130
|
+
type: "bytes"
|
|
5131
|
+
}
|
|
5132
|
+
]
|
|
5133
|
+
},
|
|
5134
|
+
{
|
|
5135
|
+
name: "store_close",
|
|
5136
|
+
discriminator: [
|
|
5137
|
+
231,
|
|
5138
|
+
65,
|
|
5139
|
+
66,
|
|
5140
|
+
193,
|
|
5141
|
+
128,
|
|
5142
|
+
236,
|
|
5143
|
+
61,
|
|
5144
|
+
11
|
|
5145
|
+
],
|
|
5146
|
+
accounts: [
|
|
5147
|
+
{
|
|
5148
|
+
name: "data_buffer",
|
|
5149
|
+
writable: true
|
|
5150
|
+
},
|
|
5151
|
+
{
|
|
5152
|
+
name: "user",
|
|
5153
|
+
signer: true,
|
|
5154
|
+
relations: [
|
|
5155
|
+
"data_buffer"
|
|
5156
|
+
]
|
|
5157
|
+
}
|
|
5158
|
+
],
|
|
5159
|
+
args: []
|
|
5160
|
+
},
|
|
5161
|
+
{
|
|
5162
|
+
name: "store_initialize",
|
|
5163
|
+
docs: [
|
|
5164
|
+
"DataBuffer Store"
|
|
5165
|
+
],
|
|
5166
|
+
discriminator: [
|
|
5167
|
+
58,
|
|
5168
|
+
143,
|
|
5169
|
+
215,
|
|
5170
|
+
232,
|
|
5171
|
+
184,
|
|
5172
|
+
29,
|
|
5173
|
+
233,
|
|
5174
|
+
116
|
|
5175
|
+
],
|
|
5176
|
+
accounts: [
|
|
5177
|
+
{
|
|
5178
|
+
name: "data_buffer",
|
|
5179
|
+
writable: true,
|
|
5180
|
+
signer: true
|
|
5181
|
+
},
|
|
5182
|
+
{
|
|
5183
|
+
name: "user",
|
|
5184
|
+
writable: true,
|
|
5185
|
+
signer: true
|
|
5186
|
+
},
|
|
5187
|
+
{
|
|
5188
|
+
name: "system_program",
|
|
5189
|
+
address: "11111111111111111111111111111111"
|
|
5190
|
+
}
|
|
5191
|
+
],
|
|
5192
|
+
args: [
|
|
5193
|
+
{
|
|
5194
|
+
name: "data_length",
|
|
5195
|
+
type: "u32"
|
|
5196
|
+
}
|
|
5197
|
+
]
|
|
5198
|
+
},
|
|
5199
|
+
{
|
|
5200
|
+
name: "verify_attestation",
|
|
5201
|
+
discriminator: [
|
|
5202
|
+
144,
|
|
5203
|
+
30,
|
|
5204
|
+
116,
|
|
5205
|
+
186,
|
|
5206
|
+
33,
|
|
5207
|
+
176,
|
|
5208
|
+
35,
|
|
5209
|
+
60
|
|
5210
|
+
],
|
|
5211
|
+
accounts: [
|
|
5212
|
+
{
|
|
5213
|
+
name: "state",
|
|
5214
|
+
writable: true
|
|
5215
|
+
},
|
|
5216
|
+
{
|
|
5217
|
+
name: "user",
|
|
5218
|
+
signer: true,
|
|
5219
|
+
relations: [
|
|
5220
|
+
"data_buffer"
|
|
5221
|
+
]
|
|
5222
|
+
},
|
|
5223
|
+
{
|
|
5224
|
+
name: "data_buffer",
|
|
5225
|
+
writable: true,
|
|
5226
|
+
optional: true
|
|
5227
|
+
}
|
|
5228
|
+
],
|
|
5229
|
+
args: [
|
|
5230
|
+
{
|
|
5231
|
+
name: "_att",
|
|
5232
|
+
type: {
|
|
5233
|
+
option: {
|
|
5234
|
+
defined: {
|
|
5235
|
+
name: "Attestation"
|
|
5236
|
+
}
|
|
5237
|
+
}
|
|
5238
|
+
}
|
|
5239
|
+
}
|
|
5240
|
+
]
|
|
5241
|
+
}
|
|
5242
|
+
],
|
|
5243
|
+
accounts: [
|
|
5244
|
+
{
|
|
5245
|
+
name: "DataBuffer",
|
|
5246
|
+
discriminator: [
|
|
5247
|
+
235,
|
|
5248
|
+
220,
|
|
5249
|
+
51,
|
|
5250
|
+
248,
|
|
5251
|
+
56,
|
|
5252
|
+
77,
|
|
5253
|
+
241,
|
|
5254
|
+
89
|
|
5255
|
+
]
|
|
5256
|
+
},
|
|
5257
|
+
{
|
|
5258
|
+
name: "PrimusState",
|
|
5259
|
+
discriminator: [
|
|
5260
|
+
200,
|
|
5261
|
+
136,
|
|
5262
|
+
35,
|
|
5263
|
+
84,
|
|
5264
|
+
173,
|
|
5265
|
+
237,
|
|
5266
|
+
163,
|
|
5267
|
+
179
|
|
5268
|
+
]
|
|
5269
|
+
}
|
|
5270
|
+
],
|
|
5271
|
+
events: [
|
|
5272
|
+
{
|
|
5273
|
+
name: "AddAttestorEvent",
|
|
5274
|
+
discriminator: [
|
|
5275
|
+
36,
|
|
5276
|
+
104,
|
|
5277
|
+
4,
|
|
5278
|
+
119,
|
|
5279
|
+
98,
|
|
5280
|
+
31,
|
|
5281
|
+
220,
|
|
5282
|
+
145
|
|
5283
|
+
]
|
|
5284
|
+
},
|
|
5285
|
+
{
|
|
5286
|
+
name: "DelAttestorEvent",
|
|
5287
|
+
discriminator: [
|
|
5288
|
+
103,
|
|
5289
|
+
73,
|
|
5290
|
+
88,
|
|
5291
|
+
10,
|
|
5292
|
+
15,
|
|
5293
|
+
78,
|
|
5294
|
+
23,
|
|
5295
|
+
49
|
|
5296
|
+
]
|
|
5297
|
+
}
|
|
5298
|
+
],
|
|
5299
|
+
errors: [
|
|
5300
|
+
{
|
|
5301
|
+
code: 6e3,
|
|
5302
|
+
name: "Unauthorized",
|
|
5303
|
+
msg: "Unauthorized"
|
|
5304
|
+
},
|
|
5305
|
+
{
|
|
5306
|
+
code: 6001,
|
|
5307
|
+
name: "AttestationExpired",
|
|
5308
|
+
msg: "Attestation expired"
|
|
5309
|
+
},
|
|
5310
|
+
{
|
|
5311
|
+
code: 6002,
|
|
5312
|
+
name: "AttestorLimitReached",
|
|
5313
|
+
msg: "Attestor limit reached"
|
|
5314
|
+
},
|
|
5315
|
+
{
|
|
5316
|
+
code: 6003,
|
|
5317
|
+
name: "AttestorNotFound",
|
|
5318
|
+
msg: "Attestor not found"
|
|
5319
|
+
},
|
|
5320
|
+
{
|
|
5321
|
+
code: 6004,
|
|
5322
|
+
name: "InvalidSignatureLength",
|
|
5323
|
+
msg: "Invalid signature length"
|
|
5324
|
+
},
|
|
5325
|
+
{
|
|
5326
|
+
code: 6005,
|
|
5327
|
+
name: "InvalidSignatureVValue",
|
|
5328
|
+
msg: "Invalid signature v value"
|
|
5329
|
+
},
|
|
5330
|
+
{
|
|
5331
|
+
code: 6006,
|
|
5332
|
+
name: "InvalidSignature",
|
|
5333
|
+
msg: "Invalid signature"
|
|
5334
|
+
},
|
|
5335
|
+
{
|
|
5336
|
+
code: 6007,
|
|
5337
|
+
name: "TooLarge",
|
|
5338
|
+
msg: "Too Large"
|
|
5339
|
+
},
|
|
5340
|
+
{
|
|
5341
|
+
code: 6008,
|
|
5342
|
+
name: "DeserializationFailed",
|
|
5343
|
+
msg: "Deserialization Failed"
|
|
5344
|
+
},
|
|
5345
|
+
{
|
|
5346
|
+
code: 6009,
|
|
5347
|
+
name: "OutOfBounds",
|
|
5348
|
+
msg: "Out Of Bounds"
|
|
5349
|
+
}
|
|
5350
|
+
],
|
|
5351
|
+
types: [
|
|
5352
|
+
{
|
|
5353
|
+
name: "AddAttestorEvent",
|
|
5354
|
+
type: {
|
|
5355
|
+
kind: "struct",
|
|
5356
|
+
fields: [
|
|
5357
|
+
{
|
|
5358
|
+
name: "address",
|
|
5359
|
+
type: {
|
|
5360
|
+
array: [
|
|
5361
|
+
"u8",
|
|
5362
|
+
20
|
|
5363
|
+
]
|
|
5364
|
+
}
|
|
5365
|
+
},
|
|
5366
|
+
{
|
|
5367
|
+
name: "attestor",
|
|
5368
|
+
type: {
|
|
5369
|
+
defined: {
|
|
5370
|
+
name: "Attestor"
|
|
5371
|
+
}
|
|
5372
|
+
}
|
|
5373
|
+
}
|
|
5374
|
+
]
|
|
5375
|
+
}
|
|
5376
|
+
},
|
|
5377
|
+
{
|
|
5378
|
+
name: "AttNetworkRequest",
|
|
5379
|
+
type: {
|
|
5380
|
+
kind: "struct",
|
|
5381
|
+
fields: [
|
|
5382
|
+
{
|
|
5383
|
+
name: "url",
|
|
5384
|
+
type: "string"
|
|
5385
|
+
},
|
|
5386
|
+
{
|
|
5387
|
+
name: "header",
|
|
5388
|
+
type: "string"
|
|
5389
|
+
},
|
|
5390
|
+
{
|
|
5391
|
+
name: "method",
|
|
5392
|
+
type: "string"
|
|
5393
|
+
},
|
|
5394
|
+
{
|
|
5395
|
+
name: "body",
|
|
5396
|
+
type: "string"
|
|
5397
|
+
}
|
|
5398
|
+
]
|
|
5399
|
+
}
|
|
5400
|
+
},
|
|
5401
|
+
{
|
|
5402
|
+
name: "AttNetworkResponseResolve",
|
|
5403
|
+
type: {
|
|
5404
|
+
kind: "struct",
|
|
5405
|
+
fields: [
|
|
5406
|
+
{
|
|
5407
|
+
name: "key_name",
|
|
5408
|
+
type: "string"
|
|
5409
|
+
},
|
|
5410
|
+
{
|
|
5411
|
+
name: "parse_type",
|
|
5412
|
+
type: "string"
|
|
5413
|
+
},
|
|
5414
|
+
{
|
|
5415
|
+
name: "parse_path",
|
|
5416
|
+
type: "string"
|
|
5417
|
+
}
|
|
5418
|
+
]
|
|
5419
|
+
}
|
|
5420
|
+
},
|
|
5421
|
+
{
|
|
5422
|
+
name: "Attestation",
|
|
5423
|
+
type: {
|
|
5424
|
+
kind: "struct",
|
|
5425
|
+
fields: [
|
|
5426
|
+
{
|
|
5427
|
+
name: "recipient",
|
|
5428
|
+
type: {
|
|
5429
|
+
array: [
|
|
5430
|
+
"u8",
|
|
5431
|
+
32
|
|
5432
|
+
]
|
|
5433
|
+
}
|
|
5434
|
+
},
|
|
5435
|
+
{
|
|
5436
|
+
name: "request",
|
|
5437
|
+
type: {
|
|
5438
|
+
defined: {
|
|
5439
|
+
name: "AttNetworkRequest"
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
},
|
|
5443
|
+
{
|
|
5444
|
+
name: "response_resolve",
|
|
5445
|
+
type: {
|
|
5446
|
+
vec: {
|
|
5447
|
+
defined: {
|
|
5448
|
+
name: "AttNetworkResponseResolve"
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
}
|
|
5452
|
+
},
|
|
5453
|
+
{
|
|
5454
|
+
name: "data",
|
|
5455
|
+
type: "string"
|
|
5456
|
+
},
|
|
5457
|
+
{
|
|
5458
|
+
name: "att_conditions",
|
|
5459
|
+
type: "string"
|
|
5460
|
+
},
|
|
5461
|
+
{
|
|
5462
|
+
name: "timestamp",
|
|
5463
|
+
type: "u64"
|
|
5464
|
+
},
|
|
5465
|
+
{
|
|
5466
|
+
name: "addition_params",
|
|
5467
|
+
type: "string"
|
|
5468
|
+
},
|
|
5469
|
+
{
|
|
5470
|
+
name: "attestors",
|
|
5471
|
+
type: {
|
|
5472
|
+
vec: {
|
|
5473
|
+
defined: {
|
|
5474
|
+
name: "Attestor"
|
|
5475
|
+
}
|
|
5476
|
+
}
|
|
5477
|
+
}
|
|
5478
|
+
},
|
|
5479
|
+
{
|
|
5480
|
+
name: "signatures",
|
|
5481
|
+
type: {
|
|
5482
|
+
vec: "bytes"
|
|
5483
|
+
}
|
|
5484
|
+
}
|
|
5485
|
+
]
|
|
5486
|
+
}
|
|
5487
|
+
},
|
|
5488
|
+
{
|
|
5489
|
+
name: "Attestor",
|
|
5490
|
+
type: {
|
|
5491
|
+
kind: "struct",
|
|
5492
|
+
fields: [
|
|
5493
|
+
{
|
|
5494
|
+
name: "attestor_addr",
|
|
5495
|
+
type: {
|
|
5496
|
+
array: [
|
|
5497
|
+
"u8",
|
|
5498
|
+
20
|
|
5499
|
+
]
|
|
5500
|
+
}
|
|
5501
|
+
},
|
|
5502
|
+
{
|
|
5503
|
+
name: "url",
|
|
5504
|
+
type: "string"
|
|
5505
|
+
}
|
|
5506
|
+
]
|
|
5507
|
+
}
|
|
5508
|
+
},
|
|
5509
|
+
{
|
|
5510
|
+
name: "DataBuffer",
|
|
5511
|
+
type: {
|
|
5512
|
+
kind: "struct",
|
|
5513
|
+
fields: [
|
|
5514
|
+
{
|
|
5515
|
+
name: "user",
|
|
5516
|
+
type: "pubkey"
|
|
5517
|
+
},
|
|
5518
|
+
{
|
|
5519
|
+
name: "length",
|
|
5520
|
+
type: "u32"
|
|
5521
|
+
},
|
|
5522
|
+
{
|
|
5523
|
+
name: "data",
|
|
5524
|
+
type: "bytes"
|
|
5525
|
+
}
|
|
5526
|
+
]
|
|
5527
|
+
}
|
|
5528
|
+
},
|
|
5529
|
+
{
|
|
5530
|
+
name: "DelAttestorEvent",
|
|
5531
|
+
type: {
|
|
5532
|
+
kind: "struct",
|
|
5533
|
+
fields: [
|
|
5534
|
+
{
|
|
5535
|
+
name: "address",
|
|
5536
|
+
type: {
|
|
5537
|
+
array: [
|
|
5538
|
+
"u8",
|
|
5539
|
+
20
|
|
5540
|
+
]
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
]
|
|
5544
|
+
}
|
|
5545
|
+
},
|
|
5546
|
+
{
|
|
5547
|
+
name: "PrimusState",
|
|
5548
|
+
type: {
|
|
5549
|
+
kind: "struct",
|
|
5550
|
+
fields: [
|
|
5551
|
+
{
|
|
5552
|
+
name: "owner",
|
|
5553
|
+
type: "pubkey"
|
|
5554
|
+
},
|
|
5555
|
+
{
|
|
5556
|
+
name: "attestors",
|
|
5557
|
+
type: {
|
|
5558
|
+
vec: {
|
|
5559
|
+
defined: {
|
|
5560
|
+
name: "Attestor"
|
|
5561
|
+
}
|
|
5562
|
+
}
|
|
5563
|
+
}
|
|
5564
|
+
},
|
|
5565
|
+
{
|
|
5566
|
+
name: "bump",
|
|
5567
|
+
type: "u8"
|
|
5568
|
+
}
|
|
5569
|
+
]
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
]
|
|
5573
|
+
};
|
|
5574
|
+
|
|
5575
|
+
// src/classes/solana/sdk.ts
|
|
5576
|
+
var anchor2 = __toESM(require("@coral-xyz/anchor"));
|
|
5577
|
+
var import_web33 = require("@solana/web3.js");
|
|
5578
|
+
|
|
5579
|
+
// src/classes/solana/attestation_schema.ts
|
|
5580
|
+
var borsh2 = __toESM(require("borsh"));
|
|
5581
|
+
var { serialize } = borsh2;
|
|
5582
|
+
var Attestor = class {
|
|
5583
|
+
attestorAddr;
|
|
5584
|
+
url;
|
|
5585
|
+
constructor(fields) {
|
|
5586
|
+
this.attestorAddr = fields.attestorAddr;
|
|
5587
|
+
this.url = fields.url;
|
|
5588
|
+
}
|
|
5589
|
+
};
|
|
5590
|
+
var AttNetworkRequest = class {
|
|
5591
|
+
url;
|
|
5592
|
+
header;
|
|
5593
|
+
method;
|
|
5594
|
+
body;
|
|
5595
|
+
constructor(fields) {
|
|
5596
|
+
this.url = fields.url;
|
|
5597
|
+
this.header = fields.header;
|
|
5598
|
+
this.method = fields.method;
|
|
5599
|
+
this.body = fields.body;
|
|
5600
|
+
}
|
|
5601
|
+
};
|
|
5602
|
+
var AttNetworkResponseResolve = class {
|
|
5603
|
+
keyName;
|
|
5604
|
+
parseType;
|
|
5605
|
+
parsePath;
|
|
5606
|
+
constructor(fields) {
|
|
5607
|
+
this.keyName = fields.keyName;
|
|
5608
|
+
this.parseType = fields.parseType;
|
|
5609
|
+
this.parsePath = fields.parsePath;
|
|
5610
|
+
}
|
|
5611
|
+
};
|
|
5612
|
+
var Attestation = class {
|
|
5613
|
+
recipient;
|
|
5614
|
+
request;
|
|
5615
|
+
responseResolve;
|
|
5616
|
+
data;
|
|
5617
|
+
attConditions;
|
|
5618
|
+
timestamp;
|
|
5619
|
+
additionParams;
|
|
5620
|
+
attestors;
|
|
5621
|
+
signatures;
|
|
5622
|
+
constructor(fields) {
|
|
5623
|
+
this.recipient = fields.recipient;
|
|
5624
|
+
this.request = new AttNetworkRequest(fields.request);
|
|
5625
|
+
this.responseResolve = fields.responseResolve.map((x) => new AttNetworkResponseResolve(x));
|
|
5626
|
+
this.data = fields.data;
|
|
5627
|
+
this.attConditions = fields.attConditions;
|
|
5628
|
+
this.timestamp = fields.timestamp;
|
|
5629
|
+
this.additionParams = fields.additionParams;
|
|
5630
|
+
this.attestors = fields.attestors.map((x) => new Attestor(x));
|
|
5631
|
+
this.signatures = fields.signatures;
|
|
5632
|
+
}
|
|
5633
|
+
};
|
|
5634
|
+
var schema = /* @__PURE__ */ new Map([
|
|
5635
|
+
[Attestor, {
|
|
5636
|
+
kind: "struct",
|
|
5637
|
+
fields: [
|
|
5638
|
+
["attestorAddr", [20]],
|
|
5639
|
+
["url", "string"]
|
|
5640
|
+
]
|
|
5641
|
+
}],
|
|
5642
|
+
[AttNetworkRequest, {
|
|
5643
|
+
kind: "struct",
|
|
5644
|
+
fields: [
|
|
5645
|
+
["url", "string"],
|
|
5646
|
+
["header", "string"],
|
|
5647
|
+
["method", "string"],
|
|
5648
|
+
["body", "string"]
|
|
5649
|
+
]
|
|
5650
|
+
}],
|
|
5651
|
+
[AttNetworkResponseResolve, {
|
|
5652
|
+
kind: "struct",
|
|
5653
|
+
fields: [
|
|
5654
|
+
["keyName", "string"],
|
|
5655
|
+
["parseType", "string"],
|
|
5656
|
+
["parsePath", "string"]
|
|
5657
|
+
]
|
|
5658
|
+
}],
|
|
5659
|
+
[Attestation, {
|
|
5660
|
+
kind: "struct",
|
|
5661
|
+
fields: [
|
|
5662
|
+
["recipient", [32]],
|
|
5663
|
+
["request", AttNetworkRequest],
|
|
5664
|
+
["responseResolve", [AttNetworkResponseResolve]],
|
|
5665
|
+
["data", "string"],
|
|
5666
|
+
["attConditions", "string"],
|
|
5667
|
+
["timestamp", "u64"],
|
|
5668
|
+
["additionParams", "string"],
|
|
5669
|
+
["attestors", [Attestor]],
|
|
5670
|
+
["signatures", [["u8"]]]
|
|
5671
|
+
]
|
|
5672
|
+
}]
|
|
5673
|
+
]);
|
|
5674
|
+
function normalizeAttestationInput(obj) {
|
|
5675
|
+
return new Attestation({
|
|
5676
|
+
...obj,
|
|
5677
|
+
request: new AttNetworkRequest(obj.request),
|
|
5678
|
+
responseResolve: obj.responseResolve.map((x) => new AttNetworkResponseResolve(x)),
|
|
5679
|
+
attestors: obj.attestors.map((x) => new Attestor(x))
|
|
5680
|
+
});
|
|
5681
|
+
}
|
|
5682
|
+
function serializeAttestation(attObj) {
|
|
5683
|
+
const borshObj = normalizeAttestationInput(attObj);
|
|
5684
|
+
console.log("attObj", attObj, "serializeAttestation-borshObj", borshObj);
|
|
5685
|
+
const buffer = serialize(schema, borshObj);
|
|
5686
|
+
console.log("attObj=buffer", buffer);
|
|
5687
|
+
return buffer;
|
|
5688
|
+
}
|
|
5689
|
+
|
|
5690
|
+
// src/classes/solana/pda.ts
|
|
5691
|
+
var import_web32 = require("@solana/web3.js");
|
|
5692
|
+
var SEED_PRIMUS_STATE = new TextEncoder().encode("primus_state");
|
|
5693
|
+
var SEED_PRIMUS_RE_STATE = new TextEncoder().encode("red_envelope");
|
|
5694
|
+
var SEED_PRIMUS_RE_RECORD = new TextEncoder().encode("re_record");
|
|
5695
|
+
function getPrimusZktlsPda({
|
|
5696
|
+
programId
|
|
5697
|
+
}) {
|
|
5698
|
+
return import_web32.PublicKey.findProgramAddressSync(
|
|
5699
|
+
[SEED_PRIMUS_STATE],
|
|
5700
|
+
programId
|
|
5701
|
+
);
|
|
5702
|
+
}
|
|
5703
|
+
function getPrimusRedEnvelopePda({
|
|
5704
|
+
programId
|
|
5705
|
+
}) {
|
|
5706
|
+
return import_web32.PublicKey.findProgramAddressSync(
|
|
5707
|
+
[SEED_PRIMUS_RE_STATE],
|
|
5708
|
+
programId
|
|
5709
|
+
);
|
|
5710
|
+
}
|
|
5711
|
+
function getPrimusRERecordPda({
|
|
5712
|
+
programId,
|
|
5713
|
+
reId
|
|
5714
|
+
}) {
|
|
5715
|
+
return import_web32.PublicKey.findProgramAddressSync(
|
|
5716
|
+
[SEED_PRIMUS_RE_RECORD, reId],
|
|
5717
|
+
programId
|
|
5718
|
+
);
|
|
5719
|
+
}
|
|
5720
|
+
|
|
5721
|
+
// src/classes/solana/sdk.ts
|
|
5722
|
+
var import_ethers5 = require("ethers");
|
|
5723
|
+
var import_spl_token2 = require("@solana/spl-token");
|
|
5724
|
+
var ERC20_TYPE = 0;
|
|
5725
|
+
var CHUNK_SIZE = 960;
|
|
5726
|
+
var VERBOSE = 0;
|
|
5727
|
+
var RE_USERID_LEN = 8;
|
|
5728
|
+
var NATIVETOKENATTBUFFERMAXLEN = 718;
|
|
5729
|
+
var ERC20TOKENATTBUFFERMAXLEN = 622;
|
|
5730
|
+
async function getATAAndProgramId(connection, mint, owner, allowOwnerOffCurve = false) {
|
|
5731
|
+
const accountInfo = await connection.getAccountInfo(mint);
|
|
5732
|
+
if (!accountInfo) {
|
|
5733
|
+
throw new Error("Mint account does not exist");
|
|
5734
|
+
}
|
|
5735
|
+
const mintOwner = accountInfo.owner;
|
|
5736
|
+
let tokenProgramId;
|
|
5737
|
+
if (mintOwner.equals(import_spl_token2.TOKEN_PROGRAM_ID)) {
|
|
5738
|
+
tokenProgramId = import_spl_token2.TOKEN_PROGRAM_ID;
|
|
5739
|
+
} else if (mintOwner.equals(import_spl_token2.TOKEN_2022_PROGRAM_ID)) {
|
|
5740
|
+
tokenProgramId = import_spl_token2.TOKEN_2022_PROGRAM_ID;
|
|
5741
|
+
} else {
|
|
5742
|
+
throw new Error(
|
|
5743
|
+
`Unknown mint owner: ${mintOwner.toBase58()}. Not SPL or Token-2022`
|
|
5744
|
+
);
|
|
5745
|
+
}
|
|
5746
|
+
const ata = await (0, import_spl_token2.getAssociatedTokenAddress)(
|
|
5747
|
+
mint,
|
|
5748
|
+
owner,
|
|
5749
|
+
allowOwnerOffCurve,
|
|
5750
|
+
tokenProgramId
|
|
5751
|
+
);
|
|
5752
|
+
return { ata, tokenProgramId };
|
|
5753
|
+
}
|
|
5754
|
+
async function waitForTransactionConfirmation(provider, tx, retries = 5, delayMs = 1e3) {
|
|
5755
|
+
for (let i = 0; i < retries; i++) {
|
|
5756
|
+
const txDetails = await provider.connection.getTransaction(tx, {
|
|
5757
|
+
maxSupportedTransactionVersion: 0,
|
|
5758
|
+
commitment: "confirmed"
|
|
5759
|
+
});
|
|
5760
|
+
if (txDetails) {
|
|
5761
|
+
console.log("Transaction details:", txDetails);
|
|
5762
|
+
if (VERBOSE > 2) {
|
|
5763
|
+
console.log("Program logs:", txDetails.meta?.logMessages);
|
|
5764
|
+
}
|
|
5765
|
+
return txDetails;
|
|
5766
|
+
}
|
|
5767
|
+
await new Promise((res) => setTimeout(res, delayMs));
|
|
5768
|
+
}
|
|
5769
|
+
console.warn(`Transaction ${tx} not found after ${retries} retries.`);
|
|
5770
|
+
return null;
|
|
5771
|
+
}
|
|
5772
|
+
async function reSend({
|
|
5773
|
+
redEnvelopeProgram,
|
|
5774
|
+
userKey,
|
|
5775
|
+
provider,
|
|
5776
|
+
tipToken,
|
|
5777
|
+
reSendParam
|
|
5778
|
+
}) {
|
|
5779
|
+
return new Promise(async (resolve, reject) => {
|
|
5780
|
+
let signatureStr;
|
|
5781
|
+
try {
|
|
5782
|
+
const spaceAccount = import_web33.Keypair.generate();
|
|
5783
|
+
const space = 8 + 32 + 4 + 8 * reSendParam.number + 4 + RE_USERID_LEN * reSendParam.number;
|
|
5784
|
+
if (space > 10 * 1024 * 1024 - 256) {
|
|
5785
|
+
throw "Cannot make so large space[" + space.toString() + "]";
|
|
5786
|
+
}
|
|
5787
|
+
const lamports = await provider.connection.getMinimumBalanceForRentExemption(space);
|
|
5788
|
+
console.log("spaceAccount:", spaceAccount.publicKey.toBase58(), "space:", space, "minimum rent:", lamports / 1e9, "SOL");
|
|
5789
|
+
const createIx = import_web33.SystemProgram.createAccount({
|
|
5790
|
+
fromPubkey: userKey,
|
|
5791
|
+
newAccountPubkey: spaceAccount.publicKey,
|
|
5792
|
+
lamports,
|
|
5793
|
+
space,
|
|
5794
|
+
programId: redEnvelopeProgram.programId
|
|
5795
|
+
});
|
|
5796
|
+
debugger;
|
|
5797
|
+
const reRecordDataInitIx = await redEnvelopeProgram.methods.reRecordDataInit().accounts({
|
|
5798
|
+
reRecordData: spaceAccount.publicKey,
|
|
5799
|
+
sender: userKey
|
|
5800
|
+
}).signers([spaceAccount]).instruction();
|
|
5801
|
+
debugger;
|
|
5802
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
5803
|
+
const redEnvelopeState = await redEnvelopeProgram.account.redEnvelopeState.fetch(redEnvelopePda);
|
|
5804
|
+
console.log("idCounter", redEnvelopeState.idCounter.toString());
|
|
5805
|
+
const idCounter = new anchor2.BN(redEnvelopeState.idCounter);
|
|
5806
|
+
const idCounterBytes = idCounter.toArrayLike(Buffer, "le", 16);
|
|
5807
|
+
const reId = Buffer.from(import_ethers5.utils.arrayify(import_ethers5.utils.keccak256(idCounterBytes)));
|
|
5808
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
5809
|
+
let mint = null;
|
|
5810
|
+
let fromTokenAccount = null;
|
|
5811
|
+
let toTokenAccount = null;
|
|
5812
|
+
let tokenProgram = import_spl_token2.TOKEN_PROGRAM_ID;
|
|
5813
|
+
if (tipToken.tokenType == ERC20_TYPE) {
|
|
5814
|
+
mint = tipToken.tokenAddress;
|
|
5815
|
+
const from = await getATAAndProgramId(provider.connection, mint, userKey, false);
|
|
5816
|
+
const to = await getATAAndProgramId(provider.connection, mint, redEnvelopePda, true);
|
|
5817
|
+
if (from.tokenProgramId != to.tokenProgramId) {
|
|
5818
|
+
throw new Error(
|
|
5819
|
+
`from.tokenProgramId ${from.tokenProgramId.toBase58()} not equal to.tokenProgramId ${to.tokenProgramId.toBase58()}`
|
|
5820
|
+
);
|
|
5821
|
+
}
|
|
5822
|
+
fromTokenAccount = from.ata;
|
|
5823
|
+
toTokenAccount = to.ata;
|
|
5824
|
+
tokenProgram = from.tokenProgramId;
|
|
5825
|
+
}
|
|
5826
|
+
debugger;
|
|
5827
|
+
const reSendIx = await redEnvelopeProgram.methods.reSend(Array.from(reId), tipToken, reSendParam).accounts({
|
|
5828
|
+
state: redEnvelopePda,
|
|
5829
|
+
reRecord: reRecordPda,
|
|
5830
|
+
reRecordData: spaceAccount.publicKey,
|
|
5831
|
+
sender: userKey,
|
|
5832
|
+
// SPL
|
|
5833
|
+
fromTokenAccount,
|
|
5834
|
+
toTokenAccount,
|
|
5835
|
+
mint,
|
|
5836
|
+
tokenProgram
|
|
5837
|
+
}).instruction();
|
|
5838
|
+
const tx = new import_web33.Transaction().add(createIx).add(reRecordDataInitIx).add(reSendIx);
|
|
5839
|
+
tx.feePayer = userKey;
|
|
5840
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
5841
|
+
tx.partialSign(spaceAccount);
|
|
5842
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
5843
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
5844
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
5845
|
+
if (isOnChain) {
|
|
5846
|
+
console.log("reSend done, reId: ", reId.toString("hex"), signatureStr);
|
|
5847
|
+
return resolve(signatureStr);
|
|
5848
|
+
} else {
|
|
5849
|
+
const serializeSignedTx = signedTx.serialize();
|
|
5850
|
+
console.log("signedTx", signedTx, serializeSignedTx, tx.recentBlockhash);
|
|
5851
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
5852
|
+
console.log("reSend done, reId: ", reId.toString("hex"), signatureStr);
|
|
5853
|
+
return resolve(signatureStr);
|
|
5854
|
+
}
|
|
5855
|
+
} catch (err) {
|
|
5856
|
+
if (getTxIsOnProcess(err)) {
|
|
5857
|
+
console.log("reSenderWithdraw done");
|
|
5858
|
+
return resolve(signatureStr);
|
|
5859
|
+
} else {
|
|
5860
|
+
console.error("reSend error:", err);
|
|
5861
|
+
const formatErr = formatErrFn(err);
|
|
5862
|
+
return reject(formatErr);
|
|
5863
|
+
}
|
|
5864
|
+
} finally {
|
|
5865
|
+
}
|
|
5866
|
+
});
|
|
5867
|
+
}
|
|
5868
|
+
async function reClaim({
|
|
5869
|
+
redEnvelopeProgram,
|
|
5870
|
+
userKey,
|
|
5871
|
+
provider,
|
|
5872
|
+
zktlsProgram,
|
|
5873
|
+
reId,
|
|
5874
|
+
attObj
|
|
5875
|
+
}) {
|
|
5876
|
+
return new Promise(async (resolve, reject) => {
|
|
5877
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
5878
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
5879
|
+
const [primusZktlsPda] = getPrimusZktlsPda({ programId: zktlsProgram.programId });
|
|
5880
|
+
console.log("primusZktlsPda:", primusZktlsPda.toBase58());
|
|
5881
|
+
console.log("reRecordPda:", reRecordPda.toBase58());
|
|
5882
|
+
const attRecipient = new import_web33.PublicKey(attObj.recipient);
|
|
5883
|
+
const redEnvelopeState = await redEnvelopeProgram.account.redEnvelopeState.fetch(redEnvelopePda);
|
|
5884
|
+
console.log("redEnvelopeState.feeRecipient", redEnvelopeState.feeRecipient.toBase58());
|
|
5885
|
+
const feeRecipient = redEnvelopeState.feeRecipient;
|
|
5886
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
5887
|
+
let tx;
|
|
5888
|
+
let signatureStr;
|
|
5889
|
+
const dataBuffer = anchor2.web3.Keypair.generate();
|
|
5890
|
+
const dataBufferKey = dataBuffer.publicKey;
|
|
5891
|
+
const attBuffer = serializeAttestation(attObj);
|
|
5892
|
+
console.log(`attBuffer.length=${attBuffer.length}`);
|
|
5893
|
+
let storeInitialized = false;
|
|
5894
|
+
let useStoreVersion = false;
|
|
5895
|
+
debugger;
|
|
5896
|
+
if (reRecord.tokenType == ERC20_TYPE && attBuffer.length > ERC20TOKENATTBUFFERMAXLEN || reRecord.tokenType != ERC20_TYPE && attBuffer.length > NATIVETOKENATTBUFFERMAXLEN) {
|
|
5897
|
+
useStoreVersion = true;
|
|
5898
|
+
}
|
|
5899
|
+
try {
|
|
5900
|
+
if (useStoreVersion) {
|
|
5901
|
+
const txStoreInitialize = await zktlsProgram.methods.storeInitialize(attBuffer.length).accounts({ dataBuffer: dataBufferKey, user: userKey }).signers([dataBuffer]).rpc();
|
|
5902
|
+
await waitForTransactionConfirmation(provider, txStoreInitialize);
|
|
5903
|
+
storeInitialized = true;
|
|
5904
|
+
console.log("storeInitialize done");
|
|
5905
|
+
for (let offset = 0; offset < attBuffer.length; offset += CHUNK_SIZE) {
|
|
5906
|
+
const chunk = attBuffer.slice(offset, offset + CHUNK_SIZE);
|
|
5907
|
+
const txStoreChunk = await zktlsProgram.methods.storeChunk(Buffer.from(chunk)).accounts({ dataBuffer: dataBufferKey, user: userKey }).rpc();
|
|
5908
|
+
await waitForTransactionConfirmation(provider, txStoreChunk);
|
|
5909
|
+
}
|
|
5910
|
+
console.log("storeChunk done");
|
|
5911
|
+
}
|
|
5912
|
+
const reRecordData2 = await redEnvelopeProgram.account.reRecordData.fetch(reRecord.recordData);
|
|
5913
|
+
console.log("reRecordData2:", reRecordData2);
|
|
5914
|
+
console.log("reRecord.tokenType:", reRecord.tokenType);
|
|
5915
|
+
const reRecordData = reRecord.recordData;
|
|
5916
|
+
console.log("reRecord.recordData", reRecord.recordData.toBase58());
|
|
5917
|
+
let mint = null;
|
|
5918
|
+
let fromTokenAccount = null;
|
|
5919
|
+
let toTokenAccount = null;
|
|
5920
|
+
let tokenProgram = import_spl_token2.TOKEN_PROGRAM_ID;
|
|
5921
|
+
if (reRecord.tokenType == ERC20_TYPE) {
|
|
5922
|
+
console.log("reRecord.tokenAddress:", reRecord.tokenAddress);
|
|
5923
|
+
mint = reRecord.tokenAddress;
|
|
5924
|
+
const from = await getATAAndProgramId(provider.connection, mint, redEnvelopePda, true);
|
|
5925
|
+
const to = await getATAAndProgramId(provider.connection, mint, attRecipient, false);
|
|
5926
|
+
if (from.tokenProgramId != to.tokenProgramId) {
|
|
5927
|
+
throw new Error(
|
|
5928
|
+
`from.tokenProgramId ${from.tokenProgramId.toBase58()} not equal to.tokenProgramId ${to.tokenProgramId.toBase58()}`
|
|
5929
|
+
);
|
|
5930
|
+
}
|
|
5931
|
+
fromTokenAccount = from.ata;
|
|
5932
|
+
toTokenAccount = to.ata;
|
|
5933
|
+
tokenProgram = from.tokenProgramId;
|
|
5934
|
+
}
|
|
5935
|
+
let _att = attObj;
|
|
5936
|
+
let _dataBufferKey = null;
|
|
5937
|
+
if (useStoreVersion) {
|
|
5938
|
+
_att = null;
|
|
5939
|
+
_dataBufferKey = dataBufferKey;
|
|
5940
|
+
}
|
|
5941
|
+
tx = await redEnvelopeProgram.methods.reClaim(reId, _att).accounts({
|
|
5942
|
+
state: redEnvelopePda,
|
|
5943
|
+
reRecord: reRecordPda,
|
|
5944
|
+
reRecordData,
|
|
5945
|
+
claimer: userKey,
|
|
5946
|
+
primusZktlsProgram: zktlsProgram.programId.toBase58(),
|
|
5947
|
+
primusZktlsState: primusZktlsPda,
|
|
5948
|
+
feeRecipient,
|
|
5949
|
+
attRecipient,
|
|
5950
|
+
dataBuffer: _dataBufferKey,
|
|
5951
|
+
// SPL
|
|
5952
|
+
fromTokenAccount,
|
|
5953
|
+
toTokenAccount,
|
|
5954
|
+
mint,
|
|
5955
|
+
tokenProgram
|
|
5956
|
+
}).transaction();
|
|
5957
|
+
tx.feePayer = userKey;
|
|
5958
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
5959
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
5960
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
5961
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
5962
|
+
if (isOnChain) {
|
|
5963
|
+
console.log("reClaim done", signatureStr);
|
|
5964
|
+
return resolve(signatureStr);
|
|
5965
|
+
} else {
|
|
5966
|
+
const serializeSignedTx = signedTx.serialize();
|
|
5967
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
5968
|
+
console.log("reClaim done ", signatureStr);
|
|
5969
|
+
return resolve(signatureStr);
|
|
5970
|
+
}
|
|
5971
|
+
} catch (err) {
|
|
5972
|
+
if (getTxIsOnProcess(err)) {
|
|
5973
|
+
console.log("reClaim done");
|
|
5974
|
+
} else {
|
|
5975
|
+
console.error("reClaim error:", err);
|
|
5976
|
+
const formatErr = formatErrFn(err);
|
|
5977
|
+
return reject(formatErr);
|
|
5978
|
+
}
|
|
5979
|
+
} finally {
|
|
5980
|
+
if (useStoreVersion && storeInitialized) {
|
|
5981
|
+
try {
|
|
5982
|
+
const txStoreClose = await zktlsProgram.methods.storeClose().accounts({ dataBuffer: dataBufferKey, user: userKey }).rpc();
|
|
5983
|
+
await waitForTransactionConfirmation(provider, txStoreClose);
|
|
5984
|
+
console.log("storeClose done");
|
|
5985
|
+
return resolve(signatureStr);
|
|
5986
|
+
} catch (closeErr) {
|
|
5987
|
+
console.error("Failed to close dataBuffer:", closeErr);
|
|
5988
|
+
}
|
|
5989
|
+
} else {
|
|
5990
|
+
return resolve(signatureStr);
|
|
5991
|
+
}
|
|
5992
|
+
}
|
|
5993
|
+
});
|
|
5994
|
+
}
|
|
5995
|
+
async function reSenderWithdraw({
|
|
5996
|
+
redEnvelopeProgram,
|
|
5997
|
+
userKey,
|
|
5998
|
+
provider,
|
|
5999
|
+
reId
|
|
6000
|
+
}) {
|
|
6001
|
+
return new Promise(async (resolve, reject) => {
|
|
6002
|
+
let tx;
|
|
6003
|
+
let signatureStr;
|
|
6004
|
+
try {
|
|
6005
|
+
const [redEnvelopePda] = getPrimusRedEnvelopePda({ programId: redEnvelopeProgram.programId });
|
|
6006
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
6007
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
6008
|
+
console.log("reRecord.tokenType:", reRecord.tokenType);
|
|
6009
|
+
let mint = null;
|
|
6010
|
+
let fromTokenAccount = null;
|
|
6011
|
+
let toTokenAccount = null;
|
|
6012
|
+
let tokenProgram = import_spl_token2.TOKEN_PROGRAM_ID;
|
|
6013
|
+
if (reRecord.tokenType == ERC20_TYPE) {
|
|
6014
|
+
console.log("reRecord.tokenAddress:", reRecord.tokenAddress);
|
|
6015
|
+
mint = reRecord.tokenAddress;
|
|
6016
|
+
const from = await getATAAndProgramId(provider.connection, mint, redEnvelopePda, true);
|
|
6017
|
+
const to = await getATAAndProgramId(provider.connection, mint, userKey, false);
|
|
6018
|
+
if (from.tokenProgramId != to.tokenProgramId) {
|
|
6019
|
+
throw new Error(
|
|
6020
|
+
`from.tokenProgramId ${from.tokenProgramId.toBase58()} not equal to.tokenProgramId ${to.tokenProgramId.toBase58()}`
|
|
6021
|
+
);
|
|
6022
|
+
}
|
|
6023
|
+
fromTokenAccount = from.ata;
|
|
6024
|
+
toTokenAccount = to.ata;
|
|
6025
|
+
tokenProgram = from.tokenProgramId;
|
|
6026
|
+
}
|
|
6027
|
+
tx = await redEnvelopeProgram.methods.reSenderWithdraw(reId).accounts({
|
|
6028
|
+
state: redEnvelopePda,
|
|
6029
|
+
reRecord: reRecordPda,
|
|
6030
|
+
reSender: userKey,
|
|
6031
|
+
// SPL
|
|
6032
|
+
fromTokenAccount,
|
|
6033
|
+
toTokenAccount,
|
|
6034
|
+
mint,
|
|
6035
|
+
tokenProgram
|
|
6036
|
+
}).transaction();
|
|
6037
|
+
tx.feePayer = userKey;
|
|
6038
|
+
tx.recentBlockhash = (await provider.connection.getLatestBlockhash()).blockhash;
|
|
6039
|
+
const signedTx = await provider.wallet.signTransaction(tx);
|
|
6040
|
+
signatureStr = getTxSigStrFromTx(signedTx);
|
|
6041
|
+
const isOnChain = await getTxIsOnChain(signatureStr, provider.connection);
|
|
6042
|
+
if (isOnChain) {
|
|
6043
|
+
console.log("reSenderWithdraw done", signatureStr);
|
|
6044
|
+
return resolve(signatureStr);
|
|
6045
|
+
} else {
|
|
6046
|
+
const serializeSignedTx = signedTx.serialize();
|
|
6047
|
+
signatureStr = await provider.connection.sendRawTransaction(serializeSignedTx);
|
|
6048
|
+
console.log("reSenderWithdraw done", signatureStr);
|
|
6049
|
+
return resolve(signatureStr);
|
|
6050
|
+
}
|
|
6051
|
+
} catch (err) {
|
|
6052
|
+
if (getTxIsOnProcess(err)) {
|
|
6053
|
+
console.log("reSenderWithdraw done");
|
|
6054
|
+
return resolve(signatureStr);
|
|
6055
|
+
} else {
|
|
6056
|
+
console.error("reSenderWithdraw error:", err);
|
|
6057
|
+
const formatErr = formatErrFn(err);
|
|
6058
|
+
return reject(formatErr);
|
|
6059
|
+
}
|
|
6060
|
+
}
|
|
6061
|
+
});
|
|
6062
|
+
}
|
|
6063
|
+
async function getREInfo({
|
|
6064
|
+
redEnvelopeProgram,
|
|
6065
|
+
reId
|
|
6066
|
+
}) {
|
|
6067
|
+
return new Promise(async (resolve, reject) => {
|
|
6068
|
+
try {
|
|
6069
|
+
const [reRecordPda] = getPrimusRERecordPda({ programId: redEnvelopeProgram.programId, reId });
|
|
6070
|
+
const reRecord = await redEnvelopeProgram.account.reRecord.fetch(reRecordPda);
|
|
6071
|
+
console.log("getREInfo done", reRecord);
|
|
6072
|
+
return resolve(reRecord);
|
|
6073
|
+
} catch (err) {
|
|
6074
|
+
console.error("getREInfo error:", err);
|
|
6075
|
+
const formatErr = formatErrFn(err);
|
|
6076
|
+
return reject(formatErr);
|
|
6077
|
+
}
|
|
6078
|
+
});
|
|
6079
|
+
}
|
|
6080
|
+
|
|
6081
|
+
// src/classes/FundOnSolanaForRedPacket.ts
|
|
6082
|
+
var import_web34 = require("@solana/web3.js");
|
|
6083
|
+
var FundOnSolanaForRedPacket = class {
|
|
6084
|
+
fundContract;
|
|
6085
|
+
provider;
|
|
6086
|
+
constructor() {
|
|
6087
|
+
}
|
|
6088
|
+
async init(provider, chainId) {
|
|
6089
|
+
return new Promise(async (resolve, reject) => {
|
|
6090
|
+
try {
|
|
6091
|
+
this.fundContract = getProgram(redPacketIdl_default, provider);
|
|
6092
|
+
this.provider = provider;
|
|
6093
|
+
resolve("success");
|
|
6094
|
+
} catch (error) {
|
|
6095
|
+
return reject(error);
|
|
6096
|
+
}
|
|
6097
|
+
});
|
|
6098
|
+
}
|
|
6099
|
+
async fund(tokenInfo, sendParam) {
|
|
6100
|
+
return new Promise(async (resolve, reject) => {
|
|
6101
|
+
try {
|
|
6102
|
+
let decimals = 9;
|
|
6103
|
+
let amountOnChain;
|
|
6104
|
+
let formatTokenInfo = { ...tokenInfo };
|
|
6105
|
+
if (tokenInfo.tokenType === 1) {
|
|
6106
|
+
formatTokenInfo.tokenAddress = anchor3.web3.PublicKey.default;
|
|
6107
|
+
amountOnChain = toTokenAmount(sendParam.amount, decimals);
|
|
6108
|
+
} else if (tokenInfo.tokenType === 0) {
|
|
6109
|
+
decimals = await getTokenDecimals(tokenInfo.tokenAddress, this.provider.connection);
|
|
6110
|
+
amountOnChain = toTokenAmount(sendParam.amount, decimals);
|
|
6111
|
+
formatTokenInfo.tokenAddress = new import_web34.PublicKey(tokenInfo.tokenAddress);
|
|
6112
|
+
}
|
|
6113
|
+
const reSendParam = {
|
|
6114
|
+
...sendParam,
|
|
6115
|
+
amount: amountOnChain,
|
|
6116
|
+
checkContract: sendParam.checkContract || anchor3.web3.PublicKey.default
|
|
6117
|
+
};
|
|
6118
|
+
const result = await reSend({
|
|
6119
|
+
redEnvelopeProgram: this.fundContract,
|
|
6120
|
+
userKey: this.provider.publicKey,
|
|
6121
|
+
provider: this.provider,
|
|
6122
|
+
tipToken: formatTokenInfo,
|
|
6123
|
+
reSendParam
|
|
6124
|
+
});
|
|
6125
|
+
resolve(result);
|
|
6126
|
+
} catch (error) {
|
|
6127
|
+
return reject(error);
|
|
6128
|
+
}
|
|
6129
|
+
});
|
|
6130
|
+
}
|
|
6131
|
+
async claim(redPacketId, attestation) {
|
|
6132
|
+
return new Promise(async (resolve, reject) => {
|
|
6133
|
+
try {
|
|
6134
|
+
const zktlsProgram = getProgram(zktlsIdl_default, this.provider);
|
|
6135
|
+
const attObj = formatAttestation(attestation);
|
|
6136
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6137
|
+
const result = await reClaim({
|
|
6138
|
+
redEnvelopeProgram: this.fundContract,
|
|
6139
|
+
userKey: this.provider.publicKey,
|
|
6140
|
+
provider: this.provider,
|
|
6141
|
+
zktlsProgram,
|
|
6142
|
+
reId: formatReId,
|
|
6143
|
+
attObj
|
|
6144
|
+
});
|
|
6145
|
+
return resolve(result);
|
|
6146
|
+
} catch (error) {
|
|
6147
|
+
return reject(error);
|
|
6148
|
+
}
|
|
6149
|
+
});
|
|
6150
|
+
}
|
|
6151
|
+
async withdraw(redPacketId) {
|
|
6152
|
+
return new Promise(async (resolve, reject) => {
|
|
6153
|
+
try {
|
|
6154
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6155
|
+
const result = await reSenderWithdraw({
|
|
6156
|
+
redEnvelopeProgram: this.fundContract,
|
|
6157
|
+
userKey: this.provider.publicKey,
|
|
6158
|
+
provider: this.provider,
|
|
6159
|
+
reId: formatReId
|
|
6160
|
+
});
|
|
6161
|
+
return resolve(result);
|
|
6162
|
+
} catch (error) {
|
|
6163
|
+
return reject(error);
|
|
6164
|
+
}
|
|
6165
|
+
});
|
|
6166
|
+
}
|
|
6167
|
+
async getRedPacketInfo(redPacketId) {
|
|
6168
|
+
return new Promise(async (resolve, reject) => {
|
|
6169
|
+
try {
|
|
6170
|
+
let formatReId = hexToUint8Array(redPacketId);
|
|
6171
|
+
const result = await getREInfo({ redEnvelopeProgram: this.fundContract, reId: formatReId });
|
|
6172
|
+
const redpacketInfo = { ...result, id: redPacketId };
|
|
6173
|
+
return resolve(redpacketInfo);
|
|
6174
|
+
} catch (error) {
|
|
6175
|
+
return reject(error);
|
|
6176
|
+
}
|
|
6177
|
+
});
|
|
6178
|
+
}
|
|
6179
|
+
async decodeReSendEvent(eventData) {
|
|
6180
|
+
return await decodeReSendEvent(eventData);
|
|
6181
|
+
}
|
|
6182
|
+
async decodeClaimEvent(eventData) {
|
|
6183
|
+
return await decodeClaimEvent(eventData);
|
|
6184
|
+
}
|
|
6185
|
+
};
|
|
6186
|
+
|
|
6187
|
+
// src/classes/ZktlsSdk.ts
|
|
6188
|
+
var import_zktls_js_sdk = require("@primuslabs/zktls-js-sdk");
|
|
6189
|
+
var ZktlsSdk = class {
|
|
6190
|
+
zkTlsSdk;
|
|
6191
|
+
constructor() {
|
|
6192
|
+
}
|
|
6193
|
+
getZkTlsSdk() {
|
|
6194
|
+
return this.zkTlsSdk;
|
|
6195
|
+
}
|
|
6196
|
+
async init(appId) {
|
|
6197
|
+
return new Promise(async (resolve, reject) => {
|
|
6198
|
+
try {
|
|
6199
|
+
this.zkTlsSdk = new import_zktls_js_sdk.PrimusZKTLS();
|
|
6200
|
+
let platformDevice = "pc";
|
|
6201
|
+
const isIpad = () => {
|
|
6202
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
6203
|
+
const isTabletSize = window.innerWidth > 768 && window.innerWidth < 1366;
|
|
6204
|
+
return /ipad/.test(userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 0 && isTabletSize;
|
|
6205
|
+
};
|
|
6206
|
+
if (navigator.userAgent.toLocaleLowerCase().includes("android")) {
|
|
6207
|
+
platformDevice = "android";
|
|
6208
|
+
} else if (navigator.userAgent.toLocaleLowerCase().includes("iphone") || isIpad()) {
|
|
6209
|
+
platformDevice = "ios";
|
|
6210
|
+
}
|
|
6211
|
+
console.log("init appId", appId, platformDevice);
|
|
6212
|
+
const extensionVersion = await this.zkTlsSdk.init(
|
|
6213
|
+
appId,
|
|
6214
|
+
"",
|
|
6215
|
+
{ platform: platformDevice }
|
|
6216
|
+
);
|
|
6217
|
+
resolve(extensionVersion);
|
|
6218
|
+
} catch (error) {
|
|
6219
|
+
return reject(error);
|
|
6220
|
+
}
|
|
6221
|
+
});
|
|
6222
|
+
}
|
|
6223
|
+
async attest(attestParams, signFn, backUrl) {
|
|
6224
|
+
return new Promise(async (resolve, reject) => {
|
|
6225
|
+
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
6226
|
+
const { socialPlatform, userIdentifier, address } = attestParams;
|
|
6227
|
+
const { id: templateId, field } = DATASOURCETEMPLATESMAP[socialPlatform];
|
|
6228
|
+
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
6229
|
+
templateId,
|
|
6230
|
+
address
|
|
6231
|
+
);
|
|
6232
|
+
if (backUrl) {
|
|
6233
|
+
attRequest.setBackUrl(backUrl);
|
|
6234
|
+
}
|
|
6235
|
+
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
6236
|
+
attRequest.setAttConditions([
|
|
6237
|
+
[
|
|
6238
|
+
{
|
|
6239
|
+
field,
|
|
6240
|
+
op: "STREQ",
|
|
6241
|
+
value: userIdentifier
|
|
6242
|
+
}
|
|
6243
|
+
]
|
|
6244
|
+
]);
|
|
6245
|
+
const signParams = attRequest.toJsonString();
|
|
6246
|
+
const signature = await signFn(signParams);
|
|
6247
|
+
if (!signature) {
|
|
6248
|
+
return reject(`appSignature is empty!`);
|
|
6249
|
+
}
|
|
6250
|
+
try {
|
|
6251
|
+
const formatAttestParams = {
|
|
6252
|
+
attRequest: {
|
|
6253
|
+
...JSON.parse(signParams)
|
|
6254
|
+
},
|
|
6255
|
+
appSignature: signature
|
|
6256
|
+
};
|
|
6257
|
+
const attestation = await this.zkTlsSdk.startAttestation(
|
|
6258
|
+
JSON.stringify(formatAttestParams)
|
|
6259
|
+
);
|
|
6260
|
+
return resolve(attestation);
|
|
6261
|
+
} catch (error) {
|
|
6262
|
+
return reject(error);
|
|
6263
|
+
}
|
|
6264
|
+
});
|
|
6265
|
+
}
|
|
6266
|
+
async attestCommon(attestParams) {
|
|
6267
|
+
const { templateId, address, signFn, conditions, additionParams, backUrl } = attestParams;
|
|
6268
|
+
return new Promise(async (resolve, reject) => {
|
|
6269
|
+
console.log("this.zkTlsSdk", this.zkTlsSdk);
|
|
6270
|
+
const attRequest = this.zkTlsSdk.generateRequestParams(
|
|
6271
|
+
templateId,
|
|
6272
|
+
address
|
|
6273
|
+
);
|
|
6274
|
+
if (backUrl) {
|
|
6275
|
+
attRequest.setBackUrl(backUrl);
|
|
6276
|
+
}
|
|
6277
|
+
console.log(`attRequest: ${JSON.stringify(attRequest)}`);
|
|
6278
|
+
if (conditions) {
|
|
6279
|
+
attRequest.setAttConditions(conditions);
|
|
6280
|
+
}
|
|
6281
|
+
if (additionParams) {
|
|
6282
|
+
console.log("setAdditionParams--", additionParams);
|
|
6283
|
+
attRequest.setAdditionParams(additionParams);
|
|
6284
|
+
}
|
|
6285
|
+
const signParams = attRequest.toJsonString();
|
|
6286
|
+
const signature = await signFn(signParams);
|
|
6287
|
+
if (!signature) {
|
|
6288
|
+
return reject(`appSignature is empty!`);
|
|
6289
|
+
}
|
|
6290
|
+
try {
|
|
6291
|
+
const formatAttestParams = {
|
|
6292
|
+
attRequest: {
|
|
6293
|
+
...JSON.parse(signParams)
|
|
6294
|
+
},
|
|
6295
|
+
appSignature: signature
|
|
6296
|
+
};
|
|
6297
|
+
const attestation = await this.zkTlsSdk.startAttestation(
|
|
6298
|
+
JSON.stringify(formatAttestParams)
|
|
6299
|
+
);
|
|
6300
|
+
return resolve(attestation);
|
|
6301
|
+
} catch (error) {
|
|
6302
|
+
return reject(error);
|
|
6303
|
+
}
|
|
6304
|
+
});
|
|
6305
|
+
}
|
|
6306
|
+
};
|
|
6307
|
+
|
|
6308
|
+
// src/index.ts
|
|
6309
|
+
console.log("SUPPORTEDCHAINIDS444", SUPPORTEDCHAINIDS);
|
|
6310
|
+
var PrimusFund = class {
|
|
6311
|
+
supportedChainIds = SUPPORTEDCHAINIDS;
|
|
6312
|
+
supportedSocialPlatforms = SUPPORTEDSOCIALPLATFORMS;
|
|
6313
|
+
provider;
|
|
6314
|
+
_fund;
|
|
6315
|
+
_fundForRedPacket;
|
|
6316
|
+
_fundOnSolanaForRedPacket;
|
|
6317
|
+
// TODO
|
|
6318
|
+
_zkTlsSdk;
|
|
6319
|
+
static utils = {
|
|
6320
|
+
decodeReSendEvent,
|
|
6321
|
+
decodeClaimEvent
|
|
6322
|
+
};
|
|
6323
|
+
async init(provider, chainId, appId) {
|
|
6324
|
+
return new Promise(async (resolve, reject) => {
|
|
6325
|
+
try {
|
|
6326
|
+
if (!this.supportedChainIds.includes(chainId) && !SUPPORTEDSOLANACHAINIDS.includes(chainId)) {
|
|
6327
|
+
return reject("chainId is not supported");
|
|
6328
|
+
}
|
|
6329
|
+
if (this.supportedChainIds.includes(chainId)) {
|
|
6330
|
+
let formatProvider;
|
|
6331
|
+
let signer;
|
|
6332
|
+
if (provider instanceof import_ethers6.ethers.providers.JsonRpcProvider) {
|
|
6333
|
+
formatProvider = provider;
|
|
6334
|
+
} else {
|
|
6335
|
+
formatProvider = new import_ethers6.ethers.providers.Web3Provider(provider);
|
|
6336
|
+
signer = formatProvider.getSigner();
|
|
6337
|
+
}
|
|
6338
|
+
await formatProvider.ready;
|
|
6339
|
+
const network = await formatProvider.getNetwork();
|
|
6340
|
+
const providerChainId = network.chainId;
|
|
6341
|
+
console.log("init provider", provider, network);
|
|
6342
|
+
console.log("init providerChainId", providerChainId, chainId);
|
|
6343
|
+
if (providerChainId !== chainId) {
|
|
6344
|
+
return reject(`Please connect to the chain with ID ${chainId} first.`);
|
|
6345
|
+
}
|
|
6346
|
+
this.provider = signer ?? formatProvider;
|
|
6347
|
+
this._fund = new Fund();
|
|
6348
|
+
await this._fund.init(this.provider, chainId);
|
|
6349
|
+
this._fundForRedPacket = new FundForRedPacket();
|
|
6350
|
+
await this._fundForRedPacket.init(this.provider, chainId);
|
|
6351
|
+
} else if (SUPPORTEDSOLANACHAINIDS.includes(chainId)) {
|
|
6352
|
+
this.provider = provider;
|
|
6353
|
+
this._fundOnSolanaForRedPacket = new FundOnSolanaForRedPacket();
|
|
6354
|
+
this._fundOnSolanaForRedPacket.init(provider, chainId);
|
|
6355
|
+
}
|
|
6356
|
+
if (appId) {
|
|
6357
|
+
this._zkTlsSdk = new ZktlsSdk();
|
|
6358
|
+
await this._zkTlsSdk.init(appId);
|
|
6359
|
+
}
|
|
6360
|
+
return resolve(true);
|
|
6361
|
+
} catch (error) {
|
|
6362
|
+
return reject(error);
|
|
6363
|
+
}
|
|
6364
|
+
});
|
|
6365
|
+
}
|
|
6366
|
+
async fund(fundParam) {
|
|
6367
|
+
return new Promise(async (resolve, reject) => {
|
|
6368
|
+
try {
|
|
6369
|
+
const { tokenInfo, recipientInfos } = fundParam;
|
|
6370
|
+
if (!recipientInfos || recipientInfos.length === 0) {
|
|
6371
|
+
return reject("recipientInfos is empty");
|
|
6372
|
+
}
|
|
6373
|
+
const hasUnsupportedSocialPlatforms = recipientInfos.some((i) => !this.supportedSocialPlatforms.includes(i.socialPlatform.toLowerCase()));
|
|
6374
|
+
if (hasUnsupportedSocialPlatforms) {
|
|
6375
|
+
return reject("socialPlatform is not supported");
|
|
6376
|
+
}
|
|
6377
|
+
if (tokenInfo.tokenType === 1) {
|
|
6378
|
+
tokenInfo.tokenAddress = import_ethers6.ethers.constants.AddressZero;
|
|
6379
|
+
}
|
|
6380
|
+
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
6381
|
+
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
6382
|
+
let formatUserIdentifier = i.userIdentifier;
|
|
6383
|
+
if (i.socialPlatform === "x" && i.userIdentifier.startsWith("@")) {
|
|
6384
|
+
formatUserIdentifier = i.userIdentifier.slice(1);
|
|
6385
|
+
}
|
|
6386
|
+
return {
|
|
6387
|
+
nftIds: i.nftIds ?? [],
|
|
6388
|
+
socialPlatform: formatSocialPlatform,
|
|
6389
|
+
userIdentifier: formatUserIdentifier,
|
|
6390
|
+
tokenAmount: i.tokenAmount
|
|
6391
|
+
};
|
|
6392
|
+
});
|
|
6393
|
+
if (recipientInfos.length === 1) {
|
|
6394
|
+
const result = await this._fund?.fund(tokenInfo, newFundRecipientInfos[0]);
|
|
6395
|
+
return resolve(result);
|
|
6396
|
+
} else if (recipientInfos.length > 1) {
|
|
6397
|
+
const result = await this._fund?.fundBatch(tokenInfo, newFundRecipientInfos);
|
|
6398
|
+
return resolve(result);
|
|
6399
|
+
}
|
|
6400
|
+
} catch (error) {
|
|
6401
|
+
return reject(error);
|
|
6402
|
+
}
|
|
6403
|
+
});
|
|
6404
|
+
}
|
|
6405
|
+
async approve(fundParam) {
|
|
6406
|
+
return new Promise(async (resolve, reject) => {
|
|
6407
|
+
try {
|
|
6408
|
+
const { tokenInfo, recipientInfos } = fundParam;
|
|
6409
|
+
if (!recipientInfos || recipientInfos.length === 0) {
|
|
6410
|
+
return reject("recipientInfos is empty");
|
|
6411
|
+
}
|
|
6412
|
+
const hasUnsupportedSocialPlatforms = recipientInfos.some((i) => !this.supportedSocialPlatforms.includes(i.socialPlatform.toLowerCase()));
|
|
6413
|
+
if (hasUnsupportedSocialPlatforms) {
|
|
6414
|
+
return reject("socialPlatform is not supported");
|
|
6415
|
+
}
|
|
6416
|
+
if (tokenInfo.tokenType === 1) {
|
|
6417
|
+
tokenInfo.tokenAddress = import_ethers6.ethers.constants.AddressZero;
|
|
6418
|
+
}
|
|
6419
|
+
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
6420
|
+
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
6421
|
+
let formatUserIdentifier = i.userIdentifier;
|
|
6422
|
+
if (i.socialPlatform === "x" && i.userIdentifier.startsWith("@")) {
|
|
6423
|
+
formatUserIdentifier = i.userIdentifier.slice(1);
|
|
6424
|
+
}
|
|
6425
|
+
return {
|
|
6426
|
+
nftIds: i.nftIds ?? [],
|
|
6427
|
+
socialPlatform: formatSocialPlatform,
|
|
2973
6428
|
userIdentifier: formatUserIdentifier,
|
|
2974
6429
|
tokenAmount: i.tokenAmount
|
|
2975
6430
|
};
|
|
@@ -2993,7 +6448,7 @@ var PrimusFund = class {
|
|
|
2993
6448
|
return reject("socialPlatform is not supported");
|
|
2994
6449
|
}
|
|
2995
6450
|
if (tokenInfo.tokenType === 1) {
|
|
2996
|
-
tokenInfo.tokenAddress =
|
|
6451
|
+
tokenInfo.tokenAddress = import_ethers6.ethers.constants.AddressZero;
|
|
2997
6452
|
}
|
|
2998
6453
|
const newFundRecipientInfos = recipientInfos.map((i) => {
|
|
2999
6454
|
const formatSocialPlatform = i.socialPlatform.toLowerCase();
|
|
@@ -3212,10 +6667,15 @@ var PrimusFund = class {
|
|
|
3212
6667
|
}
|
|
3213
6668
|
});
|
|
3214
6669
|
}
|
|
3215
|
-
async getRedPacketInfo(redPacketId) {
|
|
6670
|
+
async getRedPacketInfo(redPacketId, chainId) {
|
|
3216
6671
|
return new Promise(async (resolve, reject) => {
|
|
3217
6672
|
try {
|
|
3218
|
-
|
|
6673
|
+
let result;
|
|
6674
|
+
if (chainId && typeof chainId === "string") {
|
|
6675
|
+
result = await this._fundOnSolanaForRedPacket?.getRedPacketInfo(redPacketId);
|
|
6676
|
+
} else {
|
|
6677
|
+
result = await this._fundForRedPacket?.getRedPacketInfo(redPacketId);
|
|
6678
|
+
}
|
|
3219
6679
|
return resolve(result);
|
|
3220
6680
|
} catch (error) {
|
|
3221
6681
|
return reject(error);
|
|
@@ -3253,6 +6713,52 @@ var PrimusFund = class {
|
|
|
3253
6713
|
}
|
|
3254
6714
|
});
|
|
3255
6715
|
}
|
|
6716
|
+
async fundonSolanaForRedPacket(fundParam) {
|
|
6717
|
+
return new Promise(async (resolve, reject) => {
|
|
6718
|
+
try {
|
|
6719
|
+
const { tokenInfo, sendParam } = fundParam;
|
|
6720
|
+
const result = await this._fundOnSolanaForRedPacket?.fund(tokenInfo, sendParam);
|
|
6721
|
+
return resolve(result);
|
|
6722
|
+
} catch (error) {
|
|
6723
|
+
return reject(error);
|
|
6724
|
+
}
|
|
6725
|
+
});
|
|
6726
|
+
}
|
|
6727
|
+
async claimOnSolanaForRedPacket(redPacketId, attestation) {
|
|
6728
|
+
return new Promise(async (resolve, reject) => {
|
|
6729
|
+
try {
|
|
6730
|
+
let formatAttestation2 = { ...attestation, responseResolve: attestation.reponseResolve };
|
|
6731
|
+
delete formatAttestation2.reponseResolve;
|
|
6732
|
+
const result = await this._fundOnSolanaForRedPacket?.claim(redPacketId, formatAttestation2);
|
|
6733
|
+
return resolve(result);
|
|
6734
|
+
} catch (error) {
|
|
6735
|
+
return reject(error);
|
|
6736
|
+
}
|
|
6737
|
+
});
|
|
6738
|
+
}
|
|
6739
|
+
async withdrawOnSolanaForRedPacket(redPacketId) {
|
|
6740
|
+
return new Promise(async (resolve, reject) => {
|
|
6741
|
+
try {
|
|
6742
|
+
const result = await this._fundOnSolanaForRedPacket?.withdraw(redPacketId);
|
|
6743
|
+
return resolve(result);
|
|
6744
|
+
} catch (error) {
|
|
6745
|
+
return reject(error);
|
|
6746
|
+
}
|
|
6747
|
+
});
|
|
6748
|
+
}
|
|
6749
|
+
// async testReSend(params: any) {
|
|
6750
|
+
// const p = getProgram(redPacketIdl, params.provider)
|
|
6751
|
+
// await testReSend({ redEnvelopeProgram: p, ...params })
|
|
6752
|
+
// }
|
|
6753
|
+
// async testReClaim(params: any) {
|
|
6754
|
+
// const resPacketP = getProgram(redPacketIdl, params.provider)
|
|
6755
|
+
// const zktlsP = getProgram(zktlsIdl, params.provider)
|
|
6756
|
+
// await testReClaim({ redEnvelopeProgram: resPacketP, zktlsProgram: zktlsP, ...params })
|
|
6757
|
+
// }
|
|
6758
|
+
// async testReSenderWithdraw(params: any) {
|
|
6759
|
+
// const resPacketP = getProgram(redPacketIdl, params.provider)
|
|
6760
|
+
// await testReSenderWithdraw({ redEnvelopeProgram: resPacketP, ...params })
|
|
6761
|
+
// }
|
|
3256
6762
|
};
|
|
3257
6763
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3258
6764
|
0 && (module.exports = {
|