@streamflow/distributor 12.4.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
package/dist/esm/solana/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) => {
|
|
@@ -102,6 +102,7 @@ __export(constants_exports, {
|
|
|
102
102
|
ALIGNED_DISTRIBUTOR_PROGRAM_ID: () => ALIGNED_DISTRIBUTOR_PROGRAM_ID,
|
|
103
103
|
ALIGNED_PRECISION_FACTOR_POW: () => ALIGNED_PRECISION_FACTOR_POW,
|
|
104
104
|
ANCHOR_DISCRIMINATOR_OFFSET: () => ANCHOR_DISCRIMINATOR_OFFSET,
|
|
105
|
+
ATTESTATION_PREFIX: () => ATTESTATION_PREFIX,
|
|
105
106
|
CLAIM_STATUS_PREFIX: () => CLAIM_STATUS_PREFIX,
|
|
106
107
|
DISTRIBUTOR_ADMIN_OFFSET: () => DISTRIBUTOR_ADMIN_OFFSET,
|
|
107
108
|
DISTRIBUTOR_MINT_OFFSET: () => DISTRIBUTOR_MINT_OFFSET,
|
|
@@ -111,6 +112,7 @@ __export(constants_exports, {
|
|
|
111
112
|
MERKLE_DISTRIBUTOR_ERRORS: () => MERKLE_DISTRIBUTOR_ERRORS,
|
|
112
113
|
ONE_IN_BASIS_POINTS: () => ONE_IN_BASIS_POINTS,
|
|
113
114
|
PARTNER_ORACLE_PROGRAM_ID: () => PARTNER_ORACLE_PROGRAM_ID,
|
|
115
|
+
SOLANA_ATTESTATION_SERVICE_PROGRAM_ID: () => SOLANA_ATTESTATION_SERVICE_PROGRAM_ID,
|
|
114
116
|
SOL_FEE_PROGRAM_VERSION: () => SOL_FEE_PROGRAM_VERSION,
|
|
115
117
|
STREAMFLOW_TREASURY_PUBLIC_KEY: () => STREAMFLOW_TREASURY_PUBLIC_KEY,
|
|
116
118
|
TEST_ORACLE_PREFIX: () => TEST_ORACLE_PREFIX
|
|
@@ -121,7 +123,7 @@ var merkle_distributor_default = {
|
|
|
121
123
|
address: "MErKy6nZVoVAkryxAejJz2juifQ4ArgLgHmaJCQkU7N",
|
|
122
124
|
metadata: {
|
|
123
125
|
name: "merkle_distributor",
|
|
124
|
-
version: "1.
|
|
126
|
+
version: "1.10.0",
|
|
125
127
|
spec: "0.1.0",
|
|
126
128
|
description: "A Solana program for distributing tokens according to a Merkle root.",
|
|
127
129
|
repository: "https://github.com/streamflow-finance/distributor"
|
|
@@ -1047,6 +1049,81 @@ var merkle_distributor_default = {
|
|
|
1047
1049
|
],
|
|
1048
1050
|
args: []
|
|
1049
1051
|
},
|
|
1052
|
+
{
|
|
1053
|
+
name: "disable_kyc",
|
|
1054
|
+
discriminator: [
|
|
1055
|
+
204,
|
|
1056
|
+
167,
|
|
1057
|
+
59,
|
|
1058
|
+
181,
|
|
1059
|
+
11,
|
|
1060
|
+
7,
|
|
1061
|
+
254,
|
|
1062
|
+
148
|
|
1063
|
+
],
|
|
1064
|
+
accounts: [
|
|
1065
|
+
{
|
|
1066
|
+
name: "distributor",
|
|
1067
|
+
docs: [
|
|
1068
|
+
"The [MerkleDistributor]."
|
|
1069
|
+
],
|
|
1070
|
+
writable: true
|
|
1071
|
+
},
|
|
1072
|
+
{
|
|
1073
|
+
name: "admin",
|
|
1074
|
+
docs: [
|
|
1075
|
+
"Admin signer."
|
|
1076
|
+
],
|
|
1077
|
+
writable: true,
|
|
1078
|
+
signer: true
|
|
1079
|
+
}
|
|
1080
|
+
],
|
|
1081
|
+
args: []
|
|
1082
|
+
},
|
|
1083
|
+
{
|
|
1084
|
+
name: "enable_kyc",
|
|
1085
|
+
discriminator: [
|
|
1086
|
+
28,
|
|
1087
|
+
10,
|
|
1088
|
+
11,
|
|
1089
|
+
99,
|
|
1090
|
+
6,
|
|
1091
|
+
44,
|
|
1092
|
+
96,
|
|
1093
|
+
77
|
|
1094
|
+
],
|
|
1095
|
+
accounts: [
|
|
1096
|
+
{
|
|
1097
|
+
name: "distributor",
|
|
1098
|
+
docs: [
|
|
1099
|
+
"The [MerkleDistributor]."
|
|
1100
|
+
],
|
|
1101
|
+
writable: true
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
name: "admin",
|
|
1105
|
+
docs: [
|
|
1106
|
+
"Admin signer."
|
|
1107
|
+
],
|
|
1108
|
+
writable: true,
|
|
1109
|
+
signer: true
|
|
1110
|
+
},
|
|
1111
|
+
{
|
|
1112
|
+
name: "credential"
|
|
1113
|
+
},
|
|
1114
|
+
{
|
|
1115
|
+
name: "schema"
|
|
1116
|
+
}
|
|
1117
|
+
],
|
|
1118
|
+
args: [
|
|
1119
|
+
{
|
|
1120
|
+
name: "nonce",
|
|
1121
|
+
type: {
|
|
1122
|
+
option: "bytes"
|
|
1123
|
+
}
|
|
1124
|
+
}
|
|
1125
|
+
]
|
|
1126
|
+
},
|
|
1050
1127
|
{
|
|
1051
1128
|
name: "new_claim",
|
|
1052
1129
|
discriminator: [
|
|
@@ -2752,6 +2829,31 @@ var merkle_distributor_default = {
|
|
|
2752
2829
|
code: 6033,
|
|
2753
2830
|
name: "ClawbackRequestDelayPending",
|
|
2754
2831
|
msg: "Clawback request delay has not passed yet"
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
code: 6034,
|
|
2835
|
+
name: "MissingAttestation",
|
|
2836
|
+
msg: "Attestation is required for this Distributor"
|
|
2837
|
+
},
|
|
2838
|
+
{
|
|
2839
|
+
code: 6035,
|
|
2840
|
+
name: "InvalidAttestation",
|
|
2841
|
+
msg: "Invalid attestation account"
|
|
2842
|
+
},
|
|
2843
|
+
{
|
|
2844
|
+
code: 6036,
|
|
2845
|
+
name: "AttestationExpired",
|
|
2846
|
+
msg: "Attestation has expired"
|
|
2847
|
+
},
|
|
2848
|
+
{
|
|
2849
|
+
code: 6037,
|
|
2850
|
+
name: "InvalidAttestationCredentialSchema",
|
|
2851
|
+
msg: "Invalid attestation credential or schema"
|
|
2852
|
+
},
|
|
2853
|
+
{
|
|
2854
|
+
code: 6038,
|
|
2855
|
+
name: "KycNonceTooLong",
|
|
2856
|
+
msg: "KYC nonce is too long"
|
|
2755
2857
|
}
|
|
2756
2858
|
],
|
|
2757
2859
|
types: [
|
|
@@ -3015,6 +3117,69 @@ var merkle_distributor_default = {
|
|
|
3015
3117
|
]
|
|
3016
3118
|
}
|
|
3017
3119
|
},
|
|
3120
|
+
{
|
|
3121
|
+
name: "KycConfig",
|
|
3122
|
+
docs: [
|
|
3123
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
3124
|
+
],
|
|
3125
|
+
type: {
|
|
3126
|
+
kind: "struct",
|
|
3127
|
+
fields: [
|
|
3128
|
+
{
|
|
3129
|
+
name: "is_set",
|
|
3130
|
+
docs: [
|
|
3131
|
+
"Whether KYC is required to claim the Airdrop"
|
|
3132
|
+
],
|
|
3133
|
+
type: "bool"
|
|
3134
|
+
},
|
|
3135
|
+
{
|
|
3136
|
+
name: "credential",
|
|
3137
|
+
docs: [
|
|
3138
|
+
"SAS Credential account used to create attestations"
|
|
3139
|
+
],
|
|
3140
|
+
type: "pubkey"
|
|
3141
|
+
},
|
|
3142
|
+
{
|
|
3143
|
+
name: "schema",
|
|
3144
|
+
docs: [
|
|
3145
|
+
"SAS Schema account that attestation must conform to"
|
|
3146
|
+
],
|
|
3147
|
+
type: "pubkey"
|
|
3148
|
+
},
|
|
3149
|
+
{
|
|
3150
|
+
name: "nonce_len",
|
|
3151
|
+
docs: [
|
|
3152
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
3153
|
+
],
|
|
3154
|
+
type: "u8"
|
|
3155
|
+
},
|
|
3156
|
+
{
|
|
3157
|
+
name: "nonce",
|
|
3158
|
+
docs: [
|
|
3159
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
3160
|
+
],
|
|
3161
|
+
type: {
|
|
3162
|
+
array: [
|
|
3163
|
+
"u8",
|
|
3164
|
+
32
|
|
3165
|
+
]
|
|
3166
|
+
}
|
|
3167
|
+
},
|
|
3168
|
+
{
|
|
3169
|
+
name: "buffer",
|
|
3170
|
+
docs: [
|
|
3171
|
+
"Buffer for additional fields"
|
|
3172
|
+
],
|
|
3173
|
+
type: {
|
|
3174
|
+
array: [
|
|
3175
|
+
"u8",
|
|
3176
|
+
32
|
|
3177
|
+
]
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
]
|
|
3181
|
+
}
|
|
3182
|
+
},
|
|
3018
3183
|
{
|
|
3019
3184
|
name: "MerkleDistributor",
|
|
3020
3185
|
docs: [
|
|
@@ -3307,10 +3472,18 @@ var merkle_distributor_default = {
|
|
|
3307
3472
|
type: "u64"
|
|
3308
3473
|
},
|
|
3309
3474
|
{
|
|
3310
|
-
name: "
|
|
3475
|
+
name: "kyc_config",
|
|
3311
3476
|
docs: [
|
|
3312
3477
|
"Buffers for additional fields"
|
|
3313
3478
|
],
|
|
3479
|
+
type: {
|
|
3480
|
+
defined: {
|
|
3481
|
+
name: "KycConfig"
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
},
|
|
3485
|
+
{
|
|
3486
|
+
name: "buffer_1",
|
|
3314
3487
|
type: {
|
|
3315
3488
|
array: [
|
|
3316
3489
|
"u8",
|
|
@@ -3326,6 +3499,15 @@ var merkle_distributor_default = {
|
|
|
3326
3499
|
32
|
|
3327
3500
|
]
|
|
3328
3501
|
}
|
|
3502
|
+
},
|
|
3503
|
+
{
|
|
3504
|
+
name: "buffer_3",
|
|
3505
|
+
type: {
|
|
3506
|
+
array: [
|
|
3507
|
+
"u8",
|
|
3508
|
+
32
|
|
3509
|
+
]
|
|
3510
|
+
}
|
|
3329
3511
|
}
|
|
3330
3512
|
]
|
|
3331
3513
|
}
|
|
@@ -3377,7 +3559,7 @@ var aligned_distributor_default = {
|
|
|
3377
3559
|
address: "aMERKpFAWoChCi5oZwPvgsSCoGpZKBiU7fi76bdZjt2",
|
|
3378
3560
|
metadata: {
|
|
3379
3561
|
name: "aligned_distributor",
|
|
3380
|
-
version: "1.
|
|
3562
|
+
version: "1.10.0",
|
|
3381
3563
|
spec: "0.1.0",
|
|
3382
3564
|
description: "Proxy for merkle distributor that updates Vesting duration according to token market performance."
|
|
3383
3565
|
},
|
|
@@ -4645,6 +4827,69 @@ var aligned_distributor_default = {
|
|
|
4645
4827
|
]
|
|
4646
4828
|
}
|
|
4647
4829
|
},
|
|
4830
|
+
{
|
|
4831
|
+
name: "KycConfig",
|
|
4832
|
+
docs: [
|
|
4833
|
+
"Configuration for kyc-gated (claim) Airdrops."
|
|
4834
|
+
],
|
|
4835
|
+
type: {
|
|
4836
|
+
kind: "struct",
|
|
4837
|
+
fields: [
|
|
4838
|
+
{
|
|
4839
|
+
name: "is_set",
|
|
4840
|
+
docs: [
|
|
4841
|
+
"Whether KYC is required to claim the Airdrop"
|
|
4842
|
+
],
|
|
4843
|
+
type: "bool"
|
|
4844
|
+
},
|
|
4845
|
+
{
|
|
4846
|
+
name: "credential",
|
|
4847
|
+
docs: [
|
|
4848
|
+
"SAS Credential account used to create attestations"
|
|
4849
|
+
],
|
|
4850
|
+
type: "pubkey"
|
|
4851
|
+
},
|
|
4852
|
+
{
|
|
4853
|
+
name: "schema",
|
|
4854
|
+
docs: [
|
|
4855
|
+
"SAS Schema account that attestation must conform to"
|
|
4856
|
+
],
|
|
4857
|
+
type: "pubkey"
|
|
4858
|
+
},
|
|
4859
|
+
{
|
|
4860
|
+
name: "nonce_len",
|
|
4861
|
+
docs: [
|
|
4862
|
+
"Length of the custom nonce portion; zero means the claimant address is used directly."
|
|
4863
|
+
],
|
|
4864
|
+
type: "u8"
|
|
4865
|
+
},
|
|
4866
|
+
{
|
|
4867
|
+
name: "nonce",
|
|
4868
|
+
docs: [
|
|
4869
|
+
'Optional custom nonce portion used as sha256("claimant_address:nonce") for SAS attestation nonce.'
|
|
4870
|
+
],
|
|
4871
|
+
type: {
|
|
4872
|
+
array: [
|
|
4873
|
+
"u8",
|
|
4874
|
+
32
|
|
4875
|
+
]
|
|
4876
|
+
}
|
|
4877
|
+
},
|
|
4878
|
+
{
|
|
4879
|
+
name: "buffer",
|
|
4880
|
+
docs: [
|
|
4881
|
+
"Buffer for additional fields"
|
|
4882
|
+
],
|
|
4883
|
+
type: {
|
|
4884
|
+
array: [
|
|
4885
|
+
"u8",
|
|
4886
|
+
32
|
|
4887
|
+
]
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
]
|
|
4891
|
+
}
|
|
4892
|
+
},
|
|
4648
4893
|
{
|
|
4649
4894
|
name: "MerkleDistributor",
|
|
4650
4895
|
docs: [
|
|
@@ -4937,10 +5182,18 @@ var aligned_distributor_default = {
|
|
|
4937
5182
|
type: "u64"
|
|
4938
5183
|
},
|
|
4939
5184
|
{
|
|
4940
|
-
name: "
|
|
5185
|
+
name: "kyc_config",
|
|
4941
5186
|
docs: [
|
|
4942
5187
|
"Buffers for additional fields"
|
|
4943
5188
|
],
|
|
5189
|
+
type: {
|
|
5190
|
+
defined: {
|
|
5191
|
+
name: "KycConfig"
|
|
5192
|
+
}
|
|
5193
|
+
}
|
|
5194
|
+
},
|
|
5195
|
+
{
|
|
5196
|
+
name: "buffer_1",
|
|
4944
5197
|
type: {
|
|
4945
5198
|
array: [
|
|
4946
5199
|
"u8",
|
|
@@ -4956,6 +5209,15 @@ var aligned_distributor_default = {
|
|
|
4956
5209
|
32
|
|
4957
5210
|
]
|
|
4958
5211
|
}
|
|
5212
|
+
},
|
|
5213
|
+
{
|
|
5214
|
+
name: "buffer_3",
|
|
5215
|
+
type: {
|
|
5216
|
+
array: [
|
|
5217
|
+
"u8",
|
|
5218
|
+
32
|
|
5219
|
+
]
|
|
5220
|
+
}
|
|
4959
5221
|
}
|
|
4960
5222
|
]
|
|
4961
5223
|
}
|
|
@@ -5146,9 +5408,11 @@ var DISTRIBUTOR_PREFIX = Buffer.from("MerkleDistributor", "utf-8");
|
|
|
5146
5408
|
var ALIGNED_DISTRIBUTOR_PREFIX = Buffer.from("aligned-distributor", "utf-8");
|
|
5147
5409
|
var TEST_ORACLE_PREFIX = Buffer.from("test-oracle", "utf-8");
|
|
5148
5410
|
var CLAIM_STATUS_PREFIX = Buffer.from("ClaimStatus", "utf-8");
|
|
5411
|
+
var ATTESTATION_PREFIX = Buffer.from("attestation", "utf-8");
|
|
5149
5412
|
var ALIGNED_PRECISION_FACTOR_POW = 9;
|
|
5150
5413
|
var AIRDROP_CLAIM_FEE = BigInt(1e7);
|
|
5151
5414
|
var STREAMFLOW_TREASURY_PUBLIC_KEY = new PublicKey("5SEpbdjFK5FxwTvfsGMXVQTD2v4M2c5tyRTxhdsPkgDw");
|
|
5415
|
+
var SOLANA_ATTESTATION_SERVICE_PROGRAM_ID = new PublicKey("22zoJMtdu4tQc2PzL74ZUT7FrwgB1Udec8DdW4yw4BdG");
|
|
5152
5416
|
var ONE_IN_BASIS_POINTS = BigInt(1e4);
|
|
5153
5417
|
var SOL_FEE_PROGRAM_VERSION = 1;
|
|
5154
5418
|
var ALIGNED_DISTRIBUTOR_PROGRAM_ID = {
|
|
@@ -5347,6 +5611,46 @@ function getClaimantStatusPda(programId, distributor, claimant) {
|
|
|
5347
5611
|
const seeds = [CLAIM_STATUS_PREFIX, claimant.toBuffer(), distributor.toBuffer()];
|
|
5348
5612
|
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
5349
5613
|
}
|
|
5614
|
+
function getKycNonceBytes(nonce) {
|
|
5615
|
+
if (nonce == null) {
|
|
5616
|
+
return null;
|
|
5617
|
+
}
|
|
5618
|
+
if (typeof nonce === "string") {
|
|
5619
|
+
return Buffer$1.from(nonce);
|
|
5620
|
+
}
|
|
5621
|
+
const nonceBytes = Array.from(nonce);
|
|
5622
|
+
for (const byte of nonceBytes) {
|
|
5623
|
+
if (!Number.isInteger(byte) || byte < 0 || byte > 255) {
|
|
5624
|
+
throw new Error("KYC nonce must contain only bytes");
|
|
5625
|
+
}
|
|
5626
|
+
}
|
|
5627
|
+
return Buffer$1.from(nonceBytes);
|
|
5628
|
+
}
|
|
5629
|
+
async function getAttestationNonce({
|
|
5630
|
+
claimant,
|
|
5631
|
+
nonce
|
|
5632
|
+
}) {
|
|
5633
|
+
const nonceBytes = getKycNonceBytes(nonce);
|
|
5634
|
+
if (!nonceBytes || nonceBytes.length === 0) {
|
|
5635
|
+
return claimant;
|
|
5636
|
+
}
|
|
5637
|
+
const hash = await globalThis.crypto.subtle.digest(
|
|
5638
|
+
"SHA-256",
|
|
5639
|
+
Buffer$1.concat([Buffer$1.from(`${claimant.toString()}:`), nonceBytes])
|
|
5640
|
+
);
|
|
5641
|
+
return new PublicKey(new Uint8Array(hash));
|
|
5642
|
+
}
|
|
5643
|
+
function getAttestationPda({
|
|
5644
|
+
credential,
|
|
5645
|
+
schema,
|
|
5646
|
+
nonce,
|
|
5647
|
+
programId = SOLANA_ATTESTATION_SERVICE_PROGRAM_ID
|
|
5648
|
+
}) {
|
|
5649
|
+
return PublicKey.findProgramAddressSync(
|
|
5650
|
+
[ATTESTATION_PREFIX, credential.toBuffer(), schema.toBuffer(), nonce.toBuffer()],
|
|
5651
|
+
programId
|
|
5652
|
+
)[0];
|
|
5653
|
+
}
|
|
5350
5654
|
function getEventAuthorityPda(programId) {
|
|
5351
5655
|
const seeds = [Buffer$1.from("__event_authority")];
|
|
5352
5656
|
return PublicKey.findProgramAddressSync(seeds, programId)[0];
|
|
@@ -5556,29 +5860,45 @@ var BaseDistributorClient = class {
|
|
|
5556
5860
|
extParams.invoker.publicKey
|
|
5557
5861
|
);
|
|
5558
5862
|
const claimStatus = await this.getClaim(claimStatusPublicKey);
|
|
5559
|
-
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5563
|
-
|
|
5863
|
+
let attestation = data.attestation;
|
|
5864
|
+
if (!attestation && distributor.kycConfig.isSet) {
|
|
5865
|
+
attestation = getAttestationPda({
|
|
5866
|
+
credential: distributor.kycConfig.credential,
|
|
5867
|
+
schema: distributor.kycConfig.schema,
|
|
5868
|
+
nonce: await getAttestationNonce({
|
|
5564
5869
|
claimant: extParams.invoker.publicKey,
|
|
5565
|
-
|
|
5566
|
-
|
|
5567
|
-
|
|
5568
|
-
|
|
5870
|
+
nonce: distributor.kycConfig.nonce.slice(0, distributor.kycConfig.nonceLen)
|
|
5871
|
+
})
|
|
5872
|
+
});
|
|
5873
|
+
}
|
|
5874
|
+
const remainingAccounts = this.getClaimRemainingAccounts(data, attestation);
|
|
5875
|
+
if (!claimStatus) {
|
|
5876
|
+
let newClaimMethod = this.merkleDistributorProgram.methods.newClaim(new BN(data.amountUnlocked), new BN(data.amountLocked), data.proof).accounts({
|
|
5877
|
+
distributor: distributorPublicKey,
|
|
5878
|
+
to: invokerTokens,
|
|
5879
|
+
claimant: extParams.invoker.publicKey,
|
|
5880
|
+
tokenProgram: tokenProgramId,
|
|
5881
|
+
program: this.programId
|
|
5882
|
+
});
|
|
5883
|
+
if (remainingAccounts.length > 0) {
|
|
5884
|
+
newClaimMethod = newClaimMethod.remainingAccounts(remainingAccounts);
|
|
5885
|
+
}
|
|
5886
|
+
ixs.push(await newClaimMethod.instruction());
|
|
5569
5887
|
}
|
|
5570
5888
|
const nowTs = new BN(Math.floor(Date.now() / 1e3));
|
|
5571
5889
|
if (claimStatus || new BN(data.amountLocked).gtn(0) && nowTs.sub(distributor.startTs).gte(distributor.unlockPeriod)) {
|
|
5572
5890
|
const claimMethod = distributor.programVersion >= SOL_FEE_PROGRAM_VERSION ? this.merkleDistributorProgram.methods.claimLockedV2 : this.merkleDistributorProgram.methods.claimLocked;
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5891
|
+
let claimLockedMethod = claimMethod().accounts({
|
|
5892
|
+
distributor: distributorPublicKey,
|
|
5893
|
+
to: invokerTokens,
|
|
5894
|
+
claimant: extParams.invoker.publicKey,
|
|
5895
|
+
tokenProgram: tokenProgramId,
|
|
5896
|
+
program: this.programId
|
|
5897
|
+
});
|
|
5898
|
+
if (remainingAccounts.length > 0) {
|
|
5899
|
+
claimLockedMethod = claimLockedMethod.remainingAccounts(remainingAccounts);
|
|
5900
|
+
}
|
|
5901
|
+
ixs.push(await claimLockedMethod.instruction());
|
|
5582
5902
|
}
|
|
5583
5903
|
if (distributor.programVersion >= SOL_FEE_PROGRAM_VERSION) {
|
|
5584
5904
|
return ixs;
|
|
@@ -5657,6 +5977,78 @@ var BaseDistributorClient = class {
|
|
|
5657
5977
|
);
|
|
5658
5978
|
return ixs;
|
|
5659
5979
|
}
|
|
5980
|
+
async enableKyc(data, extParams) {
|
|
5981
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
5982
|
+
const invoker = executionParams.invoker.publicKey;
|
|
5983
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
5984
|
+
const ixs = await createAndEstimateTransaction(
|
|
5985
|
+
(params) => this.prepareEnableKycInstructions(data, params),
|
|
5986
|
+
executionParams
|
|
5987
|
+
);
|
|
5988
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
5989
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
5990
|
+
this.connection,
|
|
5991
|
+
executionParams.invoker,
|
|
5992
|
+
tx,
|
|
5993
|
+
{
|
|
5994
|
+
hash,
|
|
5995
|
+
context,
|
|
5996
|
+
commitment: this.getCommitment()
|
|
5997
|
+
},
|
|
5998
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
5999
|
+
);
|
|
6000
|
+
return { ixs, txId: signature };
|
|
6001
|
+
}
|
|
6002
|
+
async prepareEnableKycInstructions(data, extParams) {
|
|
6003
|
+
if (!extParams.invoker.publicKey) {
|
|
6004
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6005
|
+
}
|
|
6006
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
6007
|
+
ixs.push(
|
|
6008
|
+
await this.merkleDistributorProgram.methods.enableKyc(getKycNonceBytes(data.nonce)).accounts({
|
|
6009
|
+
distributor: pk(data.id),
|
|
6010
|
+
admin: extParams.invoker.publicKey,
|
|
6011
|
+
credential: pk(data.credential),
|
|
6012
|
+
schema: pk(data.schema)
|
|
6013
|
+
}).instruction()
|
|
6014
|
+
);
|
|
6015
|
+
return ixs;
|
|
6016
|
+
}
|
|
6017
|
+
async disableKyc(data, extParams) {
|
|
6018
|
+
const executionParams = this.unwrapExecutionParams(extParams);
|
|
6019
|
+
const invoker = executionParams.invoker.publicKey;
|
|
6020
|
+
invariant(invoker, "Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6021
|
+
const ixs = await createAndEstimateTransaction(
|
|
6022
|
+
(params) => this.prepareDisableKycInstructions(data, params),
|
|
6023
|
+
executionParams
|
|
6024
|
+
);
|
|
6025
|
+
const { tx, hash, context } = await prepareTransaction(this.connection, ixs, invoker);
|
|
6026
|
+
const signature = await wrappedSignAndExecuteTransaction(
|
|
6027
|
+
this.connection,
|
|
6028
|
+
executionParams.invoker,
|
|
6029
|
+
tx,
|
|
6030
|
+
{
|
|
6031
|
+
hash,
|
|
6032
|
+
context,
|
|
6033
|
+
commitment: this.getCommitment()
|
|
6034
|
+
},
|
|
6035
|
+
{ sendThrottler: this.sendThrottler, skipSimulation: executionParams.skipSimulation }
|
|
6036
|
+
);
|
|
6037
|
+
return { ixs, txId: signature };
|
|
6038
|
+
}
|
|
6039
|
+
async prepareDisableKycInstructions(data, extParams) {
|
|
6040
|
+
if (!extParams.invoker.publicKey) {
|
|
6041
|
+
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
6042
|
+
}
|
|
6043
|
+
const ixs = prepareBaseInstructions(this.connection, extParams);
|
|
6044
|
+
ixs.push(
|
|
6045
|
+
await this.merkleDistributorProgram.methods.disableKyc().accounts({
|
|
6046
|
+
distributor: pk(data.id),
|
|
6047
|
+
admin: extParams.invoker.publicKey
|
|
6048
|
+
}).instruction()
|
|
6049
|
+
);
|
|
6050
|
+
return ixs;
|
|
6051
|
+
}
|
|
5660
6052
|
async prepareClawbackInstructions(data, extParams) {
|
|
5661
6053
|
if (!extParams.invoker.publicKey) {
|
|
5662
6054
|
throw new Error("Invoker's PublicKey is not available, check passed wallet adapter!");
|
|
@@ -5793,6 +6185,11 @@ var BaseDistributorClient = class {
|
|
|
5793
6185
|
async getClaim(claimStatus) {
|
|
5794
6186
|
return this.connection.getAccountInfo(pk(claimStatus)).then((account) => this.decodeClaimStatus(account));
|
|
5795
6187
|
}
|
|
6188
|
+
async getKycConfig(distributor) {
|
|
6189
|
+
const distributorAccount = await this.merkleDistributorProgram.account.merkleDistributor.fetch(pk(distributor));
|
|
6190
|
+
invariant(distributorAccount, "Distributor account not found");
|
|
6191
|
+
return distributorAccount.kycConfig;
|
|
6192
|
+
}
|
|
5796
6193
|
async getClaims(data) {
|
|
5797
6194
|
const claimStatusPublicKeys = data.map(({ id, recipient }) => {
|
|
5798
6195
|
return getClaimantStatusPda(this.programId, new PublicKey(id), new PublicKey(recipient));
|
|
@@ -5884,6 +6281,25 @@ var BaseDistributorClient = class {
|
|
|
5884
6281
|
unwrapExecutionParams(extParams) {
|
|
5885
6282
|
return unwrapExecutionParams(extParams, this.connection);
|
|
5886
6283
|
}
|
|
6284
|
+
/**
|
|
6285
|
+
* Claim support multiple remaining accounts:
|
|
6286
|
+
* - attestation when an Airdrop requires a KYC;
|
|
6287
|
+
* - partner link accounts for custom fee derivation;
|
|
6288
|
+
*/
|
|
6289
|
+
getClaimRemainingAccounts(data, attestation) {
|
|
6290
|
+
const remainingAccounts = [];
|
|
6291
|
+
if (attestation) {
|
|
6292
|
+
remainingAccounts.push({ pubkey: pk(attestation), isSigner: false, isWritable: false });
|
|
6293
|
+
}
|
|
6294
|
+
if (data.partnerLink) {
|
|
6295
|
+
remainingAccounts.push({
|
|
6296
|
+
pubkey: pk(data.partnerLink.address),
|
|
6297
|
+
isSigner: data.partnerLink.isSigner,
|
|
6298
|
+
isWritable: false
|
|
6299
|
+
});
|
|
6300
|
+
}
|
|
6301
|
+
return remainingAccounts;
|
|
6302
|
+
}
|
|
5887
6303
|
decodeClaimStatus(account) {
|
|
5888
6304
|
if (!account) {
|
|
5889
6305
|
return null;
|
|
@@ -6068,6 +6484,6 @@ var SolanaAlignedDistributorClient = class extends BaseDistributorClient {
|
|
|
6068
6484
|
}
|
|
6069
6485
|
};
|
|
6070
6486
|
|
|
6071
|
-
export { AnchorErrorCode, ContractErrorCode, FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR, FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR, MAXIMUM_FEE_FALLBACK, MINIMUM_FEE_FALLBACK, SolanaAlignedDistributorClient, SolanaDistributorClient, applyFeeLogic, calculateAirdropFeeLamports, calculateAmountWithTransferFees, calculateClaimableLamportsFromPrices, calculateDynamicFeeFromSolParams, constants_exports as constants, fetchAirdropFee, getAlignedDistributorPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getTestOraclePda, isCompressedClaimStatus, resolveAirdropFeeLamportsUsingApi, toLamportsSOL, wrappedSignAndExecuteTransaction };
|
|
6487
|
+
export { AnchorErrorCode, ContractErrorCode, FEE_ALLOCATION_FACTOR_FALLBACK_DENOMINATOR, FEE_ALLOCATION_FACTOR_FALLBACK_NUMERATOR, MAXIMUM_FEE_FALLBACK, MINIMUM_FEE_FALLBACK, SolanaAlignedDistributorClient, SolanaDistributorClient, applyFeeLogic, calculateAirdropFeeLamports, calculateAmountWithTransferFees, calculateClaimableLamportsFromPrices, calculateDynamicFeeFromSolParams, constants_exports as constants, fetchAirdropFee, getAlignedDistributorPda, getAttestationNonce, getAttestationPda, getClaimantStatusPda, getDistributorPda, getEventAuthorityPda, getKycNonceBytes, getTestOraclePda, isCompressedClaimStatus, resolveAirdropFeeLamportsUsingApi, toLamportsSOL, wrappedSignAndExecuteTransaction };
|
|
6072
6488
|
//# sourceMappingURL=index.js.map
|
|
6073
6489
|
//# sourceMappingURL=index.js.map
|