@streamflow/distributor 12.3.0 → 12.5.0-alpha.p366.24de361
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/cjs/index.cjs +442 -23
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +1 -0
- package/dist/cjs/solana/descriptor/aligned_distributor.d.cts +82 -2
- package/dist/cjs/solana/descriptor/merkle_distributor.d.cts +182 -2
- package/dist/cjs/solana/index.cjs +442 -23
- package/dist/cjs/solana/index.cjs.map +1 -1
- package/dist/cjs/solana/index.d.cts +57 -3
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +442 -23
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/solana/descriptor/aligned_distributor.d.ts +82 -2
- package/dist/esm/solana/descriptor/idl/aligned_distributor.json +82 -2
- package/dist/esm/solana/descriptor/idl/merkle_distributor.json +182 -2
- package/dist/esm/solana/descriptor/merkle_distributor.d.ts +182 -2
- package/dist/esm/solana/index.d.ts +57 -3
- package/dist/esm/solana/index.js +440 -24
- package/dist/esm/solana/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
var web3_js = require('@solana/web3.js');
|
|
4
4
|
var BN = require('bn.js');
|
|
5
|
+
var buffer = require('buffer');
|
|
5
6
|
require('@solana/wallet-adapter-base');
|
|
6
7
|
var anchor = require('@coral-xyz/anchor');
|
|
7
8
|
var splToken = require('@solana/spl-token');
|
|
8
9
|
var common = require('@streamflow/common');
|
|
9
|
-
var buffer = require('buffer');
|
|
10
10
|
|
|
11
11
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
|
|
@@ -108,6 +108,7 @@ __export(constants_exports, {
|
|
|
108
108
|
ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
|
|
109
109
|
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
110
110
|
ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
|
|
111
|
+
ATTESTATION_PREFIX: () => ATTESTATION_PREFIX,
|
|
111
112
|
CLAIM_STATUS_PREFIX: () => CLAIM_STATUS_PREFIX,
|
|
112
113
|
DISTRIBUTOR_ADMIN_OFFSET: () => DISTRIBUTOR_ADMIN_OFFSET,
|
|
113
114
|
DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
|
|
@@ -117,6 +118,7 @@ __export(constants_exports, {
|
|
|
117
118
|
MERKLE_DISTRIBUTOR_ERRORS: () => MERKLE_DISTRIBUTOR_ERRORS,
|
|
118
119
|
ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
|
|
119
120
|
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
121
|
+
SOLANA_ATTESTATION_SERVICE_PROGRAM_ID: () => SOLANA_ATTESTATION_SERVICE_PROGRAM_ID,
|
|
120
122
|
SOL_FEE_PROGRAM_VERSION: () => SOL_FEE_PROGRAM_VERSION,
|
|
121
123
|
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
122
124
|
TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
|
|
@@ -127,7 +129,7 @@ var merkle_distributor_default = {
|
|
|
127
129
|
address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
128
130
|
metadata: {
|
|
129
131
|
name: "merkle_distributor",
|
|
130
|
-
version: "1.
|
|
132
|
+
version: "1.10.0",
|
|
131
133
|
spec: "0.1.0",
|
|
132
134
|
description: "A Solana program for distributing tokens according to a Merkle root.",
|
|
133
135
|
repository: "https://github.com/streamflow-finance/distributor"
|
|
@@ -1053,6 +1055,81 @@ var merkle_distributor_default = {
|
|
|
1053
1055
|
],
|
|
1054
1056
|
args: []
|
|
1055
1057
|
},
|
|
1058
|
+
{
|
|
1059
|
+
name: "disable_kyc",
|
|
1060
|
+
discriminator: [
|
|
1061
|
+
204,
|
|
1062
|
+
167,
|
|
1063
|
+
59,
|
|
1064
|
+
181,
|
|
1065
|
+
11,
|
|
1066
|
+
7,
|
|
1067
|
+
254,
|
|
1068
|
+
148
|
|
1069
|
+
],
|
|
1070
|
+
accounts: [
|
|
1071
|
+
{
|
|
1072
|
+
name: "distributor",
|
|
1073
|
+
docs: [
|
|
1074
|
+
"The [MerkleDistributor]."
|
|
1075
|
+
],
|
|
1076
|
+
writable: true
|
|
1077
|
+
},
|
|
1078
|
+
{
|
|
1079
|
+
name: "admin",
|
|
1080
|
+
docs: [
|
|
1081
|
+
"Admin signer."
|
|
1082
|
+
],
|
|
1083
|
+
writable: true,
|
|
1084
|
+
signer: true
|
|
1085
|
+
}
|
|
1086
|
+
],
|
|
1087
|
+
args: []
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
name: "enable_kyc",
|
|
1091
|
+
discriminator: [
|
|
1092
|
+
28,
|
|
1093
|
+
10,
|
|
1094
|
+
11,
|
|
1095
|
+
99,
|
|
1096
|
+
6,
|
|
1097
|
+
44,
|
|
1098
|
+
96,
|
|
1099
|
+
77
|
|
1100
|
+
],
|
|
1101
|
+
accounts: [
|
|
1102
|
+
{
|
|
1103
|
+
name: "distributor",
|
|
1104
|
+
docs: [
|
|
1105
|
+
"The [MerkleDistributor]."
|
|
1106
|
+
],
|
|
1107
|
+
writable: true
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
name: "admin",
|
|
1111
|
+
docs: [
|
|
1112
|
+
"Admin signer."
|
|
1113
|
+
],
|
|
1114
|
+
writable: true,
|
|
1115
|
+
signer: true
|
|
1116
|
+
},
|
|
1117
|
+
{
|
|
1118
|
+
name: "credential"
|
|
1119
|
+
},
|
|
1120
|
+
{
|
|
1121
|
+
name: "schema"
|
|
1122
|
+
}
|
|
1123
|
+
],
|
|
1124
|
+
args: [
|
|
1125
|
+
{
|
|
1126
|
+
name: "nonce",
|
|
1127
|
+
type: {
|
|
1128
|
+
option: "bytes"
|
|
1129
|
+
}
|
|
1130
|
+
}
|
|
1131
|
+
]
|
|
1132
|
+
},
|
|
1056
1133
|
{
|
|
1057
1134
|
name: "new_claim",
|
|
1058
1135
|
discriminator: [
|
|
@@ -2758,6 +2835,31 @@ var merkle_distributor_default = {
|
|
|
2758
2835
|
code: 6033,
|
|
2759
2836
|
name: "ClawbackRequestDelayPending",
|
|
2760
2837
|
msg: "Clawback request delay has not passed yet"
|
|
2838
|
+
},
|
|
2839
|
+
{
|
|
2840
|
+
code: 6034,
|
|
2841
|
+
name: "MissingAttestation",
|
|
2842
|
+
msg: "Attestation is required for this Distributor"
|
|
2843
|
+
},
|
|
2844
|
+
{
|
|
2845
|
+
code: 6035,
|
|
2846
|
+
name: "InvalidAttestation",
|
|
2847
|
+
msg: "Invalid attestation account"
|
|
2848
|
+
},
|
|
2849
|
+
{
|
|
2850
|
+
code: 6036,
|
|
2851
|
+
name: "AttestationExpired",
|
|
2852
|
+
msg: "Attestation has expired"
|
|
2853
|
+
},
|
|
2854
|
+
{
|
|
2855
|
+
code: 6037,
|
|
2856
|
+
name: "InvalidAttestationCredentialSchema",
|
|
2857
|
+
msg: "Invalid attestation credential or schema"
|
|
2858
|
+
},
|
|
2859
|
+
{
|
|
2860
|
+
code: 6038,
|
|
2861
|
+
name: "KycNonceTooLong",
|
|
2862
|
+
msg: "KYC nonce is too long"
|
|
2761
2863
|
}
|
|
2762
2864
|
],
|
|
2763
2865
|
types: [
|
|
@@ -3021,6 +3123,69 @@ var merkle_distributor_default = {
|
|
|
3021
3123
|
]
|
|
3022
3124
|
}
|
|
3023
3125
|
},
|
|
3126
|
+
{
|
|
3127
|
+
name: "KycConfig",
|
|
3128
|
+
docs: [
|
|
3129
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
3130
|
+
],
|
|
3131
|
+
type: {
|
|
3132
|
+
kind: "struct",
|
|
3133
|
+
fields: [
|
|
3134
|
+
{
|
|
3135
|
+
name: "is_set",
|
|
3136
|
+
docs: [
|
|
3137
|
+
"Whether KYC is required to claim the Airdrop"
|
|
3138
|
+
],
|
|
3139
|
+
type: "bool"
|
|
3140
|
+
},
|
|
3141
|
+
{
|
|
3142
|
+
name: "credential",
|
|
3143
|
+
docs: [
|
|
3144
|
+
"SAS Credential account used to create attestations"
|
|
3145
|
+
],
|
|
3146
|
+
type: "pubkey"
|
|
3147
|
+
},
|
|
3148
|
+
{
|
|
3149
|
+
name: "schema",
|
|
3150
|
+
docs: [
|
|
3151
|
+
"SAS Schema account that attestation must conform to"
|
|
3152
|
+
],
|
|
3153
|
+
type: "pubkey"
|
|
3154
|
+
},
|
|
3155
|
+
{
|
|
3156
|
+
name: "nonce_len",
|
|
3157
|
+
docs: [
|
|
3158
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
3159
|
+
],
|
|
3160
|
+
type: "u8"
|
|
3161
|
+
},
|
|
3162
|
+
{
|
|
3163
|
+
name: "nonce",
|
|
3164
|
+
docs: [
|
|
3165
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
3166
|
+
],
|
|
3167
|
+
type: {
|
|
3168
|
+
array: [
|
|
3169
|
+
"u8",
|
|
3170
|
+
32
|
|
3171
|
+
]
|
|
3172
|
+
}
|
|
3173
|
+
},
|
|
3174
|
+
{
|
|
3175
|
+
name: "buffer",
|
|
3176
|
+
docs: [
|
|
3177
|
+
"Buffer for additional fields"
|
|
3178
|
+
],
|
|
3179
|
+
type: {
|
|
3180
|
+
array: [
|
|
3181
|
+
"u8",
|
|
3182
|
+
32
|
|
3183
|
+
]
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
]
|
|
3187
|
+
}
|
|
3188
|
+
},
|
|
3024
3189
|
{
|
|
3025
3190
|
name: "MerkleDistributor",
|
|
3026
3191
|
docs: [
|
|
@@ -3313,10 +3478,18 @@ var merkle_distributor_default = {
|
|
|
3313
3478
|
type: "u64"
|
|
3314
3479
|
},
|
|
3315
3480
|
{
|
|
3316
|
-
name: "
|
|
3481
|
+
name: "kyc_config",
|
|
3317
3482
|
docs: [
|
|
3318
3483
|
"Buffers for additional fields"
|
|
3319
3484
|
],
|
|
3485
|
+
type: {
|
|
3486
|
+
defined: {
|
|
3487
|
+
name: "KycConfig"
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
},
|
|
3491
|
+
{
|
|
3492
|
+
name: "buffer_1",
|
|
3320
3493
|
type: {
|
|
3321
3494
|
array: [
|
|
3322
3495
|
"u8",
|
|
@@ -3332,6 +3505,15 @@ var merkle_distributor_default = {
|
|
|
3332
3505
|
32
|
|
3333
3506
|
]
|
|
3334
3507
|
}
|
|
3508
|
+
},
|
|
3509
|
+
{
|
|
3510
|
+
name: "buffer_3",
|
|
3511
|
+
type: {
|
|
3512
|
+
array: [
|
|
3513
|
+
"u8",
|
|
3514
|
+
32
|
|
3515
|
+
]
|
|
3516
|
+
}
|
|
3335
3517
|
}
|
|
3336
3518
|
]
|
|
3337
3519
|
}
|
|
@@ -3383,7 +3565,7 @@ var aligned_distributor_default = {
|
|
|
3383
3565
|
address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
3384
3566
|
metadata: {
|
|
3385
3567
|
name: "aligned_distributor",
|
|
3386
|
-
version: "1.
|
|
3568
|
+
version: "1.10.0",
|
|
3387
3569
|
spec: "0.1.0",
|
|
3388
3570
|
description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
|
|
3389
3571
|
},
|
|
@@ -4651,6 +4833,69 @@ var aligned_distributor_default = {
|
|
|
4651
4833
|
]
|
|
4652
4834
|
}
|
|
4653
4835
|
},
|
|
4836
|
+
{
|
|
4837
|
+
name: "KycConfig",
|
|
4838
|
+
docs: [
|
|
4839
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
4840
|
+
],
|
|
4841
|
+
type: {
|
|
4842
|
+
kind: "struct",
|
|
4843
|
+
fields: [
|
|
4844
|
+
{
|
|
4845
|
+
name: "is_set",
|
|
4846
|
+
docs: [
|
|
4847
|
+
"Whether KYC is required to claim the Airdrop"
|
|
4848
|
+
],
|
|
4849
|
+
type: "bool"
|
|
4850
|
+
},
|
|
4851
|
+
{
|
|
4852
|
+
name: "credential",
|
|
4853
|
+
docs: [
|
|
4854
|
+
"SAS Credential account used to create attestations"
|
|
4855
|
+
],
|
|
4856
|
+
type: "pubkey"
|
|
4857
|
+
},
|
|
4858
|
+
{
|
|
4859
|
+
name: "schema",
|
|
4860
|
+
docs: [
|
|
4861
|
+
"SAS Schema account that attestation must conform to"
|
|
4862
|
+
],
|
|
4863
|
+
type: "pubkey"
|
|
4864
|
+
},
|
|
4865
|
+
{
|
|
4866
|
+
name: "nonce_len",
|
|
4867
|
+
docs: [
|
|
4868
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
4869
|
+
],
|
|
4870
|
+
type: "u8"
|
|
4871
|
+
},
|
|
4872
|
+
{
|
|
4873
|
+
name: "nonce",
|
|
4874
|
+
docs: [
|
|
4875
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
4876
|
+
],
|
|
4877
|
+
type: {
|
|
4878
|
+
array: [
|
|
4879
|
+
"u8",
|
|
4880
|
+
32
|
|
4881
|
+
]
|
|
4882
|
+
}
|
|
4883
|
+
},
|
|
4884
|
+
{
|
|
4885
|
+
name: "buffer",
|
|
4886
|
+
docs: [
|
|
4887
|
+
"Buffer for additional fields"
|
|
4888
|
+
],
|
|
4889
|
+
type: {
|
|
4890
|
+
array: [
|
|
4891
|
+
"u8",
|
|
4892
|
+
32
|
|
4893
|
+
]
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
]
|
|
4897
|
+
}
|
|
4898
|
+
},
|
|
4654
4899
|
{
|
|
4655
4900
|
name: "MerkleDistributor",
|
|
4656
4901
|
docs: [
|
|
@@ -4943,10 +5188,18 @@ var aligned_distributor_default = {
|
|
|
4943
5188
|
type: "u64"
|
|
4944
5189
|
},
|
|
4945
5190
|
{
|
|
4946
|
-
name: "
|
|
5191
|
+
name: "kyc_config",
|
|
4947
5192
|
docs: [
|
|
4948
5193
|
"Buffers for additional fields"
|
|
4949
5194
|
],
|
|
5195
|
+
type: {
|
|
5196
|
+
defined: {
|
|
5197
|
+
name: "KycConfig"
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
},
|
|
5201
|
+
{
|
|
5202
|
+
name: "buffer_1",
|
|
4950
5203
|
type: {
|
|
4951
5204
|
array: [
|
|
4952
5205
|
"u8",
|
|
@@ -4962,6 +5215,15 @@ var aligned_distributor_default = {
|
|
|
4962
5215
|
32
|
|
4963
5216
|
]
|
|
4964
5217
|
}
|
|
5218
|
+
},
|
|
5219
|
+
{
|
|
5220
|
+
name: "buffer_3",
|
|
5221
|
+
type: {
|
|
5222
|
+
array: [
|
|
5223
|
+
"u8",
|
|
5224
|
+
32
|
|
5225
|
+
]
|
|
5226
|
+
}
|
|
4965
5227
|
}
|
|
4966
5228
|
]
|
|
4967
5229
|
}
|
|
@@ -5152,9 +5414,11 @@ var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
|
5152
5414
|
var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
5153
5415
|
var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
5154
5416
|
var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
5417
|
+
var ATTESTATION_PREFIX = Buffer.from("attestation", "utf-8");
|
|
5155
5418
|
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
5156
5419
|
var AIRDROP_CLAIM_FEE = BigInt(1e7);
|
|
5157
5420
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new web3_js.PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
5421
|
+
var SOLANA_ATTESTATION_SERVICE_PROGRAM_ID = new web3_js.PublicKey("22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG");
|
|
5158
5422
|
var ONE_IN_BASIS_POINTS = BigInt(1e4);
|
|
5159
5423
|
var SOL_FEE_PROGRAM_VERSION = 1;
|
|
5160
5424
|
var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
@@ -5353,6 +5617,46 @@ function getClaimantStatusPda(programId, distributor, claimant) {
|
|
|
5353
5617
|
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
5354
5618
|
return web3_js.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
5355
5619
|
}
|
|
5620
|
+
function getKycNonceBytes(nonce) {
|
|
5621
|
+
if (nonce == null) {
|
|
5622
|
+
return null;
|
|
5623
|
+
}
|
|
5624
|
+
if (typeof nonce === "string") {
|
|
5625
|
+
return buffer.Buffer.from(nonce);
|
|
5626
|
+
}
|
|
5627
|
+
const nonceBytes = Array.from(nonce);
|
|
5628
|
+
for (const byte of nonceBytes) {
|
|
5629
|
+
if (!Number.isInteger(byte) || byte < 0 || byte > 255) {
|
|
5630
|
+
throw new Error("KYC nonce must contain only bytes");
|
|
5631
|
+
}
|
|
5632
|
+
}
|
|
5633
|
+
return buffer.Buffer.from(nonceBytes);
|
|
5634
|
+
}
|
|
5635
|
+
async function getAttestationNonce({
|
|
5636
|
+
claimant,
|
|
5637
|
+
nonce
|
|
5638
|
+
}) {
|
|
5639
|
+
const nonceBytes = getKycNonceBytes(nonce);
|
|
5640
|
+
if (!nonceBytes || nonceBytes.length === 0) {
|
|
5641
|
+
return claimant;
|
|
5642
|
+
}
|
|
5643
|
+
const hash = await globalThis.crypto.subtle.digest(
|
|
5644
|
+
"SHA-256",
|
|
5645
|
+
buffer.Buffer.concat([buffer.Buffer.from(`${claimant.toString()}:`), nonceBytes])
|
|
5646
|
+
);
|
|
5647
|
+
return new web3_js.PublicKey(new Uint8Array(hash));
|
|
5648
|
+
}
|
|
5649
|
+
function getAttestationPda({
|
|
5650
|
+
credential,
|
|
5651
|
+
schema,
|
|
5652
|
+
nonce,
|
|
5653
|
+
programId = SOLANA_ATTESTATION_SERVICE_PROGRAM_ID
|
|
5654
|
+
}) {
|
|
5655
|
+
return web3_js.PublicKey.findProgramAddressSync(
|
|
5656
|
+
[ATTESTATION_PREFIX, credential.toBuffer(), schema.toBuffer(), nonce.toBuffer()],
|
|
5657
|
+
programId
|
|
5658
|
+
)[0];
|
|
5659
|
+
}
|
|
5356
5660
|
function getEventAuthorityPda(programId) {
|
|
5357
5661
|
const seeds = [buffer.Buffer.from("__event_authority")];
|
|
5358
5662
|
return web3_js.PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
@@ -5562,29 +5866,45 @@ var BaseDistributorClient = class {
|
|
|
5562
5866
|
extParams.invoker.publicKey
|
|
5563
5867
|
);
|
|
5564
5868
|
const claimStatus = await this.getClaim(claimStatusPublicKey);
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5869
|
+
let attestation = data.attestation;
|
|
5870
|
+
if (!attestation && distributor.kycConfig.isSet) {
|
|
5871
|
+
attestation = getAttestationPda({
|
|
5872
|
+
credential: distributor.kycConfig.credential,
|
|
5873
|
+
schema: distributor.kycConfig.schema,
|
|
5874
|
+
nonce: await getAttestationNonce({
|
|
5570
5875
|
claimant: extParams.invoker.publicKey,
|
|
5571
|
-
|
|
5572
|
-
|
|
5573
|
-
|
|
5574
|
-
|
|
5876
|
+
nonce: distributor.kycConfig.nonce.slice(0, distributor.kycConfig.nonceLen)
|
|
5877
|
+
})
|
|
5878
|
+
});
|
|
5879
|
+
}
|
|
5880
|
+
const remainingAccounts = this.getClaimRemainingAccounts(data, attestation);
|
|
5881
|
+
if (!claimStatus) {
|
|
5882
|
+
let newClaimMethod = this.merkleDistributorProgram.methods.newClaim(new BN__default.default(data.amountUnlocked), new BN__default.default(data.amountLocked), data.proof).accounts({
|
|
5883
|
+
distributor: distributorPublicKey,
|
|
5884
|
+
to: invokerTokens,
|
|
5885
|
+
claimant: extParams.invoker.publicKey,
|
|
5886
|
+
tokenProgram: tokenProgramId,
|
|
5887
|
+
program: this.programId
|
|
5888
|
+
});
|
|
5889
|
+
if (remainingAccounts.length > 0) {
|
|
5890
|
+
newClaimMethod = newClaimMethod.remainingAccounts(remainingAccounts);
|
|
5891
|
+
}
|
|
5892
|
+
ixs.push(await newClaimMethod.instruction());
|
|
5575
5893
|
}
|
|
5576
5894
|
const nowTs = new BN__default.default(Math.floor(Date.now() / 1e3));
|
|
5577
5895
|
if (claimStatus || new BN__default.default(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
5578
5896
|
const claimMethod = distributor.programVersion >= SOL_FEE_PROGRAM_VERSION ? this.merkleDistributorProgram.methods.claimLockedV2 : this.merkleDistributorProgram.methods.claimLocked;
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5897
|
+
let claimLockedMethod = claimMethod().accounts({
|
|
5898
|
+
distributor: distributorPublicKey,
|
|
5899
|
+
to: invokerTokens,
|
|
5900
|
+
claimant: extParams.invoker.publicKey,
|
|
5901
|
+
tokenProgram: tokenProgramId,
|
|
5902
|
+
program: this.programId
|
|
5903
|
+
});
|
|
5904
|
+
if (remainingAccounts.length > 0) {
|
|
5905
|
+
claimLockedMethod = claimLockedMethod.remainingAccounts(remainingAccounts);
|
|
5906
|
+
}
|
|
5907
|
+
ixs.push(await claimLockedMethod.instruction());
|
|
5588
5908
|
}
|
|
5589
5909
|
if (distributor.programVersion >= SOL_FEE_PROGRAM_VERSION) {
|
|
5590
5910
|
return ixs;
|
|
@@ -5663,6 +5983,78 @@ var BaseDistributorClient = class {
|
|
|
5663
5983
|
);
|
|
5664
5984
|
return ixs;
|
|
5665
5985
|
}
|
|
5986
|
+
async enableKyc(data, extParams) {
|
|
5987
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
5988
|
+
const invoker = executionParams.invoker.publicKey;
|
|
5989
|
+
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5990
|
+
const ixs = await common.createAndEstimateTransaction(
|
|
5991
|
+
(params) => this.prepareEnableKycInstructions(data, params),
|
|
5992
|
+
executionParams
|
|
5993
|
+
);
|
|
5994
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
|
|
5995
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
5996
|
+
this.connection,
|
|
5997
|
+
executionParams.invoker,
|
|
5998
|
+
tx,
|
|
5999
|
+
{
|
|
6000
|
+
hash,
|
|
6001
|
+
context,
|
|
6002
|
+
commitment: this.getCommitment()
|
|
6003
|
+
},
|
|
6004
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
6005
|
+
);
|
|
6006
|
+
return { ixs, txId: signature };
|
|
6007
|
+
}
|
|
6008
|
+
async prepareEnableKycInstructions(data, extParams) {
|
|
6009
|
+
if (!extParams.invoker.publicKey) {
|
|
6010
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6011
|
+
}
|
|
6012
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
6013
|
+
ixs.push(
|
|
6014
|
+
await this.merkleDistributorProgram.methods.enableKyc(getKycNonceBytes(data.nonce)).accounts({
|
|
6015
|
+
distributor: common.pk(data.id),
|
|
6016
|
+
admin: extParams.invoker.publicKey,
|
|
6017
|
+
credential: common.pk(data.credential),
|
|
6018
|
+
schema: common.pk(data.schema)
|
|
6019
|
+
}).instruction()
|
|
6020
|
+
);
|
|
6021
|
+
return ixs;
|
|
6022
|
+
}
|
|
6023
|
+
async disableKyc(data, extParams) {
|
|
6024
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
6025
|
+
const invoker = executionParams.invoker.publicKey;
|
|
6026
|
+
common.invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6027
|
+
const ixs = await common.createAndEstimateTransaction(
|
|
6028
|
+
(params) => this.prepareDisableKycInstructions(data, params),
|
|
6029
|
+
executionParams
|
|
6030
|
+
);
|
|
6031
|
+
const { tx, hash, context } = await common.prepareTransaction(this.connection, ixs, invoker);
|
|
6032
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
6033
|
+
this.connection,
|
|
6034
|
+
executionParams.invoker,
|
|
6035
|
+
tx,
|
|
6036
|
+
{
|
|
6037
|
+
hash,
|
|
6038
|
+
context,
|
|
6039
|
+
commitment: this.getCommitment()
|
|
6040
|
+
},
|
|
6041
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
6042
|
+
);
|
|
6043
|
+
return { ixs, txId: signature };
|
|
6044
|
+
}
|
|
6045
|
+
async prepareDisableKycInstructions(data, extParams) {
|
|
6046
|
+
if (!extParams.invoker.publicKey) {
|
|
6047
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6048
|
+
}
|
|
6049
|
+
const ixs = common.prepareBaseInstructions(this.connection, extParams);
|
|
6050
|
+
ixs.push(
|
|
6051
|
+
await this.merkleDistributorProgram.methods.disableKyc().accounts({
|
|
6052
|
+
distributor: common.pk(data.id),
|
|
6053
|
+
admin: extParams.invoker.publicKey
|
|
6054
|
+
}).instruction()
|
|
6055
|
+
);
|
|
6056
|
+
return ixs;
|
|
6057
|
+
}
|
|
5666
6058
|
async prepareClawbackInstructions(data, extParams) {
|
|
5667
6059
|
if (!extParams.invoker.publicKey) {
|
|
5668
6060
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5799,6 +6191,11 @@ var BaseDistributorClient = class {
|
|
|
5799
6191
|
async getClaim(claimStatus) {
|
|
5800
6192
|
return this.connection.getAccountInfo(common.pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
5801
6193
|
}
|
|
6194
|
+
async getKycConfig(distributor) {
|
|
6195
|
+
const distributorAccount = await this.merkleDistributorProgram.account.merkleDistributor.fetch(common.pk(distributor));
|
|
6196
|
+
common.invariant(distributorAccount, "Distributor account not found");
|
|
6197
|
+
return distributorAccount.kycConfig;
|
|
6198
|
+
}
|
|
5802
6199
|
async getClaims(data) {
|
|
5803
6200
|
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
5804
6201
|
return getClaimantStatusPda(this.programId, new web3_js.PublicKey(id), new web3_js.PublicKey(recipient));
|
|
@@ -5890,6 +6287,25 @@ var BaseDistributorClient = class {
|
|
|
5890
6287
|
unwrapExecutionParams(extParams) {
|
|
5891
6288
|
return common.unwrapExecutionParams(extParams, this.connection);
|
|
5892
6289
|
}
|
|
6290
|
+
/**
|
|
6291
|
+
* Claim support multiple remaining accounts:
|
|
6292
|
+
* - attestation when an Airdrop requires a KYC;
|
|
6293
|
+
* - partner link accounts for custom fee derivation;
|
|
6294
|
+
*/
|
|
6295
|
+
getClaimRemainingAccounts(data, attestation) {
|
|
6296
|
+
const remainingAccounts = [];
|
|
6297
|
+
if (attestation) {
|
|
6298
|
+
remainingAccounts.push({ pubkey: common.pk(attestation), isSigner: false, isWritable: false });
|
|
6299
|
+
}
|
|
6300
|
+
if (data.partnerLink) {
|
|
6301
|
+
remainingAccounts.push({
|
|
6302
|
+
pubkey: common.pk(data.partnerLink.address),
|
|
6303
|
+
isSigner: data.partnerLink.isSigner,
|
|
6304
|
+
isWritable: false
|
|
6305
|
+
});
|
|
6306
|
+
}
|
|
6307
|
+
return remainingAccounts;
|
|
6308
|
+
}
|
|
5893
6309
|
decodeClaimStatus(account) {
|
|
5894
6310
|
if (!account) {
|
|
5895
6311
|
return null;
|
|
@@ -6090,9 +6506,12 @@ exports.calculateDynamicFeeFromSolParams = calculateDynamicFeeFromSolParams;
|
|
|
6090
6506
|
exports.constants = constants_exports;
|
|
6091
6507
|
exports.fetchAirdropFee = fetchAirdropFee;
|
|
6092
6508
|
exports.getAlignedDistributorPda = getAlignedDistributorPda;
|
|
6509
|
+
exports.getAttestationNonce = getAttestationNonce;
|
|
6510
|
+
exports.getAttestationPda = getAttestationPda;
|
|
6093
6511
|
exports.getClaimantStatusPda = getClaimantStatusPda;
|
|
6094
6512
|
exports.getDistributorPda = getDistributorPda;
|
|
6095
6513
|
exports.getEventAuthorityPda = getEventAuthorityPda;
|
|
6514
|
+
exports.getKycNonceBytes = getKycNonceBytes;
|
|
6096
6515
|
exports.getTestOraclePda = getTestOraclePda;
|
|
6097
6516
|
exports.isCompressedClaimStatus = isCompressedClaimStatus;
|
|
6098
6517
|
exports.resolveAirdropFeeLamportsUsingApi = resolveAirdropFeeLamportsUsingApi;
|