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