@streamflow/distributor 12.4.0 → 12.5.0
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
package/dist/esm/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { PublicKey, Connection, SystemProgram } from '@solana/web3.js';
|
|
2
2
|
import BN from 'bn.js';
|
|
3
|
+
import { Buffer as Buffer$1 } from 'buffer';
|
|
3
4
|
import '@solana/wallet-adapter-base';
|
|
4
5
|
import { parseIdlErrors, translateError, Program } from '@coral-xyz/anchor';
|
|
5
6
|
import { NATIVE_MINT, getAssociatedTokenAddressSync, getTransferFeeConfig, createTransferCheckedWithFeeInstruction, createTransferCheckedInstruction } from '@solana/spl-token';
|
|
6
7
|
import { ICluster, multiplyBigIntByNumber, fetchTokenPrice, signAndExecuteTransaction, ContractError, divCeilN, invariant, getNumberFromBN, pk, getBN, buildPartnerOracle, buildSendThrottler, prepareBaseInstructions, getMintAndProgram, ata, prepareWrappedAccount, createAndEstimateTransaction, prepareTransaction, checkOrCreateAtaBatch, unwrapExecutionParams } from '@streamflow/common';
|
|
7
|
-
import { Buffer as Buffer$1 } from 'buffer';
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
10
|
var __export = (target, all) => {
|
|
@@ -31,9 +31,12 @@ __export(solana_exports, {
|
|
|
31
31
|
constants: () => constants_exports,
|
|
32
32
|
fetchAirdropFee: () => fetchAirdropFee,
|
|
33
33
|
getAlignedDistributorPda: () => getAlignedDistributorPda,
|
|
34
|
+
getAttestationNonce: () => getAttestationNonce,
|
|
35
|
+
getAttestationPda: () => getAttestationPda,
|
|
34
36
|
getClaimantStatusPda: () => getClaimantStatusPda,
|
|
35
37
|
getDistributorPda: () => getDistributorPda,
|
|
36
38
|
getEventAuthorityPda: () => getEventAuthorityPda,
|
|
39
|
+
getKycNonceBytes: () => getKycNonceBytes,
|
|
37
40
|
getTestOraclePda: () => getTestOraclePda,
|
|
38
41
|
isCompressedClaimStatus: () => isCompressedClaimStatus,
|
|
39
42
|
resolveAirdropFeeLamportsUsingApi: () => resolveAirdropFeeLamportsUsingApi,
|
|
@@ -131,6 +134,7 @@ __export(constants_exports, {
|
|
|
131
134
|
ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
|
|
132
135
|
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
133
136
|
ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
|
|
137
|
+
ATTESTATION_PREFIX: () => ATTESTATION_PREFIX,
|
|
134
138
|
CLAIM_STATUS_PREFIX: () => CLAIM_STATUS_PREFIX,
|
|
135
139
|
DISTRIBUTOR_ADMIN_OFFSET: () => DISTRIBUTOR_ADMIN_OFFSET,
|
|
136
140
|
DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
|
|
@@ -140,6 +144,7 @@ __export(constants_exports, {
|
|
|
140
144
|
MERKLE_DISTRIBUTOR_ERRORS: () => MERKLE_DISTRIBUTOR_ERRORS,
|
|
141
145
|
ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
|
|
142
146
|
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
147
|
+
SOLANA_ATTESTATION_SERVICE_PROGRAM_ID: () => SOLANA_ATTESTATION_SERVICE_PROGRAM_ID,
|
|
143
148
|
SOL_FEE_PROGRAM_VERSION: () => SOL_FEE_PROGRAM_VERSION,
|
|
144
149
|
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
145
150
|
TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
|
|
@@ -150,7 +155,7 @@ var merkle_distributor_default = {
|
|
|
150
155
|
address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
151
156
|
metadata: {
|
|
152
157
|
name: "merkle_distributor",
|
|
153
|
-
version: "1.
|
|
158
|
+
version: "1.10.0",
|
|
154
159
|
spec: "0.1.0",
|
|
155
160
|
description: "A Solana program for distributing tokens according to a Merkle root.",
|
|
156
161
|
repository: "https://github.com/streamflow-finance/distributor"
|
|
@@ -1076,6 +1081,81 @@ var merkle_distributor_default = {
|
|
|
1076
1081
|
],
|
|
1077
1082
|
args: []
|
|
1078
1083
|
},
|
|
1084
|
+
{
|
|
1085
|
+
name: "disable_kyc",
|
|
1086
|
+
discriminator: [
|
|
1087
|
+
204,
|
|
1088
|
+
167,
|
|
1089
|
+
59,
|
|
1090
|
+
181,
|
|
1091
|
+
11,
|
|
1092
|
+
7,
|
|
1093
|
+
254,
|
|
1094
|
+
148
|
|
1095
|
+
],
|
|
1096
|
+
accounts: [
|
|
1097
|
+
{
|
|
1098
|
+
name: "distributor",
|
|
1099
|
+
docs: [
|
|
1100
|
+
"The [MerkleDistributor]."
|
|
1101
|
+
],
|
|
1102
|
+
writable: true
|
|
1103
|
+
},
|
|
1104
|
+
{
|
|
1105
|
+
name: "admin",
|
|
1106
|
+
docs: [
|
|
1107
|
+
"Admin signer."
|
|
1108
|
+
],
|
|
1109
|
+
writable: true,
|
|
1110
|
+
signer: true
|
|
1111
|
+
}
|
|
1112
|
+
],
|
|
1113
|
+
args: []
|
|
1114
|
+
},
|
|
1115
|
+
{
|
|
1116
|
+
name: "enable_kyc",
|
|
1117
|
+
discriminator: [
|
|
1118
|
+
28,
|
|
1119
|
+
10,
|
|
1120
|
+
11,
|
|
1121
|
+
99,
|
|
1122
|
+
6,
|
|
1123
|
+
44,
|
|
1124
|
+
96,
|
|
1125
|
+
77
|
|
1126
|
+
],
|
|
1127
|
+
accounts: [
|
|
1128
|
+
{
|
|
1129
|
+
name: "distributor",
|
|
1130
|
+
docs: [
|
|
1131
|
+
"The [MerkleDistributor]."
|
|
1132
|
+
],
|
|
1133
|
+
writable: true
|
|
1134
|
+
},
|
|
1135
|
+
{
|
|
1136
|
+
name: "admin",
|
|
1137
|
+
docs: [
|
|
1138
|
+
"Admin signer."
|
|
1139
|
+
],
|
|
1140
|
+
writable: true,
|
|
1141
|
+
signer: true
|
|
1142
|
+
},
|
|
1143
|
+
{
|
|
1144
|
+
name: "credential"
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
name: "schema"
|
|
1148
|
+
}
|
|
1149
|
+
],
|
|
1150
|
+
args: [
|
|
1151
|
+
{
|
|
1152
|
+
name: "nonce",
|
|
1153
|
+
type: {
|
|
1154
|
+
option: "bytes"
|
|
1155
|
+
}
|
|
1156
|
+
}
|
|
1157
|
+
]
|
|
1158
|
+
},
|
|
1079
1159
|
{
|
|
1080
1160
|
name: "new_claim",
|
|
1081
1161
|
discriminator: [
|
|
@@ -2781,6 +2861,31 @@ var merkle_distributor_default = {
|
|
|
2781
2861
|
code: 6033,
|
|
2782
2862
|
name: "ClawbackRequestDelayPending",
|
|
2783
2863
|
msg: "Clawback request delay has not passed yet"
|
|
2864
|
+
},
|
|
2865
|
+
{
|
|
2866
|
+
code: 6034,
|
|
2867
|
+
name: "MissingAttestation",
|
|
2868
|
+
msg: "Attestation is required for this Distributor"
|
|
2869
|
+
},
|
|
2870
|
+
{
|
|
2871
|
+
code: 6035,
|
|
2872
|
+
name: "InvalidAttestation",
|
|
2873
|
+
msg: "Invalid attestation account"
|
|
2874
|
+
},
|
|
2875
|
+
{
|
|
2876
|
+
code: 6036,
|
|
2877
|
+
name: "AttestationExpired",
|
|
2878
|
+
msg: "Attestation has expired"
|
|
2879
|
+
},
|
|
2880
|
+
{
|
|
2881
|
+
code: 6037,
|
|
2882
|
+
name: "InvalidAttestationCredentialSchema",
|
|
2883
|
+
msg: "Invalid attestation credential or schema"
|
|
2884
|
+
},
|
|
2885
|
+
{
|
|
2886
|
+
code: 6038,
|
|
2887
|
+
name: "KycNonceTooLong",
|
|
2888
|
+
msg: "KYC nonce is too long"
|
|
2784
2889
|
}
|
|
2785
2890
|
],
|
|
2786
2891
|
types: [
|
|
@@ -3044,6 +3149,69 @@ var merkle_distributor_default = {
|
|
|
3044
3149
|
]
|
|
3045
3150
|
}
|
|
3046
3151
|
},
|
|
3152
|
+
{
|
|
3153
|
+
name: "KycConfig",
|
|
3154
|
+
docs: [
|
|
3155
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
3156
|
+
],
|
|
3157
|
+
type: {
|
|
3158
|
+
kind: "struct",
|
|
3159
|
+
fields: [
|
|
3160
|
+
{
|
|
3161
|
+
name: "is_set",
|
|
3162
|
+
docs: [
|
|
3163
|
+
"Whether KYC is required to claim the Airdrop"
|
|
3164
|
+
],
|
|
3165
|
+
type: "bool"
|
|
3166
|
+
},
|
|
3167
|
+
{
|
|
3168
|
+
name: "credential",
|
|
3169
|
+
docs: [
|
|
3170
|
+
"SAS Credential account used to create attestations"
|
|
3171
|
+
],
|
|
3172
|
+
type: "pubkey"
|
|
3173
|
+
},
|
|
3174
|
+
{
|
|
3175
|
+
name: "schema",
|
|
3176
|
+
docs: [
|
|
3177
|
+
"SAS Schema account that attestation must conform to"
|
|
3178
|
+
],
|
|
3179
|
+
type: "pubkey"
|
|
3180
|
+
},
|
|
3181
|
+
{
|
|
3182
|
+
name: "nonce_len",
|
|
3183
|
+
docs: [
|
|
3184
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
3185
|
+
],
|
|
3186
|
+
type: "u8"
|
|
3187
|
+
},
|
|
3188
|
+
{
|
|
3189
|
+
name: "nonce",
|
|
3190
|
+
docs: [
|
|
3191
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
3192
|
+
],
|
|
3193
|
+
type: {
|
|
3194
|
+
array: [
|
|
3195
|
+
"u8",
|
|
3196
|
+
32
|
|
3197
|
+
]
|
|
3198
|
+
}
|
|
3199
|
+
},
|
|
3200
|
+
{
|
|
3201
|
+
name: "buffer",
|
|
3202
|
+
docs: [
|
|
3203
|
+
"Buffer for additional fields"
|
|
3204
|
+
],
|
|
3205
|
+
type: {
|
|
3206
|
+
array: [
|
|
3207
|
+
"u8",
|
|
3208
|
+
32
|
|
3209
|
+
]
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
]
|
|
3213
|
+
}
|
|
3214
|
+
},
|
|
3047
3215
|
{
|
|
3048
3216
|
name: "MerkleDistributor",
|
|
3049
3217
|
docs: [
|
|
@@ -3336,10 +3504,18 @@ var merkle_distributor_default = {
|
|
|
3336
3504
|
type: "u64"
|
|
3337
3505
|
},
|
|
3338
3506
|
{
|
|
3339
|
-
name: "
|
|
3507
|
+
name: "kyc_config",
|
|
3340
3508
|
docs: [
|
|
3341
3509
|
"Buffers for additional fields"
|
|
3342
3510
|
],
|
|
3511
|
+
type: {
|
|
3512
|
+
defined: {
|
|
3513
|
+
name: "KycConfig"
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
},
|
|
3517
|
+
{
|
|
3518
|
+
name: "buffer_1",
|
|
3343
3519
|
type: {
|
|
3344
3520
|
array: [
|
|
3345
3521
|
"u8",
|
|
@@ -3355,6 +3531,15 @@ var merkle_distributor_default = {
|
|
|
3355
3531
|
32
|
|
3356
3532
|
]
|
|
3357
3533
|
}
|
|
3534
|
+
},
|
|
3535
|
+
{
|
|
3536
|
+
name: "buffer_3",
|
|
3537
|
+
type: {
|
|
3538
|
+
array: [
|
|
3539
|
+
"u8",
|
|
3540
|
+
32
|
|
3541
|
+
]
|
|
3542
|
+
}
|
|
3358
3543
|
}
|
|
3359
3544
|
]
|
|
3360
3545
|
}
|
|
@@ -3406,7 +3591,7 @@ var aligned_distributor_default = {
|
|
|
3406
3591
|
address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
3407
3592
|
metadata: {
|
|
3408
3593
|
name: "aligned_distributor",
|
|
3409
|
-
version: "1.
|
|
3594
|
+
version: "1.10.0",
|
|
3410
3595
|
spec: "0.1.0",
|
|
3411
3596
|
description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
|
|
3412
3597
|
},
|
|
@@ -4674,6 +4859,69 @@ var aligned_distributor_default = {
|
|
|
4674
4859
|
]
|
|
4675
4860
|
}
|
|
4676
4861
|
},
|
|
4862
|
+
{
|
|
4863
|
+
name: "KycConfig",
|
|
4864
|
+
docs: [
|
|
4865
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
4866
|
+
],
|
|
4867
|
+
type: {
|
|
4868
|
+
kind: "struct",
|
|
4869
|
+
fields: [
|
|
4870
|
+
{
|
|
4871
|
+
name: "is_set",
|
|
4872
|
+
docs: [
|
|
4873
|
+
"Whether KYC is required to claim the Airdrop"
|
|
4874
|
+
],
|
|
4875
|
+
type: "bool"
|
|
4876
|
+
},
|
|
4877
|
+
{
|
|
4878
|
+
name: "credential",
|
|
4879
|
+
docs: [
|
|
4880
|
+
"SAS Credential account used to create attestations"
|
|
4881
|
+
],
|
|
4882
|
+
type: "pubkey"
|
|
4883
|
+
},
|
|
4884
|
+
{
|
|
4885
|
+
name: "schema",
|
|
4886
|
+
docs: [
|
|
4887
|
+
"SAS Schema account that attestation must conform to"
|
|
4888
|
+
],
|
|
4889
|
+
type: "pubkey"
|
|
4890
|
+
},
|
|
4891
|
+
{
|
|
4892
|
+
name: "nonce_len",
|
|
4893
|
+
docs: [
|
|
4894
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
4895
|
+
],
|
|
4896
|
+
type: "u8"
|
|
4897
|
+
},
|
|
4898
|
+
{
|
|
4899
|
+
name: "nonce",
|
|
4900
|
+
docs: [
|
|
4901
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
4902
|
+
],
|
|
4903
|
+
type: {
|
|
4904
|
+
array: [
|
|
4905
|
+
"u8",
|
|
4906
|
+
32
|
|
4907
|
+
]
|
|
4908
|
+
}
|
|
4909
|
+
},
|
|
4910
|
+
{
|
|
4911
|
+
name: "buffer",
|
|
4912
|
+
docs: [
|
|
4913
|
+
"Buffer for additional fields"
|
|
4914
|
+
],
|
|
4915
|
+
type: {
|
|
4916
|
+
array: [
|
|
4917
|
+
"u8",
|
|
4918
|
+
32
|
|
4919
|
+
]
|
|
4920
|
+
}
|
|
4921
|
+
}
|
|
4922
|
+
]
|
|
4923
|
+
}
|
|
4924
|
+
},
|
|
4677
4925
|
{
|
|
4678
4926
|
name: "MerkleDistributor",
|
|
4679
4927
|
docs: [
|
|
@@ -4966,10 +5214,18 @@ var aligned_distributor_default = {
|
|
|
4966
5214
|
type: "u64"
|
|
4967
5215
|
},
|
|
4968
5216
|
{
|
|
4969
|
-
name: "
|
|
5217
|
+
name: "kyc_config",
|
|
4970
5218
|
docs: [
|
|
4971
5219
|
"Buffers for additional fields"
|
|
4972
5220
|
],
|
|
5221
|
+
type: {
|
|
5222
|
+
defined: {
|
|
5223
|
+
name: "KycConfig"
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
},
|
|
5227
|
+
{
|
|
5228
|
+
name: "buffer_1",
|
|
4973
5229
|
type: {
|
|
4974
5230
|
array: [
|
|
4975
5231
|
"u8",
|
|
@@ -4985,6 +5241,15 @@ var aligned_distributor_default = {
|
|
|
4985
5241
|
32
|
|
4986
5242
|
]
|
|
4987
5243
|
}
|
|
5244
|
+
},
|
|
5245
|
+
{
|
|
5246
|
+
name: "buffer_3",
|
|
5247
|
+
type: {
|
|
5248
|
+
array: [
|
|
5249
|
+
"u8",
|
|
5250
|
+
32
|
|
5251
|
+
]
|
|
5252
|
+
}
|
|
4988
5253
|
}
|
|
4989
5254
|
]
|
|
4990
5255
|
}
|
|
@@ -5175,9 +5440,11 @@ var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
|
5175
5440
|
var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
5176
5441
|
var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
5177
5442
|
var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
5443
|
+
var ATTESTATION_PREFIX = Buffer.from("attestation", "utf-8");
|
|
5178
5444
|
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
5179
5445
|
var AIRDROP_CLAIM_FEE = BigInt(1e7);
|
|
5180
5446
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
5447
|
+
var SOLANA_ATTESTATION_SERVICE_PROGRAM_ID = new PublicKey("22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG");
|
|
5181
5448
|
var ONE_IN_BASIS_POINTS = BigInt(1e4);
|
|
5182
5449
|
var SOL_FEE_PROGRAM_VERSION = 1;
|
|
5183
5450
|
var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
@@ -5376,6 +5643,46 @@ function getClaimantStatusPda(programId, distributor, claimant) {
|
|
|
5376
5643
|
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
5377
5644
|
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
5378
5645
|
}
|
|
5646
|
+
function getKycNonceBytes(nonce) {
|
|
5647
|
+
if (nonce == null) {
|
|
5648
|
+
return null;
|
|
5649
|
+
}
|
|
5650
|
+
if (typeof nonce === "string") {
|
|
5651
|
+
return Buffer$1.from(nonce);
|
|
5652
|
+
}
|
|
5653
|
+
const nonceBytes = Array.from(nonce);
|
|
5654
|
+
for (const byte of nonceBytes) {
|
|
5655
|
+
if (!Number.isInteger(byte) || byte < 0 || byte > 255) {
|
|
5656
|
+
throw new Error("KYC nonce must contain only bytes");
|
|
5657
|
+
}
|
|
5658
|
+
}
|
|
5659
|
+
return Buffer$1.from(nonceBytes);
|
|
5660
|
+
}
|
|
5661
|
+
async function getAttestationNonce({
|
|
5662
|
+
claimant,
|
|
5663
|
+
nonce
|
|
5664
|
+
}) {
|
|
5665
|
+
const nonceBytes = getKycNonceBytes(nonce);
|
|
5666
|
+
if (!nonceBytes || nonceBytes.length === 0) {
|
|
5667
|
+
return claimant;
|
|
5668
|
+
}
|
|
5669
|
+
const hash = await globalThis.crypto.subtle.digest(
|
|
5670
|
+
"SHA-256",
|
|
5671
|
+
Buffer$1.concat([Buffer$1.from(`${claimant.toString()}:`), nonceBytes])
|
|
5672
|
+
);
|
|
5673
|
+
return new PublicKey(new Uint8Array(hash));
|
|
5674
|
+
}
|
|
5675
|
+
function getAttestationPda({
|
|
5676
|
+
credential,
|
|
5677
|
+
schema,
|
|
5678
|
+
nonce,
|
|
5679
|
+
programId = SOLANA_ATTESTATION_SERVICE_PROGRAM_ID
|
|
5680
|
+
}) {
|
|
5681
|
+
return PublicKey.findProgramAddressSync(
|
|
5682
|
+
[ATTESTATION_PREFIX, credential.toBuffer(), schema.toBuffer(), nonce.toBuffer()],
|
|
5683
|
+
programId
|
|
5684
|
+
)[0];
|
|
5685
|
+
}
|
|
5379
5686
|
function getEventAuthorityPda(programId) {
|
|
5380
5687
|
const seeds = [Buffer$1.from("__event_authority")];
|
|
5381
5688
|
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
@@ -5585,29 +5892,45 @@ var BaseDistributorClient = class {
|
|
|
5585
5892
|
extParams.invoker.publicKey
|
|
5586
5893
|
);
|
|
5587
5894
|
const claimStatus = await this.getClaim(claimStatusPublicKey);
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5592
|
-
|
|
5895
|
+
let attestation = data.attestation;
|
|
5896
|
+
if (!attestation && distributor.kycConfig.isSet) {
|
|
5897
|
+
attestation = getAttestationPda({
|
|
5898
|
+
credential: distributor.kycConfig.credential,
|
|
5899
|
+
schema: distributor.kycConfig.schema,
|
|
5900
|
+
nonce: await getAttestationNonce({
|
|
5593
5901
|
claimant: extParams.invoker.publicKey,
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5597
|
-
|
|
5902
|
+
nonce: distributor.kycConfig.nonce.slice(0, distributor.kycConfig.nonceLen)
|
|
5903
|
+
})
|
|
5904
|
+
});
|
|
5905
|
+
}
|
|
5906
|
+
const remainingAccounts = this.getClaimRemainingAccounts(data, attestation);
|
|
5907
|
+
if (!claimStatus) {
|
|
5908
|
+
let newClaimMethod = this.merkleDistributorProgram.methods.newClaim(new BN(data.amountUnlocked), new BN(data.amountLocked), data.proof).accounts({
|
|
5909
|
+
distributor: distributorPublicKey,
|
|
5910
|
+
to: invokerTokens,
|
|
5911
|
+
claimant: extParams.invoker.publicKey,
|
|
5912
|
+
tokenProgram: tokenProgramId,
|
|
5913
|
+
program: this.programId
|
|
5914
|
+
});
|
|
5915
|
+
if (remainingAccounts.length > 0) {
|
|
5916
|
+
newClaimMethod = newClaimMethod.remainingAccounts(remainingAccounts);
|
|
5917
|
+
}
|
|
5918
|
+
ixs.push(await newClaimMethod.instruction());
|
|
5598
5919
|
}
|
|
5599
5920
|
const nowTs = new BN(Math.floor(Date.now() / 1e3));
|
|
5600
5921
|
if (claimStatus || new BN(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
5601
5922
|
const claimMethod = distributor.programVersion >= SOL_FEE_PROGRAM_VERSION ? this.merkleDistributorProgram.methods.claimLockedV2 : this.merkleDistributorProgram.methods.claimLocked;
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
|
-
|
|
5609
|
-
|
|
5610
|
-
|
|
5923
|
+
let claimLockedMethod = claimMethod().accounts({
|
|
5924
|
+
distributor: distributorPublicKey,
|
|
5925
|
+
to: invokerTokens,
|
|
5926
|
+
claimant: extParams.invoker.publicKey,
|
|
5927
|
+
tokenProgram: tokenProgramId,
|
|
5928
|
+
program: this.programId
|
|
5929
|
+
});
|
|
5930
|
+
if (remainingAccounts.length > 0) {
|
|
5931
|
+
claimLockedMethod = claimLockedMethod.remainingAccounts(remainingAccounts);
|
|
5932
|
+
}
|
|
5933
|
+
ixs.push(await claimLockedMethod.instruction());
|
|
5611
5934
|
}
|
|
5612
5935
|
if (distributor.programVersion >= SOL_FEE_PROGRAM_VERSION) {
|
|
5613
5936
|
return ixs;
|
|
@@ -5686,6 +6009,78 @@ var BaseDistributorClient = class {
|
|
|
5686
6009
|
);
|
|
5687
6010
|
return ixs;
|
|
5688
6011
|
}
|
|
6012
|
+
async enableKyc(data, extParams) {
|
|
6013
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
6014
|
+
const invoker = executionParams.invoker.publicKey;
|
|
6015
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6016
|
+
const ixs = await createAndEstimateTransaction(
|
|
6017
|
+
(params) => this.prepareEnableKycInstructions(data, params),
|
|
6018
|
+
executionParams
|
|
6019
|
+
);
|
|
6020
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
6021
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
6022
|
+
this.connection,
|
|
6023
|
+
executionParams.invoker,
|
|
6024
|
+
tx,
|
|
6025
|
+
{
|
|
6026
|
+
hash,
|
|
6027
|
+
context,
|
|
6028
|
+
commitment: this.getCommitment()
|
|
6029
|
+
},
|
|
6030
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
6031
|
+
);
|
|
6032
|
+
return { ixs, txId: signature };
|
|
6033
|
+
}
|
|
6034
|
+
async prepareEnableKycInstructions(data, extParams) {
|
|
6035
|
+
if (!extParams.invoker.publicKey) {
|
|
6036
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6037
|
+
}
|
|
6038
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
6039
|
+
ixs.push(
|
|
6040
|
+
await this.merkleDistributorProgram.methods.enableKyc(getKycNonceBytes(data.nonce)).accounts({
|
|
6041
|
+
distributor: pk(data.id),
|
|
6042
|
+
admin: extParams.invoker.publicKey,
|
|
6043
|
+
credential: pk(data.credential),
|
|
6044
|
+
schema: pk(data.schema)
|
|
6045
|
+
}).instruction()
|
|
6046
|
+
);
|
|
6047
|
+
return ixs;
|
|
6048
|
+
}
|
|
6049
|
+
async disableKyc(data, extParams) {
|
|
6050
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
6051
|
+
const invoker = executionParams.invoker.publicKey;
|
|
6052
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6053
|
+
const ixs = await createAndEstimateTransaction(
|
|
6054
|
+
(params) => this.prepareDisableKycInstructions(data, params),
|
|
6055
|
+
executionParams
|
|
6056
|
+
);
|
|
6057
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
6058
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
6059
|
+
this.connection,
|
|
6060
|
+
executionParams.invoker,
|
|
6061
|
+
tx,
|
|
6062
|
+
{
|
|
6063
|
+
hash,
|
|
6064
|
+
context,
|
|
6065
|
+
commitment: this.getCommitment()
|
|
6066
|
+
},
|
|
6067
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
6068
|
+
);
|
|
6069
|
+
return { ixs, txId: signature };
|
|
6070
|
+
}
|
|
6071
|
+
async prepareDisableKycInstructions(data, extParams) {
|
|
6072
|
+
if (!extParams.invoker.publicKey) {
|
|
6073
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6074
|
+
}
|
|
6075
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
6076
|
+
ixs.push(
|
|
6077
|
+
await this.merkleDistributorProgram.methods.disableKyc().accounts({
|
|
6078
|
+
distributor: pk(data.id),
|
|
6079
|
+
admin: extParams.invoker.publicKey
|
|
6080
|
+
}).instruction()
|
|
6081
|
+
);
|
|
6082
|
+
return ixs;
|
|
6083
|
+
}
|
|
5689
6084
|
async prepareClawbackInstructions(data, extParams) {
|
|
5690
6085
|
if (!extParams.invoker.publicKey) {
|
|
5691
6086
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5822,6 +6217,11 @@ var BaseDistributorClient = class {
|
|
|
5822
6217
|
async getClaim(claimStatus) {
|
|
5823
6218
|
return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
5824
6219
|
}
|
|
6220
|
+
async getKycConfig(distributor) {
|
|
6221
|
+
const distributorAccount = await this.merkleDistributorProgram.account.merkleDistributor.fetch(pk(distributor));
|
|
6222
|
+
invariant(distributorAccount, "Distributor account not found");
|
|
6223
|
+
return distributorAccount.kycConfig;
|
|
6224
|
+
}
|
|
5825
6225
|
async getClaims(data) {
|
|
5826
6226
|
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
5827
6227
|
return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
|
|
@@ -5913,6 +6313,25 @@ var BaseDistributorClient = class {
|
|
|
5913
6313
|
unwrapExecutionParams(extParams) {
|
|
5914
6314
|
return unwrapExecutionParams(extParams, this.connection);
|
|
5915
6315
|
}
|
|
6316
|
+
/**
|
|
6317
|
+
* Claim support multiple remaining accounts:
|
|
6318
|
+
* - attestation when an Airdrop requires a KYC;
|
|
6319
|
+
* - partner link accounts for custom fee derivation;
|
|
6320
|
+
*/
|
|
6321
|
+
getClaimRemainingAccounts(data, attestation) {
|
|
6322
|
+
const remainingAccounts = [];
|
|
6323
|
+
if (attestation) {
|
|
6324
|
+
remainingAccounts.push({ pubkey: pk(attestation), isSigner: false, isWritable: false });
|
|
6325
|
+
}
|
|
6326
|
+
if (data.partnerLink) {
|
|
6327
|
+
remainingAccounts.push({
|
|
6328
|
+
pubkey: pk(data.partnerLink.address),
|
|
6329
|
+
isSigner: data.partnerLink.isSigner,
|
|
6330
|
+
isWritable: false
|
|
6331
|
+
});
|
|
6332
|
+
}
|
|
6333
|
+
return remainingAccounts;
|
|
6334
|
+
}
|
|
5916
6335
|
decodeClaimStatus(account) {
|
|
5917
6336
|
if (!account) {
|
|
5918
6337
|
return null;
|