@nexus-cross/pop 1.4.1-beta.4 → 1.4.1-beta.6
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/{SafeDropApiPort-BbAICG2k.d.ts → SafeDropApiPort-B7NfQOsb.d.ts} +12 -5
- package/dist/adapters/index.d.ts +4 -4
- package/dist/adapters/index.js +1 -1
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.js +1 -1
- package/dist/{chunk-S3SHOE45.js → chunk-ENB6CCH7.js} +1 -1
- package/dist/{createSafeDrop-Cf_8pUY1.d.ts → createSafeDrop-BGoIQ4nK.d.ts} +1 -1
- package/dist/{index-DyeewSUH.d.ts → index-DVeDD7Dp.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/react/index.d.ts +2 -2
- package/package.json +1 -1
- package/src/infrastructure/openapi.json +159 -1
|
@@ -126,6 +126,8 @@ declare class SafeDropError extends Error {
|
|
|
126
126
|
interface XConnection {
|
|
127
127
|
readonly xUserId: string;
|
|
128
128
|
readonly handle: string;
|
|
129
|
+
/** 원래 대소문자를 보존한 표시용 handle. */
|
|
130
|
+
readonly displayHandle: string;
|
|
129
131
|
readonly displayName: string;
|
|
130
132
|
readonly profileImageUrl: string;
|
|
131
133
|
/** SIWE 인증 주소. 본문으로 고를 수 없다. */
|
|
@@ -187,23 +189,24 @@ interface EnvelopeLayout {
|
|
|
187
189
|
};
|
|
188
190
|
readonly layers: readonly {
|
|
189
191
|
readonly prefix?: string;
|
|
190
|
-
readonly
|
|
192
|
+
readonly suffix?: string;
|
|
193
|
+
readonly source: 'recipientHandle' | 'sender' | 'amount' | 'serial' | 'date' | 'message';
|
|
191
194
|
readonly overflow: {
|
|
192
|
-
readonly strategy:
|
|
195
|
+
readonly strategy: 'shrink' | 'ellipsis';
|
|
193
196
|
};
|
|
194
197
|
readonly position: {
|
|
195
198
|
readonly x: number;
|
|
196
199
|
readonly y: number;
|
|
197
200
|
readonly width: number;
|
|
198
|
-
readonly height?: number;
|
|
199
201
|
};
|
|
200
202
|
readonly typography: {
|
|
201
203
|
readonly fontSize: number;
|
|
202
|
-
readonly textAlign: 'left' | 'center'
|
|
204
|
+
readonly textAlign: 'left' | 'center';
|
|
203
205
|
readonly colorToken: string;
|
|
204
|
-
readonly fontFamily:
|
|
206
|
+
readonly fontFamily: 'sora' | 'fredoka' | 'jetbrains-mono';
|
|
205
207
|
readonly fontWeight: number;
|
|
206
208
|
readonly minFontSize: number;
|
|
209
|
+
readonly lineHeight?: number;
|
|
207
210
|
};
|
|
208
211
|
}[];
|
|
209
212
|
}
|
|
@@ -219,6 +222,8 @@ interface Envelope {
|
|
|
219
222
|
/** GET /leaderboards — identifier별 pending 잔액. */
|
|
220
223
|
interface LeaderboardEntry {
|
|
221
224
|
readonly identifier: string;
|
|
225
|
+
/** 원래 대소문자를 보존한 표시용 identifier. */
|
|
226
|
+
readonly displayHandle: string;
|
|
222
227
|
/** 수령 가능(pending) 합계 (wei-scale). */
|
|
223
228
|
readonly balance: bigint;
|
|
224
229
|
/** 최근 Deposited 금액 (wei-scale). */
|
|
@@ -241,6 +246,8 @@ type HistoryStatus = 'pending' | 'claimed' | 'refunded';
|
|
|
241
246
|
interface HistoryParty {
|
|
242
247
|
readonly address: Address;
|
|
243
248
|
readonly handle: string;
|
|
249
|
+
/** 원래 대소문자를 보존한 표시용 handle. */
|
|
250
|
+
readonly displayHandle: string;
|
|
244
251
|
readonly displayName: string;
|
|
245
252
|
readonly profileImageUrl: string;
|
|
246
253
|
}
|
package/dist/adapters/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CryptoPort, b as ClaimSignerPort, a as SafeDropChainPort, O as OnePopDrop, D as DropState, S as SafeDrop } from '../createSafeDrop-
|
|
2
|
-
import { S as Secret, a as SecretHash, H as Hex, A as Address, I as Id, m as SafeDropApiPort } from '../SafeDropApiPort-
|
|
1
|
+
import { C as CryptoPort, b as ClaimSignerPort, a as SafeDropChainPort, O as OnePopDrop, D as DropState, S as SafeDrop } from '../createSafeDrop-BGoIQ4nK.js';
|
|
2
|
+
import { S as Secret, a as SecretHash, H as Hex, A as Address, I as Id, m as SafeDropApiPort } from '../SafeDropApiPort-B7NfQOsb.js';
|
|
3
3
|
import { PublicClient, WalletClient, Chain, Transport, Abi } from 'viem';
|
|
4
|
-
import { H as HttpSafeDropApiAdapterOptions } from '../index-
|
|
5
|
-
export { C as CrossAuthClient, a as CrossAuthClientOptions, D as DEFAULT_POP_API_PATHS, b as HttpSafeDropApiAdapter, c as HttpXAuthAdapter, d as HttpXAuthAdapterOptions, O as ONE_POP_BPS_DENOMINATOR, e as ONE_POP_DEPLOYMENTS, f as ONE_POP_FEE_BPS, P as Pkce, g as PopApiPaths, h as PopContracts, i as PopDeployment, j as PopEnvironment, S as SessionStore, X as XAuthClient, k as XAuthClientOptions, l as generatePkce, m as generateState, n as getCrossAuthBaseUrl, o as getOnePopApiBaseUrl, p as getOnePopContracts, q as getOnePopDeployment, r as getPopEnvironment } from '../index-
|
|
4
|
+
import { H as HttpSafeDropApiAdapterOptions } from '../index-DVeDD7Dp.js';
|
|
5
|
+
export { C as CrossAuthClient, a as CrossAuthClientOptions, D as DEFAULT_POP_API_PATHS, b as HttpSafeDropApiAdapter, c as HttpXAuthAdapter, d as HttpXAuthAdapterOptions, O as ONE_POP_BPS_DENOMINATOR, e as ONE_POP_DEPLOYMENTS, f as ONE_POP_FEE_BPS, P as Pkce, g as PopApiPaths, h as PopContracts, i as PopDeployment, j as PopEnvironment, S as SessionStore, X as XAuthClient, k as XAuthClientOptions, l as generatePkce, m as generateState, n as getCrossAuthBaseUrl, o as getOnePopApiBaseUrl, p as getOnePopContracts, q as getOnePopDeployment, r as getPopEnvironment } from '../index-DVeDD7Dp.js';
|
|
6
6
|
import '../XAuthPort-BNJePosj.js';
|
|
7
7
|
|
|
8
8
|
/**
|
package/dist/adapters/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as N}from"../chunk-M7FFQCP2.js";import{a as Z,b as q,c as $,d as X,e as j,g as Y,h as D,i as z,j as J,k as P,l as Q,m as ee,n as te,o as ne,p as ie}from"../chunk-S3SHOE45.js";import{a as d}from"../chunk-5DT3H2VX.js";import{bytesToHex as ae,keccak256 as se,recoverAddress as re,toBytes as pe}from"viem";var l=class{keccak256(e){return se(pe(e))}randomSecret(){let e=new Uint8Array(32);return de().getRandomValues(e),ae(e).slice(2)}recoverAddress(e){return re({hash:e.digest,signature:e.signature})}};function de(){let r=globalThis.crypto;if(!r||typeof r.getRandomValues!="function")throw new Error("Secure crypto RNG (globalThis.crypto.getRandomValues) is unavailable");return r}import{serializeSignature as oe,sign as ye}from"viem/accounts";var h=class{async signDigest(e){try{let t=await ye({hash:e.digest,privateKey:e.claimKey});return oe(t)}catch(t){throw new d("SIGN_FAILED","Failed to sign claim digest with temp key",{cause:t instanceof Error?t.message:String(t)})}}};import{BaseError as G,ContractFunctionRevertedError as K,createWalletClient as ce,http as me,keccak256 as I,parseEventLogs as le,parseSignature as B,toBytes as f,toHex as V}from"viem";import{privateKeyToAccount as he,serializeSignature as _,sign as F}from"viem/accounts";var E=[{name:"sponsor",type:"address"},{name:"amount",type:"uint96"},{name:"claimAddr",type:"address"},{name:"recipient",type:"address"},{name:"secretHash",type:"bytes32"},{name:"id",type:"string"}],S=[{name:"dropKeys",type:"bytes32[]"},{name:"records",type:"tuple[]",components:E}],ue=["AlreadyMapped","AmountOverflow","BelowMinDeposit","ChangeAlreadyRequested","ChangeInProgress","CountExceedsPending","DropAlreadyExists","DropNotFound","ECDSAInvalidSignature","EmptyId","IdMismatch","IdNotMapped","InvalidClaimSignature","InvalidExecutor","InvalidShortString","InvalidValidatorNonce","InvalidValidatorSignature","NoPendingChange","NotRecipient","NotSponsor","PendingLimitExceeded","RecipientNotEmpty","ReentrancyGuardReentrantCall","SameRecipient","SecretMismatch","TokenNotEighteenDecimals","ValidatorSigExpired","ZeroAmount","ZeroClaimAddress","ZeroCount","ZeroFeeRecipient","ZeroRecipient","ZeroSbt","ZeroSecretHash","ZeroToken","ZeroValidator"],R=[...ue.map(r=>({type:"error",name:r,inputs:[]})),{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address"}]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string"}]}],s=[{type:"event",name:"Deposited",inputs:[{name:"addr",type:"address",indexed:!0},{name:"sponsor",type:"address",indexed:!0},{name:"dropKey",type:"bytes32",indexed:!0},{name:"amount",type:"uint256",indexed:!1},{name:"id",type:"string",indexed:!1},{name:"secretHash",type:"bytes32",indexed:!1},{name:"token",type:"address",indexed:!1}],anonymous:!1},{type:"function",name:"activeDropOf",stateMutability:"view",inputs:[{name:"sponsor",type:"address"},{name:"claimAddr",type:"address"}],outputs:[{type:"bytes32"}]},{type:"function",name:"drops",stateMutability:"view",inputs:[{name:"dropKey",type:"bytes32"}],outputs:E},{type:"function",name:"token",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{type:"function",name:"claimDigest",stateMutability:"view",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"}],outputs:[{type:"bytes32"}]},{type:"function",name:"anchorClaimDigest",stateMutability:"view",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"}],outputs:[{type:"bytes32"}]},{type:"function",name:"claimedRecipientOf",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:[{type:"address"}]},{type:"function",name:"pendingDropsByXid",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:S},{type:"function",name:"pendingDropsByRecipient",stateMutability:"view",inputs:[{name:"recipient",type:"address"}],outputs:S},{type:"function",name:"pendingDropsOf",stateMutability:"view",inputs:[{name:"sponsor",type:"address"}],outputs:S},{type:"function",name:"depositMapped",stateMutability:"nonpayable",inputs:[{name:"amount",type:"uint256"},{name:"id",type:"string"},{name:"permitDeadline",type:"uint256"},{name:"v",type:"uint8"},{name:"r",type:"bytes32"},{name:"s",type:"bytes32"}],outputs:[]},{type:"function",name:"withdrawUnmapped",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"},{name:"signature",type:"bytes"},{name:"secret",type:"bytes"}],outputs:[]},{type:"function",name:"withdrawUnmappedBatchByKeys",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"anchorDropKey",type:"bytes32"},{name:"signature",type:"bytes"},{name:"secret",type:"bytes"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"executor",type:"address"},{name:"dropKeys",type:"bytes32[]"},{name:"validatorSignature",type:"bytes"}],outputs:[]},{type:"function",name:"withdrawMapped",stateMutability:"nonpayable",inputs:[{name:"dropKey",type:"bytes32"}],outputs:[]},{type:"function",name:"batchWithdrawMapped",stateMutability:"nonpayable",inputs:[{name:"count",type:"uint256"}],outputs:[]},{type:"function",name:"batchWithdrawMapped",stateMutability:"nonpayable",inputs:[{name:"dropKeys",type:"bytes32[]"}],outputs:[]},{type:"function",name:"refund",stateMutability:"nonpayable",inputs:[{name:"dropKey",type:"bytes32"}],outputs:[]},{type:"function",name:"changeNonceById",stateMutability:"view",inputs:[{name:"idKey",type:"bytes32"}],outputs:[{type:"uint256"}]},{type:"function",name:"pendingRecipientChange",stateMutability:"view",inputs:[{name:"idKey",type:"bytes32"}],outputs:[{name:"newRecipient",type:"address"}]},{type:"function",name:"requestRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"newRecipient",type:"address"}],outputs:[]},{type:"function",name:"completeRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"validatorSignature",type:"bytes"}],outputs:[]},{type:"function",name:"cancelRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"}],outputs:[]},{type:"function",name:"resetRecipient",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"validatorSignature",type:"bytes"}],outputs:[]},...R];var T=[{type:"function",name:"deposit",stateMutability:"nonpayable",inputs:[{name:"claimAddr",type:"address"},{name:"amount",type:"uint256"},{name:"id",type:"string"},{name:"secretHash",type:"bytes32"},{name:"deadline",type:"uint256"},{name:"v",type:"uint8"},{name:"r",type:"bytes32"},{name:"s",type:"bytes32"}],outputs:[]},{type:"function",name:"token",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},...R],b=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"eip712Domain",stateMutability:"view",inputs:[],outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}]}],H={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};var g=[{type:"function",name:"validator",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{type:"function",name:"validatorClaimDigest",stateMutability:"view",inputs:[{name:"executor",type:"address"},{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],outputs:[{type:"bytes32"}]},{type:"function",name:"validatorNonceById",stateMutability:"view",inputs:[{name:"idHash",type:"bytes32"}],outputs:[{type:"uint256"}]},{type:"function",name:"claimedRecipientOf",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:[{type:"address"}]},{type:"error",name:"ValidatorSigExpired",inputs:[]},{type:"error",name:"InvalidValidatorNonce",inputs:[]}];var be="0x0000000000000000000000000000000000000000",ge=`0x${"00".repeat(32)}`,fe={gas:BigInt(1e6),batchBaseGas:BigInt(1e6),batchGasPerDrop:BigInt(75e4),maxBatchGas:BigInt(3e7),maxFeePerGas:BigInt(4e9),maxPriorityFeePerGas:BigInt(1e9)},k=BigInt(1800),w=class{constructor(e){if(this.address=e.address,this.publicClient=e.publicClient,this.walletClient=e.walletClient,this.chain=e.chain,this.transport=e.transport??me(),this.transactionFees={...fe,...e.withdrawFees,...e.transactionFees},this.transactionFees.gas<=BigInt(0)||this.transactionFees.batchBaseGas<=BigInt(0)||this.transactionFees.batchGasPerDrop<=BigInt(0)||this.transactionFees.maxBatchGas<=BigInt(0)||this.transactionFees.maxFeePerGas<=BigInt(0)||this.transactionFees.maxPriorityFeePerGas<=BigInt(0)||this.transactionFees.maxPriorityFeePerGas>this.transactionFees.maxFeePerGas)throw new d("INVALID_PARAM","invalid EIP-1559 gas configuration");this.depositWithPermit=t=>this.permitDeposit(t)}async getDropByKey(e){try{let[t,n,i,a,o,y]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"drops",args:[e]});return t.toLowerCase()===be?null:{dropKey:e,sponsor:t,amount:n,claimAddress:i,recipient:a,secretHash:o,id:y}}catch(t){throw p("drops",t)}}async getDropKeyByClaimAddress(e,t){try{let n=await this.publicClient.readContract({address:this.address,abi:s,functionName:"activeDropOf",args:[t,e]});return n===ge?null:n}catch(n){throw p("activeDropOf",n)}}async getPendingDropsById(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsByXid",args:[e.id]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsByXid",t)}}async getPendingDropsByRecipient(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsByRecipient",args:[e.recipient]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsByRecipient",t)}}async getPendingDropsBySponsor(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsOf",args:[e.sponsor]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsOf",t)}}async getDrop(e,t){let n=await this.getDropKeyByClaimAddress(e,t);if(!n)return null;let[i,a]=await Promise.all([this.getDropByKey(n),this.escrowToken()]);return i&&a?{...i,token:a}:null}async escrowToken(){try{return await this.publicClient.readContract({address:this.address,abi:T,functionName:"token"})}catch{throw new d("CHAIN_ERROR","token() failed")}}async getClaimDigest(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimDigest",args:[e.recipient,e.id,e.dropKey]})}catch(t){throw p("claimDigest",t)}}async permitDeposit(e){try{let t=this.requireAccount(),n=e.token,[i,a,o]=await Promise.all([this.publicClient.readContract({address:this.address,abi:T,functionName:"token"}),this.publicClient.readContract({address:n,abi:b,functionName:"nonces",args:[t.address]}),this.permitDomain(n)]);if(i.toLowerCase()!==n.toLowerCase())throw new d("INVALID_TOKEN","token does not match the escrow token",{expected:i,received:e.token});let y=BigInt(Math.floor(Date.now()/1e3))+k,u=await this.walletClient.signTypedData({account:t,domain:{...o,chainId:this.chain.id,verifyingContract:n},types:H,primaryType:"Permit",message:{owner:t.address,spender:this.address,value:e.amount,nonce:a,deadline:y}}),{r:C,s:x,v:A,yParity:v}=B(u),c=await this.walletClient.writeContract({address:this.address,abi:T,functionName:"deposit",args:[e.claimAddress,e.amount,e.id,e.secretHash,y,Number(A??BigInt(v+27)),C,x],account:t,chain:this.chain,...this.transactionOverrides()});await e.onSubmitted?.(c);let m=await this.confirm("depositWithPermit",c);return{txHash:c,dropKey:this.depositedDropKey(m.logs,t.address,e.amount,e.id,c)}}catch(t){throw p("depositWithPermit",t)}}async depositMapped(e){try{let t=this.requireAccount(),n=e.token,[i,a,o]=await Promise.all([this.publicClient.readContract({address:this.address,abi:s,functionName:"token"}),this.publicClient.readContract({address:n,abi:b,functionName:"nonces",args:[t.address]}),this.permitDomain(n)]);if(i.toLowerCase()!==n.toLowerCase())throw new d("INVALID_TOKEN","token does not match the escrow token",{expected:i,received:e.token});let y=BigInt(Math.floor(Date.now()/1e3))+k,u=await this.walletClient.signTypedData({account:t,domain:{...o,chainId:this.chain.id,verifyingContract:n},types:H,primaryType:"Permit",message:{owner:t.address,spender:this.address,value:e.amount,nonce:a,deadline:y}}),{r:C,s:x,v:A,yParity:v}=B(u),c=[e.amount,e.id,y,Number(A??BigInt(v+27)),C,x];await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"depositMapped",args:c,account:t});let m=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"depositMapped",args:c,account:t,chain:this.chain,...this.transactionOverrides()});await e.onSubmitted?.(m);let U=await this.confirm("depositMapped",m);return{txHash:m,dropKey:this.depositedDropKey(U.logs,t.address,e.amount,e.id,m)}}catch(t){throw p("depositMapped",t)}}async permitDomain(e){try{let t=await this.publicClient.readContract({address:e,abi:b,functionName:"eip712Domain"});return{name:t[1],version:t[2]}}catch{return{name:await this.publicClient.readContract({address:e,abi:b,functionName:"name"}),version:"1"}}}async withdrawUnmapped(e){try{let t=he(e.claimKey),n=await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimDigest",args:[e.recipient,e.id,e.dropKey]}),i=e.signature??_(await F({hash:n,privateKey:e.claimKey})),o=await ce({account:t,chain:this.chain,transport:this.transport}).writeContract({address:this.address,abi:s,functionName:"withdrawUnmapped",args:[e.recipient,e.id,e.dropKey,i,V(f(e.secret))],...this.transactionOverrides()});return await e.onSubmitted?.(o),await this.confirm("withdrawUnmapped",o),o}catch(t){throw L("withdrawUnmapped",t)}}async withdrawMapped(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"withdrawMapped",args:[e.dropKey],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"withdrawMapped",args:[e.dropKey],account:t,chain:this.chain,...this.transactionOverrides()});return await e.onSubmitted?.(n),await this.confirm("withdrawMapped",n),n}catch(n){throw p("withdrawMapped",n)}}async batchWithdrawMapped(e){if(!Number.isSafeInteger(e.count)||e.count<=0)throw new d("INVALID_PARAM","count must be a positive safe integer");let t=this.batchTransactionOverrides(e.count),n=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:[BigInt(e.count)],account:n});let i=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:[BigInt(e.count)],account:n,chain:this.chain,...t});return await this.confirm("batchWithdrawMapped",i),i}catch(i){throw p("batchWithdrawMapped",i)}}async batchWithdrawMappedByKeys(e){if(!e.dropKeys.length)throw new d("INVALID_PARAM","dropKeys must not be empty");let t=this.batchTransactionOverrides(e.dropKeys.length),n=this.requireAccount(),i=[e.dropKeys];try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:i,account:n});let a=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:i,account:n,chain:this.chain,...t});return await this.confirm("batchWithdrawMapped",a),a}catch(a){throw p("batchWithdrawMapped",a)}}async withdrawUnmappedBatchByKeys(e){let t=e.dropKeys.filter(a=>a.toLowerCase()!==e.anchorDropKey.toLowerCase()),n=this.batchTransactionOverrides(t.length+1),i=this.requireAccount();try{let a=await this.publicClient.readContract({address:this.address,abi:s,functionName:"anchorClaimDigest",args:[e.recipient,e.id,e.anchorDropKey]}),o=_(await F({hash:a,privateKey:e.claimKey})),y=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"withdrawUnmappedBatchByKeys",args:[e.recipient,e.id,e.anchorDropKey,o,V(f(e.secret)),e.nonce,e.deadline,e.executor,t,e.validatorSignature],account:i,chain:this.chain,...n});return await this.confirm("withdrawUnmappedBatchByKeys",y),y}catch(a){throw L("withdrawUnmappedBatchByKeys",a)}}async getValidatorNonce(e){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validatorNonceById",args:[I(f(e.id))]})}catch(t){throw p("validatorNonceById",t)}}async getValidatorClaimDigest(e){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validatorClaimDigest",args:[e.executor,e.recipient,e.id,e.nonce,e.deadline]})}catch(t){throw p("validatorClaimDigest",t)}}async getValidator(){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validator"})}catch(e){throw p("validator",e)}}async getClaimedRecipient(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimedRecipientOf",args:[e.id]})}catch(t){throw p("claimedRecipientOf",t)}}async refundByKey(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"refund",args:[e.dropKey],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"refund",args:[e.dropKey],account:t,chain:this.chain,...this.transactionOverrides()});return await this.confirm("refund",n),n}catch(n){throw p("refund",n)}}async getChangeNonce(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"changeNonceById",args:[I(f(e.id))]})}catch(t){throw p("changeNonceById",t)}}async getPendingRecipientChange(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingRecipientChange",args:[I(f(e.id))]})}catch(t){throw p("pendingRecipientChange",t)}}async requestRecipientChange(e){return this.currentContractWrite("requestRecipientChange",[e.id,e.newRecipient])}async completeRecipientChange(e){return this.currentContractWrite("completeRecipientChange",[e.id,e.nonce,e.deadline,e.signature])}async cancelRecipientChange(e){return this.currentContractWrite("cancelRecipientChange",[e.id])}async resetRecipient(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"resetRecipient",args:[e.id,e.nonce,e.deadline,e.signature],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"resetRecipient",args:[e.id,e.nonce,e.deadline,e.signature],account:t,chain:this.chain,...this.transactionOverrides()});return await this.confirm("resetRecipient",n),n}catch(n){throw p("resetRecipient",n)}}async currentContractWrite(e,t){let n=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:e,args:t,account:n});let i=await this.walletClient.writeContract({address:this.address,abi:s,functionName:e,args:t,account:n,chain:this.chain,...this.transactionOverrides()});return await this.confirm(e,i),i}catch(i){throw p(e,i)}}transactionOverrides(e=this.transactionFees.gas){return{type:"eip1559",gas:e,maxFeePerGas:this.transactionFees.maxFeePerGas,maxPriorityFeePerGas:this.transactionFees.maxPriorityFeePerGas}}batchTransactionOverrides(e){if(!Number.isSafeInteger(e)||e<=0)throw new d("INVALID_PARAM","batch count must be a positive safe integer");let t=this.transactionFees.batchBaseGas+this.transactionFees.batchGasPerDrop*BigInt(e);if(t>this.transactionFees.maxBatchGas)throw new d("INVALID_PARAM","batch gas exceeds maxBatchGas",{count:e,gas:t.toString(),maxBatchGas:this.transactionFees.maxBatchGas.toString()});return this.transactionOverrides(t)}async sponsorWrite(e,t){try{let n=await t();return await this.confirm(e,n),n}catch(n){throw p(e,n)}}depositedDropKey(e,t,n,i,a){let o=le({abi:s,eventName:"Deposited",logs:[...e]}).find(({address:y,args:u})=>y.toLowerCase()===this.address.toLowerCase()&&u.sponsor.toLowerCase()===t.toLowerCase()&&u.amount===n&&u.id===i);if(!o)throw new d("CHAIN_ERROR","deposit receipt omitted the Deposited event",{txHash:a});return o.args.dropKey}async confirm(e,t){let n=await this.publicClient.waitForTransactionReceipt({hash:t});if(n.status!=="success"){let i=await this.recoverRevertName(t,n.blockNumber),a=i?`SafeDrop.${e} reverted: ${i}`:`transaction reverted: ${t}`;throw new d("CHAIN_ERROR",a,{revertName:i,txHash:t})}return n}async recoverRevertName(e,t){try{let n=await this.publicClient.getTransaction({hash:e});await this.publicClient.call({account:n.from,to:n.to??void 0,data:n.input,value:n.value,blockNumber:t});return}catch(n){return O(n)}}requireAccount(){let e=this.walletClient.account;if(!e)throw new d("CHAIN_ERROR","walletClient has no account (connect a wallet first)");return e}};function M(r,e){return{dropKey:r,sponsor:e.sponsor,amount:e.amount,claimAddress:e.claimAddr,recipient:e.recipient,secretHash:e.secretHash,id:e.id}}function p(r,e){if(e instanceof d)return e;let t=O(e),n=e instanceof Error?e.message:String(e),i=t?`SafeDrop.${r} reverted: ${t}`:`SafeDrop.${r} failed`;return new d("CHAIN_ERROR",i,{cause:n,revertName:t})}function L(r,e){if(e instanceof d)return e;let t=O(e),n=e instanceof G?e.walk(o=>{let y=o;return typeof y.code=="number"||y.data!==void 0}):void 0,i={revertName:t};typeof n?.code=="number"&&(i.rpcCode=n.code),typeof n?.details=="string"&&(i.rpcMessage=n.details),typeof n?.data=="string"&&(i.rpcData=n.data);let a=t?`SafeDrop.${r} reverted: ${t}`:`SafeDrop.${r} failed`;return new d("CHAIN_ERROR",a,i)}function O(r){if(!(r instanceof G))return;let e=r.walk(t=>t instanceof K);if(e instanceof K)return e.data?.errorName??e.reason??void 0}var W=[{type:"constructor",inputs:[{name:"token_",type:"address",internalType:"contract IERC20"},{name:"validator_",type:"address",internalType:"address"},{name:"sbt_",type:"address",internalType:"contract ISoulboundToken"},{name:"feeRecipient_",type:"address",internalType:"address"},{name:"minDeposit_",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"FEE_BPS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"MAX_PENDING_PER_SPONSOR_ID",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"activeDropOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"claimAddr",type:"address",internalType:"address"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"anchorClaimDigest",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"batchWithdrawMapped",inputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"batchWithdrawMapped",inputs:[{name:"count",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"cancelRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"changeNonceById",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"changeRecipientDigest",inputs:[{name:"id",type:"string",internalType:"string"},{name:"newRecipient",type:"address",internalType:"address"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"claimDigest",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"claimedRecipientOf",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"completeRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"deposit",inputs:[{name:"claimAddr",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"id",type:"string",internalType:"string"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"permitDeadline",type:"uint256",internalType:"uint256"},{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"depositMapped",inputs:[{name:"amount",type:"uint256",internalType:"uint256"},{name:"id",type:"string",internalType:"string"},{name:"permitDeadline",type:"uint256",internalType:"uint256"},{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"drops",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"feeRecipient",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"minDeposit",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingCountOf",inputs:[{name:"sponsor",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingCountOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsByRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsByRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsByXid",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsByXid",inputs:[{name:"id",type:"string",internalType:"string"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsOf",inputs:[{name:"sponsor",type:"address",internalType:"address"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingRecipientChange",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"newRecipient",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"refund",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"requestRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"},{name:"newRecipient",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"resetRecipient",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"resetRecipientDigest",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"sbt",inputs:[],outputs:[{name:"",type:"address",internalType:"contract ISoulboundToken"}],stateMutability:"view"},{type:"function",name:"settledCountOf",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"token",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC20"}],stateMutability:"view"},{type:"function",name:"validator",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"validatorClaimDigest",inputs:[{name:"executor",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"validatorNonceById",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"withdrawMapped",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmapped",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmappedBatch",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"anchorDropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"executor",type:"address",internalType:"address"},{name:"payCount",type:"uint256",internalType:"uint256"},{name:"moveCount",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmappedBatchByKeys",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"anchorDropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"executor",type:"address",internalType:"address"},{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"Deposited",inputs:[{name:"addr",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"secretHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"FeeCharged",inputs:[{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"gross",type:"uint256",indexed:!1,internalType:"uint256"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Moved",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"sponsor",type:"address",indexed:!1,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"RecipientChangeCancelled",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientChangeRequested",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientChanged",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientMapped",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientReset",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"Refunded",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Withdrawn",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"sbtTokenId",type:"uint256",indexed:!1,internalType:"uint256"},{name:"dropKey",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"error",name:"AlreadyMapped",inputs:[]},{type:"error",name:"AmountOverflow",inputs:[]},{type:"error",name:"BelowMinDeposit",inputs:[]},{type:"error",name:"ChangeAlreadyRequested",inputs:[]},{type:"error",name:"ChangeInProgress",inputs:[]},{type:"error",name:"CountExceedsPending",inputs:[]},{type:"error",name:"DropAlreadyExists",inputs:[]},{type:"error",name:"DropNotFound",inputs:[]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"EmptyId",inputs:[]},{type:"error",name:"IdMismatch",inputs:[]},{type:"error",name:"IdNotMapped",inputs:[]},{type:"error",name:"InvalidClaimSignature",inputs:[]},{type:"error",name:"InvalidExecutor",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidValidatorNonce",inputs:[]},{type:"error",name:"InvalidValidatorSignature",inputs:[]},{type:"error",name:"NoPendingChange",inputs:[]},{type:"error",name:"NotRecipient",inputs:[]},{type:"error",name:"NotSponsor",inputs:[]},{type:"error",name:"PendingLimitExceeded",inputs:[]},{type:"error",name:"RecipientNotEmpty",inputs:[]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address",internalType:"address"}]},{type:"error",name:"SameRecipient",inputs:[]},{type:"error",name:"SecretMismatch",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]},{type:"error",name:"TokenNotEighteenDecimals",inputs:[]},{type:"error",name:"ValidatorSigExpired",inputs:[]},{type:"error",name:"ZeroAmount",inputs:[]},{type:"error",name:"ZeroClaimAddress",inputs:[]},{type:"error",name:"ZeroCount",inputs:[]},{type:"error",name:"ZeroFeeRecipient",inputs:[]},{type:"error",name:"ZeroRecipient",inputs:[]},{type:"error",name:"ZeroSbt",inputs:[]},{type:"error",name:"ZeroSecretHash",inputs:[]},{type:"error",name:"ZeroToken",inputs:[]},{type:"error",name:"ZeroValidator",inputs:[]}];var Te=W;function Ce(r){let e=r.apiPort??new P(r.api),t=new w({address:r.contractAddress??D().onePop,publicClient:r.publicClient,walletClient:r.walletClient,chain:r.chain,transport:r.transport,withdrawFees:r.withdrawFees,transactionFees:r.transactionFees});return N({claimBaseUrl:r.claimBaseUrl},{api:e,chain:t,signer:new h,crypto:new l})}export{Q as CrossAuthClient,X as DEFAULT_POP_API_PATHS,P as HttpSafeDropApiAdapter,ne as HttpXAuthAdapter,s as ONEPOP_ABI,q as ONE_POP_BPS_DENOMINATOR,$ as ONE_POP_DEPLOYMENTS,Z as ONE_POP_FEE_BPS,Te as SAFEDROP_ABI,g as SAFEDROP_VALIDATOR_ABI,h as ViemClaimSignerAdapter,l as ViemCryptoAdapter,w as ViemSafeDropChainAdapter,ie as XAuthClient,Ce as createSafeDropClient,ee as generatePkce,te as generateState,J as getCrossAuthBaseUrl,z as getOnePopApiBaseUrl,D as getOnePopContracts,Y as getOnePopDeployment,j as getPopEnvironment};
|
|
1
|
+
import{j as N}from"../chunk-M7FFQCP2.js";import{a as Z,b as q,c as $,d as X,e as j,g as Y,h as D,i as z,j as J,k as P,l as Q,m as ee,n as te,o as ne,p as ie}from"../chunk-ENB6CCH7.js";import{a as d}from"../chunk-5DT3H2VX.js";import{bytesToHex as ae,keccak256 as se,recoverAddress as re,toBytes as pe}from"viem";var l=class{keccak256(e){return se(pe(e))}randomSecret(){let e=new Uint8Array(32);return de().getRandomValues(e),ae(e).slice(2)}recoverAddress(e){return re({hash:e.digest,signature:e.signature})}};function de(){let r=globalThis.crypto;if(!r||typeof r.getRandomValues!="function")throw new Error("Secure crypto RNG (globalThis.crypto.getRandomValues) is unavailable");return r}import{serializeSignature as oe,sign as ye}from"viem/accounts";var h=class{async signDigest(e){try{let t=await ye({hash:e.digest,privateKey:e.claimKey});return oe(t)}catch(t){throw new d("SIGN_FAILED","Failed to sign claim digest with temp key",{cause:t instanceof Error?t.message:String(t)})}}};import{BaseError as G,ContractFunctionRevertedError as K,createWalletClient as ce,http as me,keccak256 as I,parseEventLogs as le,parseSignature as B,toBytes as f,toHex as V}from"viem";import{privateKeyToAccount as he,serializeSignature as _,sign as F}from"viem/accounts";var E=[{name:"sponsor",type:"address"},{name:"amount",type:"uint96"},{name:"claimAddr",type:"address"},{name:"recipient",type:"address"},{name:"secretHash",type:"bytes32"},{name:"id",type:"string"}],S=[{name:"dropKeys",type:"bytes32[]"},{name:"records",type:"tuple[]",components:E}],ue=["AlreadyMapped","AmountOverflow","BelowMinDeposit","ChangeAlreadyRequested","ChangeInProgress","CountExceedsPending","DropAlreadyExists","DropNotFound","ECDSAInvalidSignature","EmptyId","IdMismatch","IdNotMapped","InvalidClaimSignature","InvalidExecutor","InvalidShortString","InvalidValidatorNonce","InvalidValidatorSignature","NoPendingChange","NotRecipient","NotSponsor","PendingLimitExceeded","RecipientNotEmpty","ReentrancyGuardReentrantCall","SameRecipient","SecretMismatch","TokenNotEighteenDecimals","ValidatorSigExpired","ZeroAmount","ZeroClaimAddress","ZeroCount","ZeroFeeRecipient","ZeroRecipient","ZeroSbt","ZeroSecretHash","ZeroToken","ZeroValidator"],R=[...ue.map(r=>({type:"error",name:r,inputs:[]})),{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32"}]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address"}]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string"}]}],s=[{type:"event",name:"Deposited",inputs:[{name:"addr",type:"address",indexed:!0},{name:"sponsor",type:"address",indexed:!0},{name:"dropKey",type:"bytes32",indexed:!0},{name:"amount",type:"uint256",indexed:!1},{name:"id",type:"string",indexed:!1},{name:"secretHash",type:"bytes32",indexed:!1},{name:"token",type:"address",indexed:!1}],anonymous:!1},{type:"function",name:"activeDropOf",stateMutability:"view",inputs:[{name:"sponsor",type:"address"},{name:"claimAddr",type:"address"}],outputs:[{type:"bytes32"}]},{type:"function",name:"drops",stateMutability:"view",inputs:[{name:"dropKey",type:"bytes32"}],outputs:E},{type:"function",name:"token",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{type:"function",name:"claimDigest",stateMutability:"view",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"}],outputs:[{type:"bytes32"}]},{type:"function",name:"anchorClaimDigest",stateMutability:"view",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"}],outputs:[{type:"bytes32"}]},{type:"function",name:"claimedRecipientOf",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:[{type:"address"}]},{type:"function",name:"pendingDropsByXid",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:S},{type:"function",name:"pendingDropsByRecipient",stateMutability:"view",inputs:[{name:"recipient",type:"address"}],outputs:S},{type:"function",name:"pendingDropsOf",stateMutability:"view",inputs:[{name:"sponsor",type:"address"}],outputs:S},{type:"function",name:"depositMapped",stateMutability:"nonpayable",inputs:[{name:"amount",type:"uint256"},{name:"id",type:"string"},{name:"permitDeadline",type:"uint256"},{name:"v",type:"uint8"},{name:"r",type:"bytes32"},{name:"s",type:"bytes32"}],outputs:[]},{type:"function",name:"withdrawUnmapped",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"dropKey",type:"bytes32"},{name:"signature",type:"bytes"},{name:"secret",type:"bytes"}],outputs:[]},{type:"function",name:"withdrawUnmappedBatchByKeys",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"anchorDropKey",type:"bytes32"},{name:"signature",type:"bytes"},{name:"secret",type:"bytes"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"executor",type:"address"},{name:"dropKeys",type:"bytes32[]"},{name:"validatorSignature",type:"bytes"}],outputs:[]},{type:"function",name:"withdrawMapped",stateMutability:"nonpayable",inputs:[{name:"dropKey",type:"bytes32"}],outputs:[]},{type:"function",name:"batchWithdrawMapped",stateMutability:"nonpayable",inputs:[{name:"count",type:"uint256"}],outputs:[]},{type:"function",name:"batchWithdrawMapped",stateMutability:"nonpayable",inputs:[{name:"dropKeys",type:"bytes32[]"}],outputs:[]},{type:"function",name:"refund",stateMutability:"nonpayable",inputs:[{name:"dropKey",type:"bytes32"}],outputs:[]},{type:"function",name:"changeNonceById",stateMutability:"view",inputs:[{name:"idKey",type:"bytes32"}],outputs:[{type:"uint256"}]},{type:"function",name:"pendingRecipientChange",stateMutability:"view",inputs:[{name:"idKey",type:"bytes32"}],outputs:[{name:"newRecipient",type:"address"}]},{type:"function",name:"requestRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"newRecipient",type:"address"}],outputs:[]},{type:"function",name:"completeRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"validatorSignature",type:"bytes"}],outputs:[]},{type:"function",name:"cancelRecipientChange",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"}],outputs:[]},{type:"function",name:"resetRecipient",stateMutability:"nonpayable",inputs:[{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"},{name:"validatorSignature",type:"bytes"}],outputs:[]},...R];var T=[{type:"function",name:"deposit",stateMutability:"nonpayable",inputs:[{name:"claimAddr",type:"address"},{name:"amount",type:"uint256"},{name:"id",type:"string"},{name:"secretHash",type:"bytes32"},{name:"deadline",type:"uint256"},{name:"v",type:"uint8"},{name:"r",type:"bytes32"},{name:"s",type:"bytes32"}],outputs:[]},{type:"function",name:"token",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},...R],b=[{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"nonces",stateMutability:"view",inputs:[{name:"owner",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"eip712Domain",stateMutability:"view",inputs:[],outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}]}],H={Permit:[{name:"owner",type:"address"},{name:"spender",type:"address"},{name:"value",type:"uint256"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}]};var g=[{type:"function",name:"validator",stateMutability:"view",inputs:[],outputs:[{type:"address"}]},{type:"function",name:"validatorClaimDigest",stateMutability:"view",inputs:[{name:"executor",type:"address"},{name:"recipient",type:"address"},{name:"id",type:"string"},{name:"nonce",type:"uint256"},{name:"deadline",type:"uint256"}],outputs:[{type:"bytes32"}]},{type:"function",name:"validatorNonceById",stateMutability:"view",inputs:[{name:"idHash",type:"bytes32"}],outputs:[{type:"uint256"}]},{type:"function",name:"claimedRecipientOf",stateMutability:"view",inputs:[{name:"id",type:"string"}],outputs:[{type:"address"}]},{type:"error",name:"ValidatorSigExpired",inputs:[]},{type:"error",name:"InvalidValidatorNonce",inputs:[]}];var be="0x0000000000000000000000000000000000000000",ge=`0x${"00".repeat(32)}`,fe={gas:BigInt(1e6),batchBaseGas:BigInt(1e6),batchGasPerDrop:BigInt(75e4),maxBatchGas:BigInt(3e7),maxFeePerGas:BigInt(4e9),maxPriorityFeePerGas:BigInt(1e9)},k=BigInt(1800),w=class{constructor(e){if(this.address=e.address,this.publicClient=e.publicClient,this.walletClient=e.walletClient,this.chain=e.chain,this.transport=e.transport??me(),this.transactionFees={...fe,...e.withdrawFees,...e.transactionFees},this.transactionFees.gas<=BigInt(0)||this.transactionFees.batchBaseGas<=BigInt(0)||this.transactionFees.batchGasPerDrop<=BigInt(0)||this.transactionFees.maxBatchGas<=BigInt(0)||this.transactionFees.maxFeePerGas<=BigInt(0)||this.transactionFees.maxPriorityFeePerGas<=BigInt(0)||this.transactionFees.maxPriorityFeePerGas>this.transactionFees.maxFeePerGas)throw new d("INVALID_PARAM","invalid EIP-1559 gas configuration");this.depositWithPermit=t=>this.permitDeposit(t)}async getDropByKey(e){try{let[t,n,i,a,o,y]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"drops",args:[e]});return t.toLowerCase()===be?null:{dropKey:e,sponsor:t,amount:n,claimAddress:i,recipient:a,secretHash:o,id:y}}catch(t){throw p("drops",t)}}async getDropKeyByClaimAddress(e,t){try{let n=await this.publicClient.readContract({address:this.address,abi:s,functionName:"activeDropOf",args:[t,e]});return n===ge?null:n}catch(n){throw p("activeDropOf",n)}}async getPendingDropsById(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsByXid",args:[e.id]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsByXid",t)}}async getPendingDropsByRecipient(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsByRecipient",args:[e.recipient]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsByRecipient",t)}}async getPendingDropsBySponsor(e){try{let[t,n]=await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingDropsOf",args:[e.sponsor]});return n.map((i,a)=>M(t[a],i))}catch(t){throw p("pendingDropsOf",t)}}async getDrop(e,t){let n=await this.getDropKeyByClaimAddress(e,t);if(!n)return null;let[i,a]=await Promise.all([this.getDropByKey(n),this.escrowToken()]);return i&&a?{...i,token:a}:null}async escrowToken(){try{return await this.publicClient.readContract({address:this.address,abi:T,functionName:"token"})}catch{throw new d("CHAIN_ERROR","token() failed")}}async getClaimDigest(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimDigest",args:[e.recipient,e.id,e.dropKey]})}catch(t){throw p("claimDigest",t)}}async permitDeposit(e){try{let t=this.requireAccount(),n=e.token,[i,a,o]=await Promise.all([this.publicClient.readContract({address:this.address,abi:T,functionName:"token"}),this.publicClient.readContract({address:n,abi:b,functionName:"nonces",args:[t.address]}),this.permitDomain(n)]);if(i.toLowerCase()!==n.toLowerCase())throw new d("INVALID_TOKEN","token does not match the escrow token",{expected:i,received:e.token});let y=BigInt(Math.floor(Date.now()/1e3))+k,u=await this.walletClient.signTypedData({account:t,domain:{...o,chainId:this.chain.id,verifyingContract:n},types:H,primaryType:"Permit",message:{owner:t.address,spender:this.address,value:e.amount,nonce:a,deadline:y}}),{r:C,s:x,v:A,yParity:v}=B(u),c=await this.walletClient.writeContract({address:this.address,abi:T,functionName:"deposit",args:[e.claimAddress,e.amount,e.id,e.secretHash,y,Number(A??BigInt(v+27)),C,x],account:t,chain:this.chain,...this.transactionOverrides()});await e.onSubmitted?.(c);let m=await this.confirm("depositWithPermit",c);return{txHash:c,dropKey:this.depositedDropKey(m.logs,t.address,e.amount,e.id,c)}}catch(t){throw p("depositWithPermit",t)}}async depositMapped(e){try{let t=this.requireAccount(),n=e.token,[i,a,o]=await Promise.all([this.publicClient.readContract({address:this.address,abi:s,functionName:"token"}),this.publicClient.readContract({address:n,abi:b,functionName:"nonces",args:[t.address]}),this.permitDomain(n)]);if(i.toLowerCase()!==n.toLowerCase())throw new d("INVALID_TOKEN","token does not match the escrow token",{expected:i,received:e.token});let y=BigInt(Math.floor(Date.now()/1e3))+k,u=await this.walletClient.signTypedData({account:t,domain:{...o,chainId:this.chain.id,verifyingContract:n},types:H,primaryType:"Permit",message:{owner:t.address,spender:this.address,value:e.amount,nonce:a,deadline:y}}),{r:C,s:x,v:A,yParity:v}=B(u),c=[e.amount,e.id,y,Number(A??BigInt(v+27)),C,x];await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"depositMapped",args:c,account:t});let m=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"depositMapped",args:c,account:t,chain:this.chain,...this.transactionOverrides()});await e.onSubmitted?.(m);let U=await this.confirm("depositMapped",m);return{txHash:m,dropKey:this.depositedDropKey(U.logs,t.address,e.amount,e.id,m)}}catch(t){throw p("depositMapped",t)}}async permitDomain(e){try{let t=await this.publicClient.readContract({address:e,abi:b,functionName:"eip712Domain"});return{name:t[1],version:t[2]}}catch{return{name:await this.publicClient.readContract({address:e,abi:b,functionName:"name"}),version:"1"}}}async withdrawUnmapped(e){try{let t=he(e.claimKey),n=await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimDigest",args:[e.recipient,e.id,e.dropKey]}),i=e.signature??_(await F({hash:n,privateKey:e.claimKey})),o=await ce({account:t,chain:this.chain,transport:this.transport}).writeContract({address:this.address,abi:s,functionName:"withdrawUnmapped",args:[e.recipient,e.id,e.dropKey,i,V(f(e.secret))],...this.transactionOverrides()});return await e.onSubmitted?.(o),await this.confirm("withdrawUnmapped",o),o}catch(t){throw L("withdrawUnmapped",t)}}async withdrawMapped(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"withdrawMapped",args:[e.dropKey],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"withdrawMapped",args:[e.dropKey],account:t,chain:this.chain,...this.transactionOverrides()});return await e.onSubmitted?.(n),await this.confirm("withdrawMapped",n),n}catch(n){throw p("withdrawMapped",n)}}async batchWithdrawMapped(e){if(!Number.isSafeInteger(e.count)||e.count<=0)throw new d("INVALID_PARAM","count must be a positive safe integer");let t=this.batchTransactionOverrides(e.count),n=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:[BigInt(e.count)],account:n});let i=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:[BigInt(e.count)],account:n,chain:this.chain,...t});return await this.confirm("batchWithdrawMapped",i),i}catch(i){throw p("batchWithdrawMapped",i)}}async batchWithdrawMappedByKeys(e){if(!e.dropKeys.length)throw new d("INVALID_PARAM","dropKeys must not be empty");let t=this.batchTransactionOverrides(e.dropKeys.length),n=this.requireAccount(),i=[e.dropKeys];try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:i,account:n});let a=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"batchWithdrawMapped",args:i,account:n,chain:this.chain,...t});return await this.confirm("batchWithdrawMapped",a),a}catch(a){throw p("batchWithdrawMapped",a)}}async withdrawUnmappedBatchByKeys(e){let t=e.dropKeys.filter(a=>a.toLowerCase()!==e.anchorDropKey.toLowerCase()),n=this.batchTransactionOverrides(t.length+1),i=this.requireAccount();try{let a=await this.publicClient.readContract({address:this.address,abi:s,functionName:"anchorClaimDigest",args:[e.recipient,e.id,e.anchorDropKey]}),o=_(await F({hash:a,privateKey:e.claimKey})),y=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"withdrawUnmappedBatchByKeys",args:[e.recipient,e.id,e.anchorDropKey,o,V(f(e.secret)),e.nonce,e.deadline,e.executor,t,e.validatorSignature],account:i,chain:this.chain,...n});return await this.confirm("withdrawUnmappedBatchByKeys",y),y}catch(a){throw L("withdrawUnmappedBatchByKeys",a)}}async getValidatorNonce(e){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validatorNonceById",args:[I(f(e.id))]})}catch(t){throw p("validatorNonceById",t)}}async getValidatorClaimDigest(e){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validatorClaimDigest",args:[e.executor,e.recipient,e.id,e.nonce,e.deadline]})}catch(t){throw p("validatorClaimDigest",t)}}async getValidator(){try{return await this.publicClient.readContract({address:this.address,abi:g,functionName:"validator"})}catch(e){throw p("validator",e)}}async getClaimedRecipient(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"claimedRecipientOf",args:[e.id]})}catch(t){throw p("claimedRecipientOf",t)}}async refundByKey(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"refund",args:[e.dropKey],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"refund",args:[e.dropKey],account:t,chain:this.chain,...this.transactionOverrides()});return await this.confirm("refund",n),n}catch(n){throw p("refund",n)}}async getChangeNonce(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"changeNonceById",args:[I(f(e.id))]})}catch(t){throw p("changeNonceById",t)}}async getPendingRecipientChange(e){try{return await this.publicClient.readContract({address:this.address,abi:s,functionName:"pendingRecipientChange",args:[I(f(e.id))]})}catch(t){throw p("pendingRecipientChange",t)}}async requestRecipientChange(e){return this.currentContractWrite("requestRecipientChange",[e.id,e.newRecipient])}async completeRecipientChange(e){return this.currentContractWrite("completeRecipientChange",[e.id,e.nonce,e.deadline,e.signature])}async cancelRecipientChange(e){return this.currentContractWrite("cancelRecipientChange",[e.id])}async resetRecipient(e){let t=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:"resetRecipient",args:[e.id,e.nonce,e.deadline,e.signature],account:t});let n=await this.walletClient.writeContract({address:this.address,abi:s,functionName:"resetRecipient",args:[e.id,e.nonce,e.deadline,e.signature],account:t,chain:this.chain,...this.transactionOverrides()});return await this.confirm("resetRecipient",n),n}catch(n){throw p("resetRecipient",n)}}async currentContractWrite(e,t){let n=this.requireAccount();try{await this.publicClient.simulateContract({address:this.address,abi:s,functionName:e,args:t,account:n});let i=await this.walletClient.writeContract({address:this.address,abi:s,functionName:e,args:t,account:n,chain:this.chain,...this.transactionOverrides()});return await this.confirm(e,i),i}catch(i){throw p(e,i)}}transactionOverrides(e=this.transactionFees.gas){return{type:"eip1559",gas:e,maxFeePerGas:this.transactionFees.maxFeePerGas,maxPriorityFeePerGas:this.transactionFees.maxPriorityFeePerGas}}batchTransactionOverrides(e){if(!Number.isSafeInteger(e)||e<=0)throw new d("INVALID_PARAM","batch count must be a positive safe integer");let t=this.transactionFees.batchBaseGas+this.transactionFees.batchGasPerDrop*BigInt(e);if(t>this.transactionFees.maxBatchGas)throw new d("INVALID_PARAM","batch gas exceeds maxBatchGas",{count:e,gas:t.toString(),maxBatchGas:this.transactionFees.maxBatchGas.toString()});return this.transactionOverrides(t)}async sponsorWrite(e,t){try{let n=await t();return await this.confirm(e,n),n}catch(n){throw p(e,n)}}depositedDropKey(e,t,n,i,a){let o=le({abi:s,eventName:"Deposited",logs:[...e]}).find(({address:y,args:u})=>y.toLowerCase()===this.address.toLowerCase()&&u.sponsor.toLowerCase()===t.toLowerCase()&&u.amount===n&&u.id===i);if(!o)throw new d("CHAIN_ERROR","deposit receipt omitted the Deposited event",{txHash:a});return o.args.dropKey}async confirm(e,t){let n=await this.publicClient.waitForTransactionReceipt({hash:t});if(n.status!=="success"){let i=await this.recoverRevertName(t,n.blockNumber),a=i?`SafeDrop.${e} reverted: ${i}`:`transaction reverted: ${t}`;throw new d("CHAIN_ERROR",a,{revertName:i,txHash:t})}return n}async recoverRevertName(e,t){try{let n=await this.publicClient.getTransaction({hash:e});await this.publicClient.call({account:n.from,to:n.to??void 0,data:n.input,value:n.value,blockNumber:t});return}catch(n){return O(n)}}requireAccount(){let e=this.walletClient.account;if(!e)throw new d("CHAIN_ERROR","walletClient has no account (connect a wallet first)");return e}};function M(r,e){return{dropKey:r,sponsor:e.sponsor,amount:e.amount,claimAddress:e.claimAddr,recipient:e.recipient,secretHash:e.secretHash,id:e.id}}function p(r,e){if(e instanceof d)return e;let t=O(e),n=e instanceof Error?e.message:String(e),i=t?`SafeDrop.${r} reverted: ${t}`:`SafeDrop.${r} failed`;return new d("CHAIN_ERROR",i,{cause:n,revertName:t})}function L(r,e){if(e instanceof d)return e;let t=O(e),n=e instanceof G?e.walk(o=>{let y=o;return typeof y.code=="number"||y.data!==void 0}):void 0,i={revertName:t};typeof n?.code=="number"&&(i.rpcCode=n.code),typeof n?.details=="string"&&(i.rpcMessage=n.details),typeof n?.data=="string"&&(i.rpcData=n.data);let a=t?`SafeDrop.${r} reverted: ${t}`:`SafeDrop.${r} failed`;return new d("CHAIN_ERROR",a,i)}function O(r){if(!(r instanceof G))return;let e=r.walk(t=>t instanceof K);if(e instanceof K)return e.data?.errorName??e.reason??void 0}var W=[{type:"constructor",inputs:[{name:"token_",type:"address",internalType:"contract IERC20"},{name:"validator_",type:"address",internalType:"address"},{name:"sbt_",type:"address",internalType:"contract ISoulboundToken"},{name:"feeRecipient_",type:"address",internalType:"address"},{name:"minDeposit_",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"FEE_BPS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"MAX_PENDING_PER_SPONSOR_ID",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"activeDropOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"claimAddr",type:"address",internalType:"address"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"anchorClaimDigest",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"batchWithdrawMapped",inputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"batchWithdrawMapped",inputs:[{name:"count",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"cancelRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"changeNonceById",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"changeRecipientDigest",inputs:[{name:"id",type:"string",internalType:"string"},{name:"newRecipient",type:"address",internalType:"address"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"claimDigest",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"claimedRecipientOf",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"completeRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"deposit",inputs:[{name:"claimAddr",type:"address",internalType:"address"},{name:"amount",type:"uint256",internalType:"uint256"},{name:"id",type:"string",internalType:"string"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"permitDeadline",type:"uint256",internalType:"uint256"},{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"depositMapped",inputs:[{name:"amount",type:"uint256",internalType:"uint256"},{name:"id",type:"string",internalType:"string"},{name:"permitDeadline",type:"uint256",internalType:"uint256"},{name:"v",type:"uint8",internalType:"uint8"},{name:"r",type:"bytes32",internalType:"bytes32"},{name:"s",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"drops",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"eip712Domain",inputs:[],outputs:[{name:"fields",type:"bytes1",internalType:"bytes1"},{name:"name",type:"string",internalType:"string"},{name:"version",type:"string",internalType:"string"},{name:"chainId",type:"uint256",internalType:"uint256"},{name:"verifyingContract",type:"address",internalType:"address"},{name:"salt",type:"bytes32",internalType:"bytes32"},{name:"extensions",type:"uint256[]",internalType:"uint256[]"}],stateMutability:"view"},{type:"function",name:"feeRecipient",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"minDeposit",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingCountOf",inputs:[{name:"sponsor",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingCountOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsByRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsByRecipient",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsByXid",inputs:[{name:"id",type:"string",internalType:"string"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsByXid",inputs:[{name:"id",type:"string",internalType:"string"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingDropsOf",inputs:[{name:"sponsor",type:"address",internalType:"address"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]}],stateMutability:"view"},{type:"function",name:"pendingDropsOf",inputs:[{name:"sponsor",type:"address",internalType:"address"},{name:"offset",type:"uint256",internalType:"uint256"},{name:"limit",type:"uint256",internalType:"uint256"}],outputs:[{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"records",type:"tuple[]",internalType:"struct ONEpop.Drop[]",components:[{name:"sponsor",type:"address",internalType:"address"},{name:"amount",type:"uint96",internalType:"uint96"},{name:"claimAddr",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"secretHash",type:"bytes32",internalType:"bytes32"},{name:"id",type:"string",internalType:"string"}]},{name:"total",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"pendingRecipientChange",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"newRecipient",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"refund",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"requestRecipientChange",inputs:[{name:"id",type:"string",internalType:"string"},{name:"newRecipient",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"resetRecipient",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"resetRecipientDigest",inputs:[{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"sbt",inputs:[],outputs:[{name:"",type:"address",internalType:"contract ISoulboundToken"}],stateMutability:"view"},{type:"function",name:"settledCountOf",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"token",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC20"}],stateMutability:"view"},{type:"function",name:"validator",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"validatorClaimDigest",inputs:[{name:"executor",type:"address",internalType:"address"},{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"validatorNonceById",inputs:[{name:"idKey",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"withdrawMapped",inputs:[{name:"dropKey",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmapped",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"dropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmappedBatch",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"anchorDropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"executor",type:"address",internalType:"address"},{name:"payCount",type:"uint256",internalType:"uint256"},{name:"moveCount",type:"uint256",internalType:"uint256"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"withdrawUnmappedBatchByKeys",inputs:[{name:"recipient",type:"address",internalType:"address"},{name:"id",type:"string",internalType:"string"},{name:"anchorDropKey",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"},{name:"secret",type:"bytes",internalType:"bytes"},{name:"nonce",type:"uint256",internalType:"uint256"},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"executor",type:"address",internalType:"address"},{name:"dropKeys",type:"bytes32[]",internalType:"bytes32[]"},{name:"validatorSignature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"Deposited",inputs:[{name:"addr",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"secretHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"EIP712DomainChanged",inputs:[],anonymous:!1},{type:"event",name:"FeeCharged",inputs:[{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"gross",type:"uint256",indexed:!1,internalType:"uint256"},{name:"fee",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Moved",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"sponsor",type:"address",indexed:!1,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"RecipientChangeCancelled",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientChangeRequested",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientChanged",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientMapped",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"RecipientReset",inputs:[{name:"idKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"}],anonymous:!1},{type:"event",name:"Refunded",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"dropKey",type:"bytes32",indexed:!0,internalType:"bytes32"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Withdrawn",inputs:[{name:"claimAddr",type:"address",indexed:!0,internalType:"address"},{name:"recipient",type:"address",indexed:!0,internalType:"address"},{name:"sponsor",type:"address",indexed:!0,internalType:"address"},{name:"id",type:"string",indexed:!1,internalType:"string"},{name:"amount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"sbtTokenId",type:"uint256",indexed:!1,internalType:"uint256"},{name:"dropKey",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"error",name:"AlreadyMapped",inputs:[]},{type:"error",name:"AmountOverflow",inputs:[]},{type:"error",name:"BelowMinDeposit",inputs:[]},{type:"error",name:"ChangeAlreadyRequested",inputs:[]},{type:"error",name:"ChangeInProgress",inputs:[]},{type:"error",name:"CountExceedsPending",inputs:[]},{type:"error",name:"DropAlreadyExists",inputs:[]},{type:"error",name:"DropNotFound",inputs:[]},{type:"error",name:"ECDSAInvalidSignature",inputs:[]},{type:"error",name:"ECDSAInvalidSignatureLength",inputs:[{name:"length",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ECDSAInvalidSignatureS",inputs:[{name:"s",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"EmptyId",inputs:[]},{type:"error",name:"IdMismatch",inputs:[]},{type:"error",name:"IdNotMapped",inputs:[]},{type:"error",name:"InvalidClaimSignature",inputs:[]},{type:"error",name:"InvalidExecutor",inputs:[]},{type:"error",name:"InvalidShortString",inputs:[]},{type:"error",name:"InvalidValidatorNonce",inputs:[]},{type:"error",name:"InvalidValidatorSignature",inputs:[]},{type:"error",name:"NoPendingChange",inputs:[]},{type:"error",name:"NotRecipient",inputs:[]},{type:"error",name:"NotSponsor",inputs:[]},{type:"error",name:"PendingLimitExceeded",inputs:[]},{type:"error",name:"RecipientNotEmpty",inputs:[]},{type:"error",name:"ReentrancyGuardReentrantCall",inputs:[]},{type:"error",name:"SafeERC20FailedOperation",inputs:[{name:"token",type:"address",internalType:"address"}]},{type:"error",name:"SameRecipient",inputs:[]},{type:"error",name:"SecretMismatch",inputs:[]},{type:"error",name:"StringTooLong",inputs:[{name:"str",type:"string",internalType:"string"}]},{type:"error",name:"TokenNotEighteenDecimals",inputs:[]},{type:"error",name:"ValidatorSigExpired",inputs:[]},{type:"error",name:"ZeroAmount",inputs:[]},{type:"error",name:"ZeroClaimAddress",inputs:[]},{type:"error",name:"ZeroCount",inputs:[]},{type:"error",name:"ZeroFeeRecipient",inputs:[]},{type:"error",name:"ZeroRecipient",inputs:[]},{type:"error",name:"ZeroSbt",inputs:[]},{type:"error",name:"ZeroSecretHash",inputs:[]},{type:"error",name:"ZeroToken",inputs:[]},{type:"error",name:"ZeroValidator",inputs:[]}];var Te=W;function Ce(r){let e=r.apiPort??new P(r.api),t=new w({address:r.contractAddress??D().onePop,publicClient:r.publicClient,walletClient:r.walletClient,chain:r.chain,transport:r.transport,withdrawFees:r.withdrawFees,transactionFees:r.transactionFees});return N({claimBaseUrl:r.claimBaseUrl},{api:e,chain:t,signer:new h,crypto:new l})}export{Q as CrossAuthClient,X as DEFAULT_POP_API_PATHS,P as HttpSafeDropApiAdapter,ne as HttpXAuthAdapter,s as ONEPOP_ABI,q as ONE_POP_BPS_DENOMINATOR,$ as ONE_POP_DEPLOYMENTS,Z as ONE_POP_FEE_BPS,Te as SAFEDROP_ABI,g as SAFEDROP_VALIDATOR_ABI,h as ViemClaimSignerAdapter,l as ViemCryptoAdapter,w as ViemSafeDropChainAdapter,ie as XAuthClient,Ce as createSafeDropClient,ee as generatePkce,te as generateState,J as getCrossAuthBaseUrl,z as getOnePopApiBaseUrl,D as getOnePopContracts,Y as getOnePopDeployment,j as getPopEnvironment};
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { C as CrossAuthClient, a as CrossAuthClientOptions, D as DEFAULT_POP_API_PATHS, b as HttpSafeDropApiAdapter, H as HttpSafeDropApiAdapterOptions, c as HttpXAuthAdapter, d as HttpXAuthAdapterOptions, e as ONE_POP_DEPLOYMENTS, P as Pkce, g as PopApiPaths, h as PopContracts, i as PopDeployment, j as PopEnvironment, S as SessionStore, X as XAuthClient, k as XAuthClientOptions, l as generatePkce, m as generateState, n as getCrossAuthBaseUrl, o as getOnePopApiBaseUrl, s as resolvePopEnvironment } from '../index-
|
|
2
|
-
import '../SafeDropApiPort-
|
|
1
|
+
export { C as CrossAuthClient, a as CrossAuthClientOptions, D as DEFAULT_POP_API_PATHS, b as HttpSafeDropApiAdapter, H as HttpSafeDropApiAdapterOptions, c as HttpXAuthAdapter, d as HttpXAuthAdapterOptions, e as ONE_POP_DEPLOYMENTS, P as Pkce, g as PopApiPaths, h as PopContracts, i as PopDeployment, j as PopEnvironment, S as SessionStore, X as XAuthClient, k as XAuthClientOptions, l as generatePkce, m as generateState, n as getCrossAuthBaseUrl, o as getOnePopApiBaseUrl, s as resolvePopEnvironment } from '../index-DVeDD7Dp.js';
|
|
2
|
+
import '../SafeDropApiPort-B7NfQOsb.js';
|
|
3
3
|
import '../XAuthPort-BNJePosj.js';
|
package/dist/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as t,d as e,f as p,i as o,j as r,k as n,l as A,m as s,n as P,o as i,p as a}from"../chunk-
|
|
1
|
+
import{c as t,d as e,f as p,i as o,j as r,k as n,l as A,m as s,n as P,o as i,p as a}from"../chunk-ENB6CCH7.js";import"../chunk-5DT3H2VX.js";export{A as CrossAuthClient,e as DEFAULT_POP_API_PATHS,n as HttpSafeDropApiAdapter,i as HttpXAuthAdapter,t as ONE_POP_DEPLOYMENTS,a as XAuthClient,s as generatePkce,P as generateState,r as getCrossAuthBaseUrl,o as getOnePopApiBaseUrl,p as resolvePopEnvironment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-5DT3H2VX.js";var h=BigInt(500),Q=BigInt(1e4),E={dev:{apiBaseUrl:"https://dev-one-pop-api.onechain.nexus/api",contracts:{onePop:"0xdC44AEF049Fb86Bd78CA887C330903cb2c031b7D",permitErc20:"0xFaDAB54449262178aE0562F5D8416bBeF4659714",nft:"0xc09f0E4B342e32ef32ca73306B5A29B3C8d01aE8",nftMinter:"0xdC44AEF049Fb86Bd78CA887C330903cb2c031b7D",validator:"0xF30d8e0544f0b92A6987522f4F696D3915B579b4",feeRecipient:"0xF30d8e0544f0b92A6987522f4F696D3915B579b4"}},stage:{apiBaseUrl:"https://stg-one-pop-api.onechain.nexus/api",contracts:{onePop:"0x7a54205e47819344eC3b89D5637C779531346642",permitErc20:"0xFaDAB54449262178aE0562F5D8416bBeF4659714",nft:"0x0B35DaD70114663EC07d5b86763B15f3DaCd7C8D",nftMinter:"0x7a54205e47819344eC3b89D5637C779531346642",validator:"0xa953af3742345dFC2BdcA30cBa79D8313b0a3B61",feeRecipient:"0xa953af3742345dFC2BdcA30cBa79D8313b0a3B61"}},production:{apiBaseUrl:"https://one-pop-api.onechain.nexus/api"}},b={createWallet:"/wallets",dropMetadata:"/drops/metadata",retrievePrivateKey:"/wallets/private-key",drops:"/drops",rejectDrops:"/drops/reject",envelopes:"/envelopes",leaderboards:"/leaderboards",leaderboardMe:"/leaderboards/me",histories:"/histories",xConnections:"/x-connections",batchClaimSignature:"/batch-claim-signature",feedbacks:"/feedbacks",revealYou:"/reveal-you",recipientChangeSignature:"/recipient-change-signature",recipientResetSignature:"/recipient-reset-signature",eventsSubscribe:"/events/subscribe"},X="https://dev-cross-auth.crosstoken.io";function f(r){try{return import.meta.env?.[r]}catch{return}}function u(r){if(!(typeof process>"u"||!process.env))switch(r){case"NEXT_PUBLIC_ONE_POP_ENVIRONMENT":return process.env.NEXT_PUBLIC_ONE_POP_ENVIRONMENT;case"ONE_POP_ENVIRONMENT":return process.env.ONE_POP_ENVIRONMENT;case"NEXT_PUBLIC_ONE_POP_API_BASE_URL":return process.env.NEXT_PUBLIC_ONE_POP_API_BASE_URL;case"NEXT_PUBLIC_CROSS_AUTH_URL":return process.env.NEXT_PUBLIC_CROSS_AUTH_URL;default:return}}function R(){let r=f("VITE_ONE_POP_ENVIRONMENT")??u("NEXT_PUBLIC_ONE_POP_ENVIRONMENT")??u("ONE_POP_ENVIRONMENT");return $(r)}function $(r){switch(r?.toLowerCase()){case"dev":case"development":return"dev";case"stg":case"stage":case"staging":return"stage";case void 0:case"production":case"prod":return"production";default:throw new Error(`[pop] Invalid environment: ${r}`)}}function F(){return E[R()]}function ee(){return q(R())}function q(r){let e=E[r].contracts;if(!e)throw new Error(`[pop] Contract addresses are not configured for ${r}`);return e}function A(){let e=f("VITE_ONE_POP_API_BASE_URL")??u("NEXT_PUBLIC_ONE_POP_API_BASE_URL")??F().apiBaseUrl;return I(e),e}function w(){let e=(f("VITE_CROSS_AUTH_URL")??u("NEXT_PUBLIC_CROSS_AUTH_URL")??X).replace(/\/+$/,"");return I(e),e}function I(r){let e;try{e=new URL(r)}catch{throw new Error(`[pop] Invalid base URL: ${r}`)}if(e.protocol==="https:")return;let t=e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".local");if(!(e.protocol==="http:"&&t))throw new Error(`[pop] base URL must be https (or http://localhost for dev). Got: ${r}`)}var V={INVALID_PARAM:"INVALID_PARAM",RATE_LIMITED:"RATE_LIMITED",INVALID_OAUTH_TOKEN:"INVALID_OAUTH_TOKEN",UNAUTHORIZED:"UNAUTHORIZED",WALLET_NOT_FOUND:"WALLET_NOT_FOUND",SEND_BLOCKED:"SEND_BLOCKED",ENVELOPE_NOT_FOUND:"ENVELOPE_NOT_FOUND",PENDING_LIMIT_EXCEEDED:"PENDING_LIMIT_EXCEEDED",DROP_NOT_FOUND:"DROP_NOT_FOUND",IDENTIFIER_NOT_MAPPED:"IDENTIFIER_NOT_MAPPED",X_CONNECTION_NOT_FOUND:"X_CONNECTION_NOT_FOUND",X_ALREADY_CONNECTED:"X_ALREADY_CONNECTED"},l=140,O=class{constructor(e={}){this.baseUrl=(e.baseUrl??A()).replace(/\/+$/,"");let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t,this.getJwt=e.getJwt,this.paths={...b,...e.paths}}async createClaimWallet(e){let t=await this.request(this.paths.createWallet,{method:"POST",auth:!0,payload:{identifier:e.recipient.handle,oauth_type:e.recipient.provider,sender_address:e.sender}});if(!t?.address)throw new o("API_ERROR","createClaimWallet: missing address in response",{body:t});if(!t.identifier)throw new o("API_ERROR","createClaimWallet: missing identifier in response",{body:t});return{claimAddress:t.address,id:t.identifier,isMapped:t.is_mapped===!0}}async recordDropMetadata(e){if(e.message&&[...e.message].length>l)throw new o("INVALID_PARAM",`message must be <= ${l} runes`);await this.request(this.paths.dropMetadata,{method:"POST",auth:!0,query:{tx_hash:e.txHash},payload:{...e.message?{message:e.message}:{},...e.envelopeId?{envelope_id:e.envelopeId}:{}}})}async retrieveClaimKey(e){let t=await this.request(this.paths.retrievePrivateKey,{method:"POST",payload:{oauth_token:e.oauth.accessToken,oauth_type:e.oauth.provider,sender_address:e.senderAddress,address:e.claimAddress}});if(t?.private_key&&t.address){if(t.address.toLowerCase()!==e.claimAddress.toLowerCase())throw new o("API_ERROR","retrieveClaimKey: returned a different address");return{isMapped:!1,claimKey:t.private_key,claimAddress:t.address}}if(t?.is_mapped===!0)return{isMapped:!0};throw new o("API_ERROR","retrieveClaimKey: missing key/address in response",{body:t})}async listDrops(e){if(!e?.token)throw new o("INVALID_PARAM","listDrops requires a token address");let t=await this.request(this.paths.drops,{method:"GET",auth:!0,query:{token:e.token,drop_key:e.dropKey}});return{items:(t?.items??[]).map(z),count:t?.count??0,totalAmount:d(t?.total_amount,"drops.total_amount"),hasClaimedBefore:t?.has_claimed_before===!0,mappedRecipient:c(t?.mapped_recipient),pendingChangeTo:c(t?.pending_change_to),feeBps:t?.fee_bps??Number(h)}}async rejectDrops(e){if(!Array.isArray(e.dropIds)||e.dropIds.length===0||e.dropIds.length>100||e.dropIds.some(n=>!Number.isSafeInteger(n)||n<=0))throw new o("INVALID_PARAM","dropIds must contain 1-100 positive integers");return(await this.request(this.paths.rejectDrops,{method:"POST",auth:!0,payload:{drop_ids:e.dropIds}}))?.count??0}async listEnvelopes(e={}){return((await this.request(this.paths.envelopes,{method:"GET",query:{locale:e.locale}}))?.items??[]).map(n=>({id:s(n.id),name:s(n.name),imageUrl:s(n.image_url),badge:s(n.badge),sortOrder:Number(n.sort_order??0),layout:n.layout}))}async getLeaderboard(e){if(!e.token)throw new o("INVALID_PARAM","getLeaderboard requires a token address");let t=await this.request(this.paths.leaderboards,{method:"GET",query:{token:e.token,page:e.page,page_size:e.pageSize,identifier:e.identifier}});return{items:(t?.items??[]).map(T),page:t?.page??1,pageSize:t?.page_size??0,total:t?.total??0}}async getMyLeaderboardEntry(e){let t=await this.request(this.paths.leaderboardMe,{method:"GET",auth:!0,query:{token:e.token}});return{...T(t??{}),rank:k(t?.rank)}}async listHistories(e){if(!e?.type)throw new o("INVALID_PARAM","listHistories requires type");let t=await this.request(this.paths.histories,{method:"GET",auth:!0,query:{type:e.type,token:e.token,status:e.status,rejected:e.rejected===void 0?void 0:String(e.rejected),page:e.page,page_size:e.pageSize}});return{items:(t?.items??[]).map(n=>({id:Number(n.id??0),type:s(n.type),status:s(n.status),token:s(n.token),amount:d(n.amount,"history.amount"),claimAddress:s(n.claim_address),depositTxHash:s(n.deposit_tx_hash),depositedAt:s(n.deposited_at),resolvedTxHash:c(n.resolved_tx_hash),resolvedAt:c(n.resolved_at),message:s(n.message),feedback:c(n.feedback),envelopeId:s(n.envelope_id),rejected:n.rejected===!0,sender:U(n.sender),receiver:K(n.receiver)})),page:t?.page??1,pageSize:t?.page_size??0,total:t?.total??0,feeBps:t?.fee_bps??Number(h)}}async getXConnection(){let e=await this.request(this.paths.xConnections,{method:"GET",auth:!0,notFoundAsNull:!0});return e?S(e):null}async connectX(e){let t=await this.request(this.paths.xConnections,{method:"POST",auth:!0,payload:{oauth_token:e.oauth.accessToken}});return S(t??{})}async disconnectX(){await this.request(this.paths.xConnections,{method:"DELETE",auth:!0,notFoundAsNull:!0})}async submitFeedback(e){if(!Number.isSafeInteger(e.dropId)||e.dropId<=0)throw new o("INVALID_PARAM","dropId must be a positive integer");if(!e.message.trim()||[...e.message.trim()].length>l)throw new o("INVALID_PARAM",`message must be 1-${l} runes`);let t=await this.request(this.paths.feedbacks,{method:"PUT",auth:!0,query:{drop_id:e.dropId},payload:{message:e.message}});return s(t?.message)}async setRevealYou(e){return(await this.request(this.paths.revealYou,{method:"PUT",auth:!0,payload:{reveal_you:e.revealYou}}))?.reveal_you===!0}async requestRecipientChangeSignature(e){let t=await this.request(this.paths.recipientChangeSignature,{method:"POST",auth:!0,payload:v(e)});return{...N(t,e),newRecipient:s(t?.new_recipient)}}async requestRecipientResetSignature(e){let t=await this.request(this.paths.recipientResetSignature,{method:"POST",payload:v(e)});return N(t,e)}async requestBatchClaimSignature(e){let t=await this.request(this.paths.batchClaimSignature,{method:"POST",auth:!0,payload:{id:e.id,oauth_token:e.oauth.accessToken,nonce:e.nonce.toString(),deadline:e.deadline.toString()}}),n=s(t?.signature);if(!n)throw new o("API_ERROR","requestBatchClaimSignature: missing signature",{body:t});return{id:s(t?.id)||e.id,recipient:s(t?.recipient),nonce:g(t?.nonce)?d(t?.nonce,"batchClaim.nonce"):e.nonce,deadline:g(t?.deadline)?d(t?.deadline,"batchClaim.deadline"):e.deadline,signature:n}}async request(e,t){let n={};if(t.payload&&(n["Content-Type"]="application/json"),t.auth){let a=await this.getJwt?.();if(!a)throw new o("UNAUTHORIZED",`${e} requires a SIWE JWT (options.getJwt)`);n.Authorization=`Bearer ${a}`}let i;try{i=await this.fetchImpl(`${this.baseUrl}${e}${j(t.query)}`,{method:t.method,headers:n,body:t.payload?JSON.stringify(t.payload):void 0})}catch(a){throw new o("API_ERROR",`Network error calling ${e}`,{cause:a instanceof Error?a.message:String(a)})}if(i.status===404&&t.notFoundAsNull)return null;if(!i.ok){let a=await i.json().catch(()=>{}),p=a?.code_name;throw new o((p?V[p]:void 0)??"API_ERROR",a?.message?`${e}: ${a.message}`:`${e} responded ${i.status}`,{status:i.status,code:a?.code,codeName:p})}return i.status===204?null:await i.json().catch(()=>null)}};function j(r){if(!r)return"";let e=new URLSearchParams;for(let[n,i]of Object.entries(r))i!==void 0&&i!==""&&e.set(n,String(i));let t=e.toString();return t?`?${t}`:""}function g(r){return r!=null&&r!==""}function s(r){return typeof r=="string"?r:""}function c(r){return typeof r=="string"&&r?r:null}function d(r,e){if(typeof r=="bigint")return r;if(typeof r=="number"){if(!Number.isSafeInteger(r))throw new o("API_ERROR",`${e} exceeds safe-integer precision as a JSON number`,{value:r});return BigInt(r)}let t=typeof r=="string"?r.trim():"";if(!t)return BigInt(0);try{return BigInt(t)}catch{throw new o("API_ERROR",`${e} is not a valid decimal string`,{value:r})}}function z(r){let e=r??{},t=e.sender??{};return{id:Number(e.id??0),dropKey:s(e.drop_key),claimAddress:s(e.claim_address),token:s(e.token),amount:d(e.amount,"drop.amount"),message:s(e.message),envelopeId:s(e.envelope_id),depositedAt:s(e.deposited_at),rejected:e.rejected===!0,sender:{address:s(t.address),handle:s(t.handle),displayName:s(t.display_name),profileImageUrl:s(t.profile_image_url)}}}function S(r){return{xUserId:s(r.x_user_id),handle:s(r.handle),displayName:s(r.display_name),profileImageUrl:s(r.profile_image_url),walletAddress:s(r.wallet_address),revealYou:r.reveal_you===!0,onchainMapped:r.onchain_mapped===!0,mappedRecipient:c(r.mapped_recipient)}}function T(r){return{identifier:s(r.identifier),balance:d(r.balance,"leaderboard.balance"),lastDepositAmount:d(r.last_deposit_amount,"leaderboard.last_deposit_amount"),rank:Number(r.rank??0),previousRank:k(r.previous_rank),profileImageUrl:s(r.profile_image_url)}}function k(r){return typeof r=="number"?r:null}function U(r){let e=r??{};return{address:s(e.address),handle:s(e.handle),displayName:s(e.display_name),profileImageUrl:s(e.profile_image_url)}}function K(r){return{...U(r),address:c(r?.address)}}function v(r){return{id:r.id,oauth_token:r.oauth.accessToken,nonce:r.nonce.toString(),deadline:r.deadline.toString()}}function N(r,e){let t=s(r?.signature);if(!t)throw new o("API_ERROR","signature response is missing signature");return{id:s(r?.id)||e.id,nonce:g(r?.nonce)?d(r?.nonce,"signature.nonce"):e.nonce,deadline:g(r?.deadline)?d(r?.deadline,"signature.deadline"):e.deadline,signature:t}}var C=class{constructor(e={}){this.baseUrl=(e.baseUrl??w()).replace(/\/+$/,""),this.domain=e.domain??globalThis.location?.origin??"";let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t}unsignedHash(e,t){return this.post("/login/unsigned-hash",{chain_id:e,address:t,domain:this.domain})}siweToken(e,t){return this.post("/login/token",{address:e,signature:t,domain:this.domain})}async post(e,t){let n;try{n=await this.fetchImpl(`${this.baseUrl}/cross-auth${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(a){throw new o("API_ERROR",`cross-auth network error calling ${e}`,{cause:a instanceof Error?a.message:String(a)})}let i=await n.json().catch(()=>({}));if(!n.ok||i.data==null)throw new o("API_ERROR",`cross-auth ${e} failed`,{code:i.code,message:i.message});return i.data}};async function D(){let r=m(L(32)),e=await W().digest("SHA-256",G(r)),t=m(new Uint8Array(e));return{verifier:r,challenge:t,method:"S256"}}function x(){return m(L(16))}function L(r){let e=globalThis.crypto;if(!e?.getRandomValues)throw new Error("crypto.getRandomValues unavailable");let t=new Uint8Array(r);return e.getRandomValues(t),t}function W(){let r=globalThis.crypto?.subtle;if(!r)throw new Error("crypto.subtle unavailable (needs https/secure context)");return r}function G(r){return new TextEncoder().encode(r)}function m(r){let e="";for(let n of r)e+=String.fromCharCode(n);let t=globalThis.btoa?.(e);if(t===void 0)throw new Error("btoa unavailable");return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var B=class{constructor(e={}){this.baseUrl=(e.baseUrl??"").replace(/\/+$/,""),this.tokenPath=e.tokenPath??"/api/x/token",this.mePath=e.mePath??"/api/x/me";let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t}async exchangeCode(e){let n=await(await this.call(this.tokenPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:e.clientId,redirectUri:e.redirectUri,code:e.code,verifier:e.codeVerifier})})).json().catch(()=>({}));if(!n.access_token)throw new o("API_ERROR","X token exchange: missing access_token",{body:n});return{accessToken:n.access_token,scope:n.scope,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async getHandle(e){let n=await(await this.call(this.mePath,{method:"GET",headers:{Authorization:`Bearer ${e}`}})).json().catch(()=>({})),i=n.data?.username??n.username;if(!i)throw new o("API_ERROR","X /me: missing username",{body:n});return{handle:i}}async call(e,t){let n;try{n=await this.fetchImpl(`${this.baseUrl}${e}`,t)}catch(i){throw new o("API_ERROR",`Network error calling ${e}`,{cause:i instanceof Error?i.message:String(i)})}if(!n.ok)throw new o("API_ERROR",`${e} responded ${n.status}`,{status:n.status});return n}};var _="pop.xauth.verifier",P="pop.xauth.state",J="https://x.com/i/oauth2/authorize",Y="tweet.read users.read offline.access",M=class{constructor(e){this.opts={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope??Y,authorizeUrl:e.authorizeUrl??J,port:e.port,storage:e.storage??Z()}}async start(){let e=await D(),t=x();this.opts.storage.set(_,e.verifier),this.opts.storage.set(P,t);let n=new URLSearchParams({response_type:"code",client_id:this.opts.clientId,redirect_uri:this.opts.redirectUri,scope:this.opts.scope,state:t,code_challenge:e.challenge,code_challenge_method:"S256"});return{authorizeUrl:`${this.opts.authorizeUrl}?${n.toString()}`,state:t}}async complete(e){let t=new URL(e),n=t.searchParams.get("code"),i=t.searchParams.get("state");if(!n)throw new o("API_ERROR","X callback: missing authorization code",{error:t.searchParams.get("error")});let a=this.opts.storage.get(P);if(!i||!a||i!==a)throw new o("API_ERROR","X callback: state mismatch (possible CSRF)");let p=this.opts.storage.get(_);if(!p)throw new o("API_ERROR","X callback: missing PKCE verifier (expired session?)");let y=await this.opts.port.exchangeCode({clientId:this.opts.clientId,redirectUri:this.opts.redirectUri,code:n,codeVerifier:p}),{handle:H}=await this.opts.port.getHandle(y.accessToken);return this.opts.storage.remove(_),this.opts.storage.remove(P),{oauth:{provider:"x",accessToken:y.accessToken},handle:H}}};function Z(){let r=globalThis.sessionStorage;if(!r)throw new Error("sessionStorage unavailable; provide options.storage");return{get:e=>r.getItem(e),set:(e,t)=>r.setItem(e,t),remove:e=>r.removeItem(e)}}export{h as a,Q as b,E as c,b as d,R as e,$ as f,F as g,ee as h,A as i,w as j,O as k,C as l,D as m,x as n,B as o,M as p};
|
|
1
|
+
import{a as o}from"./chunk-5DT3H2VX.js";var g=BigInt(500),Q=BigInt(1e4),E={dev:{apiBaseUrl:"https://dev-one-pop-api.onechain.nexus/api",contracts:{onePop:"0xdC44AEF049Fb86Bd78CA887C330903cb2c031b7D",permitErc20:"0xFaDAB54449262178aE0562F5D8416bBeF4659714",nft:"0xc09f0E4B342e32ef32ca73306B5A29B3C8d01aE8",nftMinter:"0xdC44AEF049Fb86Bd78CA887C330903cb2c031b7D",validator:"0xF30d8e0544f0b92A6987522f4F696D3915B579b4",feeRecipient:"0xF30d8e0544f0b92A6987522f4F696D3915B579b4"}},stage:{apiBaseUrl:"https://stg-one-pop-api.onechain.nexus/api",contracts:{onePop:"0xb03B0C0d03E4Cbe91edD48fa3C4E6Bb1EEA65eDe",permitErc20:"0xFaDAB54449262178aE0562F5D8416bBeF4659714",nft:"0x0B35DaD70114663EC07d5b86763B15f3DaCd7C8D",nftMinter:"0x7a54205e47819344eC3b89D5637C779531346642",validator:"0xa953af3742345dFC2BdcA30cBa79D8313b0a3B61",feeRecipient:"0xa953af3742345dFC2BdcA30cBa79D8313b0a3B61"}},production:{apiBaseUrl:"https://one-pop-api.onechain.nexus/api"}},b={createWallet:"/wallets",dropMetadata:"/drops/metadata",retrievePrivateKey:"/wallets/private-key",drops:"/drops",rejectDrops:"/drops/reject",envelopes:"/envelopes",leaderboards:"/leaderboards",leaderboardMe:"/leaderboards/me",histories:"/histories",xConnections:"/x-connections",batchClaimSignature:"/batch-claim-signature",feedbacks:"/feedbacks",revealYou:"/reveal-you",recipientChangeSignature:"/recipient-change-signature",recipientResetSignature:"/recipient-reset-signature",eventsSubscribe:"/events/subscribe"},X="https://dev-cross-auth.crosstoken.io";function f(r){try{return import.meta.env?.[r]}catch{return}}function u(r){if(!(typeof process>"u"||!process.env))switch(r){case"NEXT_PUBLIC_ONE_POP_ENVIRONMENT":return process.env.NEXT_PUBLIC_ONE_POP_ENVIRONMENT;case"ONE_POP_ENVIRONMENT":return process.env.ONE_POP_ENVIRONMENT;case"NEXT_PUBLIC_ONE_POP_API_BASE_URL":return process.env.NEXT_PUBLIC_ONE_POP_API_BASE_URL;case"NEXT_PUBLIC_CROSS_AUTH_URL":return process.env.NEXT_PUBLIC_CROSS_AUTH_URL;default:return}}function R(){let r=f("VITE_ONE_POP_ENVIRONMENT")??u("NEXT_PUBLIC_ONE_POP_ENVIRONMENT")??u("ONE_POP_ENVIRONMENT");return $(r)}function $(r){switch(r?.toLowerCase()){case"dev":case"development":return"dev";case"stg":case"stage":case"staging":return"stage";case void 0:case"production":case"prod":return"production";default:throw new Error(`[pop] Invalid environment: ${r}`)}}function F(){return E[R()]}function ee(){return q(R())}function q(r){let e=E[r].contracts;if(!e)throw new Error(`[pop] Contract addresses are not configured for ${r}`);return e}function A(){let e=f("VITE_ONE_POP_API_BASE_URL")??u("NEXT_PUBLIC_ONE_POP_API_BASE_URL")??F().apiBaseUrl;return I(e),e}function w(){let e=(f("VITE_CROSS_AUTH_URL")??u("NEXT_PUBLIC_CROSS_AUTH_URL")??X).replace(/\/+$/,"");return I(e),e}function I(r){let e;try{e=new URL(r)}catch{throw new Error(`[pop] Invalid base URL: ${r}`)}if(e.protocol==="https:")return;let t=e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".local");if(!(e.protocol==="http:"&&t))throw new Error(`[pop] base URL must be https (or http://localhost for dev). Got: ${r}`)}var V={INVALID_PARAM:"INVALID_PARAM",RATE_LIMITED:"RATE_LIMITED",INVALID_OAUTH_TOKEN:"INVALID_OAUTH_TOKEN",UNAUTHORIZED:"UNAUTHORIZED",WALLET_NOT_FOUND:"WALLET_NOT_FOUND",SEND_BLOCKED:"SEND_BLOCKED",ENVELOPE_NOT_FOUND:"ENVELOPE_NOT_FOUND",PENDING_LIMIT_EXCEEDED:"PENDING_LIMIT_EXCEEDED",DROP_NOT_FOUND:"DROP_NOT_FOUND",IDENTIFIER_NOT_MAPPED:"IDENTIFIER_NOT_MAPPED",X_CONNECTION_NOT_FOUND:"X_CONNECTION_NOT_FOUND",X_ALREADY_CONNECTED:"X_ALREADY_CONNECTED"},l=140,O=class{constructor(e={}){this.baseUrl=(e.baseUrl??A()).replace(/\/+$/,"");let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t,this.getJwt=e.getJwt,this.paths={...b,...e.paths}}async createClaimWallet(e){let t=await this.request(this.paths.createWallet,{method:"POST",auth:!0,payload:{identifier:e.recipient.handle,oauth_type:e.recipient.provider,sender_address:e.sender}});if(!t?.address)throw new o("API_ERROR","createClaimWallet: missing address in response",{body:t});if(!t.identifier)throw new o("API_ERROR","createClaimWallet: missing identifier in response",{body:t});return{claimAddress:t.address,id:t.identifier,isMapped:t.is_mapped===!0}}async recordDropMetadata(e){if(e.message&&[...e.message].length>l)throw new o("INVALID_PARAM",`message must be <= ${l} runes`);await this.request(this.paths.dropMetadata,{method:"POST",auth:!0,query:{tx_hash:e.txHash},payload:{...e.message?{message:e.message}:{},...e.envelopeId?{envelope_id:e.envelopeId}:{}}})}async retrieveClaimKey(e){let t=await this.request(this.paths.retrievePrivateKey,{method:"POST",payload:{oauth_token:e.oauth.accessToken,oauth_type:e.oauth.provider,sender_address:e.senderAddress,address:e.claimAddress}});if(t?.private_key&&t.address){if(t.address.toLowerCase()!==e.claimAddress.toLowerCase())throw new o("API_ERROR","retrieveClaimKey: returned a different address");return{isMapped:!1,claimKey:t.private_key,claimAddress:t.address}}if(t?.is_mapped===!0)return{isMapped:!0};throw new o("API_ERROR","retrieveClaimKey: missing key/address in response",{body:t})}async listDrops(e){if(!e?.token)throw new o("INVALID_PARAM","listDrops requires a token address");let t=await this.request(this.paths.drops,{method:"GET",auth:!0,query:{token:e.token,drop_key:e.dropKey}});return{items:(t?.items??[]).map(z),count:t?.count??0,totalAmount:d(t?.total_amount,"drops.total_amount"),hasClaimedBefore:t?.has_claimed_before===!0,mappedRecipient:c(t?.mapped_recipient),pendingChangeTo:c(t?.pending_change_to),feeBps:t?.fee_bps??Number(g)}}async rejectDrops(e){if(!Array.isArray(e.dropIds)||e.dropIds.length===0||e.dropIds.length>100||e.dropIds.some(n=>!Number.isSafeInteger(n)||n<=0))throw new o("INVALID_PARAM","dropIds must contain 1-100 positive integers");return(await this.request(this.paths.rejectDrops,{method:"POST",auth:!0,payload:{drop_ids:e.dropIds}}))?.count??0}async listEnvelopes(e={}){return((await this.request(this.paths.envelopes,{method:"GET",query:{locale:e.locale}}))?.items??[]).map(n=>({id:s(n.id),name:s(n.name),imageUrl:s(n.image_url),badge:s(n.badge),sortOrder:Number(n.sort_order??0),layout:n.layout}))}async getLeaderboard(e){if(!e.token)throw new o("INVALID_PARAM","getLeaderboard requires a token address");let t=await this.request(this.paths.leaderboards,{method:"GET",query:{token:e.token,page:e.page,page_size:e.pageSize,identifier:e.identifier}});return{items:(t?.items??[]).map(T),page:t?.page??1,pageSize:t?.page_size??0,total:t?.total??0}}async getMyLeaderboardEntry(e){let t=await this.request(this.paths.leaderboardMe,{method:"GET",auth:!0,query:{token:e.token}});return{...T(t??{}),rank:k(t?.rank)}}async listHistories(e){if(!e?.type)throw new o("INVALID_PARAM","listHistories requires type");let t=await this.request(this.paths.histories,{method:"GET",auth:!0,query:{type:e.type,token:e.token,status:e.status,rejected:e.rejected===void 0?void 0:String(e.rejected),page:e.page,page_size:e.pageSize}});return{items:(t?.items??[]).map(n=>({id:Number(n.id??0),type:s(n.type),status:s(n.status),token:s(n.token),amount:d(n.amount,"history.amount"),claimAddress:s(n.claim_address),depositTxHash:s(n.deposit_tx_hash),depositedAt:s(n.deposited_at),resolvedTxHash:c(n.resolved_tx_hash),resolvedAt:c(n.resolved_at),message:s(n.message),feedback:c(n.feedback),envelopeId:s(n.envelope_id),rejected:n.rejected===!0,sender:U(n.sender),receiver:K(n.receiver)})),page:t?.page??1,pageSize:t?.page_size??0,total:t?.total??0,feeBps:t?.fee_bps??Number(g)}}async getXConnection(){let e=await this.request(this.paths.xConnections,{method:"GET",auth:!0,notFoundAsNull:!0});return e?S(e):null}async connectX(e){let t=await this.request(this.paths.xConnections,{method:"POST",auth:!0,payload:{oauth_token:e.oauth.accessToken}});return S(t??{})}async disconnectX(){await this.request(this.paths.xConnections,{method:"DELETE",auth:!0,notFoundAsNull:!0})}async submitFeedback(e){if(!Number.isSafeInteger(e.dropId)||e.dropId<=0)throw new o("INVALID_PARAM","dropId must be a positive integer");if(!e.message.trim()||[...e.message.trim()].length>l)throw new o("INVALID_PARAM",`message must be 1-${l} runes`);let t=await this.request(this.paths.feedbacks,{method:"PUT",auth:!0,query:{drop_id:e.dropId},payload:{message:e.message}});return s(t?.message)}async setRevealYou(e){return(await this.request(this.paths.revealYou,{method:"PUT",auth:!0,payload:{reveal_you:e.revealYou}}))?.reveal_you===!0}async requestRecipientChangeSignature(e){let t=await this.request(this.paths.recipientChangeSignature,{method:"POST",auth:!0,payload:v(e)});return{...N(t,e),newRecipient:s(t?.new_recipient)}}async requestRecipientResetSignature(e){let t=await this.request(this.paths.recipientResetSignature,{method:"POST",payload:v(e)});return N(t,e)}async requestBatchClaimSignature(e){let t=await this.request(this.paths.batchClaimSignature,{method:"POST",auth:!0,payload:{id:e.id,oauth_token:e.oauth.accessToken,nonce:e.nonce.toString(),deadline:e.deadline.toString()}}),n=s(t?.signature);if(!n)throw new o("API_ERROR","requestBatchClaimSignature: missing signature",{body:t});return{id:s(t?.id)||e.id,recipient:s(t?.recipient),nonce:h(t?.nonce)?d(t?.nonce,"batchClaim.nonce"):e.nonce,deadline:h(t?.deadline)?d(t?.deadline,"batchClaim.deadline"):e.deadline,signature:n}}async request(e,t){let n={};if(t.payload&&(n["Content-Type"]="application/json"),t.auth){let a=await this.getJwt?.();if(!a)throw new o("UNAUTHORIZED",`${e} requires a SIWE JWT (options.getJwt)`);n.Authorization=`Bearer ${a}`}let i;try{i=await this.fetchImpl(`${this.baseUrl}${e}${j(t.query)}`,{method:t.method,headers:n,body:t.payload?JSON.stringify(t.payload):void 0})}catch(a){throw new o("API_ERROR",`Network error calling ${e}`,{cause:a instanceof Error?a.message:String(a)})}if(i.status===404&&t.notFoundAsNull)return null;if(!i.ok){let a=await i.json().catch(()=>{}),p=a?.code_name;throw new o((p?V[p]:void 0)??"API_ERROR",a?.message?`${e}: ${a.message}`:`${e} responded ${i.status}`,{status:i.status,code:a?.code,codeName:p})}return i.status===204?null:await i.json().catch(()=>null)}};function j(r){if(!r)return"";let e=new URLSearchParams;for(let[n,i]of Object.entries(r))i!==void 0&&i!==""&&e.set(n,String(i));let t=e.toString();return t?`?${t}`:""}function h(r){return r!=null&&r!==""}function s(r){return typeof r=="string"?r:""}function c(r){return typeof r=="string"&&r?r:null}function d(r,e){if(typeof r=="bigint")return r;if(typeof r=="number"){if(!Number.isSafeInteger(r))throw new o("API_ERROR",`${e} exceeds safe-integer precision as a JSON number`,{value:r});return BigInt(r)}let t=typeof r=="string"?r.trim():"";if(!t)return BigInt(0);try{return BigInt(t)}catch{throw new o("API_ERROR",`${e} is not a valid decimal string`,{value:r})}}function z(r){let e=r??{},t=e.sender??{};return{id:Number(e.id??0),dropKey:s(e.drop_key),claimAddress:s(e.claim_address),token:s(e.token),amount:d(e.amount,"drop.amount"),message:s(e.message),envelopeId:s(e.envelope_id),depositedAt:s(e.deposited_at),rejected:e.rejected===!0,sender:{address:s(t.address),handle:s(t.handle),displayName:s(t.display_name),profileImageUrl:s(t.profile_image_url)}}}function S(r){return{xUserId:s(r.x_user_id),handle:s(r.handle),displayHandle:s(r.display_handle),displayName:s(r.display_name),profileImageUrl:s(r.profile_image_url),walletAddress:s(r.wallet_address),revealYou:r.reveal_you===!0,onchainMapped:r.onchain_mapped===!0,mappedRecipient:c(r.mapped_recipient)}}function T(r){return{identifier:s(r.identifier),displayHandle:s(r.display_handle),balance:d(r.balance,"leaderboard.balance"),lastDepositAmount:d(r.last_deposit_amount,"leaderboard.last_deposit_amount"),rank:Number(r.rank??0),previousRank:k(r.previous_rank),profileImageUrl:s(r.profile_image_url)}}function k(r){return typeof r=="number"?r:null}function U(r){let e=r??{};return{address:s(e.address),handle:s(e.handle),displayHandle:s(e.display_handle),displayName:s(e.display_name),profileImageUrl:s(e.profile_image_url)}}function K(r){return{...U(r),address:c(r?.address)}}function v(r){return{id:r.id,oauth_token:r.oauth.accessToken,nonce:r.nonce.toString(),deadline:r.deadline.toString()}}function N(r,e){let t=s(r?.signature);if(!t)throw new o("API_ERROR","signature response is missing signature");return{id:s(r?.id)||e.id,nonce:h(r?.nonce)?d(r?.nonce,"signature.nonce"):e.nonce,deadline:h(r?.deadline)?d(r?.deadline,"signature.deadline"):e.deadline,signature:t}}var C=class{constructor(e={}){this.baseUrl=(e.baseUrl??w()).replace(/\/+$/,""),this.domain=e.domain??globalThis.location?.origin??"";let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t}unsignedHash(e,t){return this.post("/login/unsigned-hash",{chain_id:e,address:t,domain:this.domain})}siweToken(e,t){return this.post("/login/token",{address:e,signature:t,domain:this.domain})}async post(e,t){let n;try{n=await this.fetchImpl(`${this.baseUrl}/cross-auth${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}catch(a){throw new o("API_ERROR",`cross-auth network error calling ${e}`,{cause:a instanceof Error?a.message:String(a)})}let i=await n.json().catch(()=>({}));if(!n.ok||i.data==null)throw new o("API_ERROR",`cross-auth ${e} failed`,{code:i.code,message:i.message});return i.data}};async function D(){let r=m(L(32)),e=await W().digest("SHA-256",G(r)),t=m(new Uint8Array(e));return{verifier:r,challenge:t,method:"S256"}}function x(){return m(L(16))}function L(r){let e=globalThis.crypto;if(!e?.getRandomValues)throw new Error("crypto.getRandomValues unavailable");let t=new Uint8Array(r);return e.getRandomValues(t),t}function W(){let r=globalThis.crypto?.subtle;if(!r)throw new Error("crypto.subtle unavailable (needs https/secure context)");return r}function G(r){return new TextEncoder().encode(r)}function m(r){let e="";for(let n of r)e+=String.fromCharCode(n);let t=globalThis.btoa?.(e);if(t===void 0)throw new Error("btoa unavailable");return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}var B=class{constructor(e={}){this.baseUrl=(e.baseUrl??"").replace(/\/+$/,""),this.tokenPath=e.tokenPath??"/api/x/token",this.mePath=e.mePath??"/api/x/me";let t=e.fetchImpl??globalThis.fetch;if(!t)throw new Error("fetch is unavailable; provide options.fetchImpl");this.fetchImpl=t}async exchangeCode(e){let n=await(await this.call(this.tokenPath,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({clientId:e.clientId,redirectUri:e.redirectUri,code:e.code,verifier:e.codeVerifier})})).json().catch(()=>({}));if(!n.access_token)throw new o("API_ERROR","X token exchange: missing access_token",{body:n});return{accessToken:n.access_token,scope:n.scope,expiresIn:n.expires_in,refreshToken:n.refresh_token}}async getHandle(e){let n=await(await this.call(this.mePath,{method:"GET",headers:{Authorization:`Bearer ${e}`}})).json().catch(()=>({})),i=n.data?.username??n.username;if(!i)throw new o("API_ERROR","X /me: missing username",{body:n});return{handle:i}}async call(e,t){let n;try{n=await this.fetchImpl(`${this.baseUrl}${e}`,t)}catch(i){throw new o("API_ERROR",`Network error calling ${e}`,{cause:i instanceof Error?i.message:String(i)})}if(!n.ok)throw new o("API_ERROR",`${e} responded ${n.status}`,{status:n.status});return n}};var _="pop.xauth.verifier",P="pop.xauth.state",J="https://x.com/i/oauth2/authorize",Y="tweet.read users.read offline.access",M=class{constructor(e){this.opts={clientId:e.clientId,redirectUri:e.redirectUri,scope:e.scope??Y,authorizeUrl:e.authorizeUrl??J,port:e.port,storage:e.storage??Z()}}async start(){let e=await D(),t=x();this.opts.storage.set(_,e.verifier),this.opts.storage.set(P,t);let n=new URLSearchParams({response_type:"code",client_id:this.opts.clientId,redirect_uri:this.opts.redirectUri,scope:this.opts.scope,state:t,code_challenge:e.challenge,code_challenge_method:"S256"});return{authorizeUrl:`${this.opts.authorizeUrl}?${n.toString()}`,state:t}}async complete(e){let t=new URL(e),n=t.searchParams.get("code"),i=t.searchParams.get("state");if(!n)throw new o("API_ERROR","X callback: missing authorization code",{error:t.searchParams.get("error")});let a=this.opts.storage.get(P);if(!i||!a||i!==a)throw new o("API_ERROR","X callback: state mismatch (possible CSRF)");let p=this.opts.storage.get(_);if(!p)throw new o("API_ERROR","X callback: missing PKCE verifier (expired session?)");let y=await this.opts.port.exchangeCode({clientId:this.opts.clientId,redirectUri:this.opts.redirectUri,code:n,codeVerifier:p}),{handle:H}=await this.opts.port.getHandle(y.accessToken);return this.opts.storage.remove(_),this.opts.storage.remove(P),{oauth:{provider:"x",accessToken:y.accessToken},handle:H}}};function Z(){let r=globalThis.sessionStorage;if(!r)throw new Error("sessionStorage unavailable; provide options.storage");return{get:e=>r.getItem(e),set:(e,t)=>r.setItem(e,t),remove:e=>r.removeItem(e)}}export{g as a,Q as b,E as c,b as d,R as e,$ as f,F as g,ee as h,A as i,w as j,O as k,C as l,D as m,x as n,B as o,M as p};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as Secret, a as SecretHash, H as Hex, A as Address, I as Id, D as DepositParams, b as DepositResult, O as OAuthProof, W as WithdrawParams, c as WithdrawResult, R as RefundParams, d as RefundResult, e as DropInbox, E as Envelope, L as LeaderboardPage, M as MyLeaderboardEntry, f as HistoryType, g as HistoryStatus, h as HistoryPage, X as XConnection, i as RecipientChangeSignature, j as RecipientSignature, B as BatchClaimParams, k as BatchClaimResult, l as BatchClaimSignature, m as SafeDropApiPort } from './SafeDropApiPort-
|
|
1
|
+
import { S as Secret, a as SecretHash, H as Hex, A as Address, I as Id, D as DepositParams, b as DepositResult, O as OAuthProof, W as WithdrawParams, c as WithdrawResult, R as RefundParams, d as RefundResult, e as DropInbox, E as Envelope, L as LeaderboardPage, M as MyLeaderboardEntry, f as HistoryType, g as HistoryStatus, h as HistoryPage, X as XConnection, i as RecipientChangeSignature, j as RecipientSignature, B as BatchClaimParams, k as BatchClaimResult, l as BatchClaimSignature, m as SafeDropApiPort } from './SafeDropApiPort-B7NfQOsb.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* 순수 계산이 아니라 외부 구현(해시 라이브러리/CSPRNG)이 필요한 암호 연산.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as SafeDropApiPort, A as Address, w as SocialIdentifier, I as Id, H as Hex, O as OAuthProof, e as DropInbox, E as Envelope, L as LeaderboardPage, M as MyLeaderboardEntry, f as HistoryType, g as HistoryStatus, h as HistoryPage, X as XConnection, i as RecipientChangeSignature, j as RecipientSignature, l as BatchClaimSignature } from './SafeDropApiPort-
|
|
1
|
+
import { m as SafeDropApiPort, A as Address, w as SocialIdentifier, I as Id, H as Hex, O as OAuthProof, e as DropInbox, E as Envelope, L as LeaderboardPage, M as MyLeaderboardEntry, f as HistoryType, g as HistoryStatus, h as HistoryPage, X as XConnection, i as RecipientChangeSignature, j as RecipientSignature, l as BatchClaimSignature } from './SafeDropApiPort-B7NfQOsb.js';
|
|
2
2
|
import { X as XAuthPort, a as XTokenResult } from './XAuthPort-BNJePosj.js';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as SafeDropApiPort, D as DepositParams, b as DepositResult, B as BatchClaimParams, k as BatchClaimResult, W as WithdrawParams, c as WithdrawResult, R as RefundParams, d as RefundResult, A as Address, S as Secret } from './SafeDropApiPort-
|
|
2
|
-
export { l as BatchClaimSignature, e as DropInbox, n as DropSender, E as Envelope, o as EnvelopeLayout, H as Hex, p as HistoryEntry, h as HistoryPage, q as HistoryParty, r as HistoryReceiverParty, g as HistoryStatus, f as HistoryType, I as Id, s as LeaderboardEntry, L as LeaderboardPage, t as MappedDepositResult, M as MyLeaderboardEntry, O as OAuthProof, P as PendingDrop, i as RecipientChangeSignature, j as RecipientSignature, u as SafeDropError, v as SafeDropErrorCode, a as SecretHash, w as SocialIdentifier, x as SocialProvider, U as UnmappedDepositResult, X as XConnection } from './SafeDropApiPort-
|
|
3
|
-
import { a as SafeDropChainPort, C as CryptoPort, b as ClaimSignerPort } from './createSafeDrop-
|
|
4
|
-
export { D as DropState, O as OnePopDrop, S as SafeDrop, c as SafeDropConfig, d as SafeDropDeps, e as createSafeDrop } from './createSafeDrop-
|
|
1
|
+
import { m as SafeDropApiPort, D as DepositParams, b as DepositResult, B as BatchClaimParams, k as BatchClaimResult, W as WithdrawParams, c as WithdrawResult, R as RefundParams, d as RefundResult, A as Address, S as Secret } from './SafeDropApiPort-B7NfQOsb.js';
|
|
2
|
+
export { l as BatchClaimSignature, e as DropInbox, n as DropSender, E as Envelope, o as EnvelopeLayout, H as Hex, p as HistoryEntry, h as HistoryPage, q as HistoryParty, r as HistoryReceiverParty, g as HistoryStatus, f as HistoryType, I as Id, s as LeaderboardEntry, L as LeaderboardPage, t as MappedDepositResult, M as MyLeaderboardEntry, O as OAuthProof, P as PendingDrop, i as RecipientChangeSignature, j as RecipientSignature, u as SafeDropError, v as SafeDropErrorCode, a as SecretHash, w as SocialIdentifier, x as SocialProvider, U as UnmappedDepositResult, X as XConnection } from './SafeDropApiPort-B7NfQOsb.js';
|
|
3
|
+
import { a as SafeDropChainPort, C as CryptoPort, b as ClaimSignerPort } from './createSafeDrop-BGoIQ4nK.js';
|
|
4
|
+
export { D as DropState, O as OnePopDrop, S as SafeDrop, c as SafeDropConfig, d as SafeDropDeps, e as createSafeDrop } from './createSafeDrop-BGoIQ4nK.js';
|
|
5
5
|
export { X as XAuthPort, a as XTokenResult } from './XAuthPort-BNJePosj.js';
|
|
6
6
|
|
|
7
7
|
/**
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { S as SafeDrop } from '../createSafeDrop-
|
|
4
|
-
import '../SafeDropApiPort-
|
|
3
|
+
import { S as SafeDrop } from '../createSafeDrop-BGoIQ4nK.js';
|
|
4
|
+
import '../SafeDropApiPort-B7NfQOsb.js';
|
|
5
5
|
|
|
6
6
|
interface SafeDropProviderProps {
|
|
7
7
|
client: SafeDrop;
|
package/package.json
CHANGED
|
@@ -1379,7 +1379,7 @@
|
|
|
1379
1379
|
"example": "https://cdn.example.com/envelopes/classic-coral.png"
|
|
1380
1380
|
},
|
|
1381
1381
|
"layout": {
|
|
1382
|
-
"
|
|
1382
|
+
"$ref": "#/definitions/types.EnvelopeLayout"
|
|
1383
1383
|
},
|
|
1384
1384
|
"name": {
|
|
1385
1385
|
"type": "string",
|
|
@@ -1391,6 +1391,144 @@
|
|
|
1391
1391
|
}
|
|
1392
1392
|
}
|
|
1393
1393
|
},
|
|
1394
|
+
"types.EnvelopeLayout": {
|
|
1395
|
+
"type": "object",
|
|
1396
|
+
"properties": {
|
|
1397
|
+
"canvas": {
|
|
1398
|
+
"$ref": "#/definitions/types.EnvelopeLayoutCanvas"
|
|
1399
|
+
},
|
|
1400
|
+
"layers": {
|
|
1401
|
+
"type": "array",
|
|
1402
|
+
"items": {
|
|
1403
|
+
"$ref": "#/definitions/types.EnvelopeLayoutLayer"
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
},
|
|
1408
|
+
"types.EnvelopeLayoutCanvas": {
|
|
1409
|
+
"type": "object",
|
|
1410
|
+
"properties": {
|
|
1411
|
+
"height": {
|
|
1412
|
+
"type": "integer"
|
|
1413
|
+
},
|
|
1414
|
+
"overscan": {
|
|
1415
|
+
"$ref": "#/definitions/types.EnvelopeLayoutOverscan"
|
|
1416
|
+
},
|
|
1417
|
+
"width": {
|
|
1418
|
+
"type": "integer"
|
|
1419
|
+
}
|
|
1420
|
+
}
|
|
1421
|
+
},
|
|
1422
|
+
"types.EnvelopeLayoutLayer": {
|
|
1423
|
+
"type": "object",
|
|
1424
|
+
"properties": {
|
|
1425
|
+
"overflow": {
|
|
1426
|
+
"$ref": "#/definitions/types.EnvelopeLayoutOverflow"
|
|
1427
|
+
},
|
|
1428
|
+
"position": {
|
|
1429
|
+
"$ref": "#/definitions/types.EnvelopeLayoutPosition"
|
|
1430
|
+
},
|
|
1431
|
+
"prefix": {
|
|
1432
|
+
"type": "string"
|
|
1433
|
+
},
|
|
1434
|
+
"source": {
|
|
1435
|
+
"type": "string",
|
|
1436
|
+
"enum": [
|
|
1437
|
+
"recipientHandle",
|
|
1438
|
+
"sender",
|
|
1439
|
+
"amount",
|
|
1440
|
+
"serial",
|
|
1441
|
+
"date",
|
|
1442
|
+
"message"
|
|
1443
|
+
]
|
|
1444
|
+
},
|
|
1445
|
+
"suffix": {
|
|
1446
|
+
"type": "string"
|
|
1447
|
+
},
|
|
1448
|
+
"typography": {
|
|
1449
|
+
"$ref": "#/definitions/types.EnvelopeLayoutTypography"
|
|
1450
|
+
}
|
|
1451
|
+
}
|
|
1452
|
+
},
|
|
1453
|
+
"types.EnvelopeLayoutOverflow": {
|
|
1454
|
+
"type": "object",
|
|
1455
|
+
"properties": {
|
|
1456
|
+
"strategy": {
|
|
1457
|
+
"type": "string",
|
|
1458
|
+
"enum": [
|
|
1459
|
+
"shrink",
|
|
1460
|
+
"ellipsis"
|
|
1461
|
+
]
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
},
|
|
1465
|
+
"types.EnvelopeLayoutOverscan": {
|
|
1466
|
+
"type": "object",
|
|
1467
|
+
"properties": {
|
|
1468
|
+
"height": {
|
|
1469
|
+
"type": "number"
|
|
1470
|
+
},
|
|
1471
|
+
"left": {
|
|
1472
|
+
"type": "number"
|
|
1473
|
+
},
|
|
1474
|
+
"top": {
|
|
1475
|
+
"type": "number"
|
|
1476
|
+
},
|
|
1477
|
+
"width": {
|
|
1478
|
+
"type": "number"
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
},
|
|
1482
|
+
"types.EnvelopeLayoutPosition": {
|
|
1483
|
+
"type": "object",
|
|
1484
|
+
"properties": {
|
|
1485
|
+
"width": {
|
|
1486
|
+
"type": "number"
|
|
1487
|
+
},
|
|
1488
|
+
"x": {
|
|
1489
|
+
"type": "number"
|
|
1490
|
+
},
|
|
1491
|
+
"y": {
|
|
1492
|
+
"type": "number"
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
},
|
|
1496
|
+
"types.EnvelopeLayoutTypography": {
|
|
1497
|
+
"type": "object",
|
|
1498
|
+
"properties": {
|
|
1499
|
+
"colorToken": {
|
|
1500
|
+
"type": "string",
|
|
1501
|
+
"example": "#F9E7CC"
|
|
1502
|
+
},
|
|
1503
|
+
"fontFamily": {
|
|
1504
|
+
"type": "string",
|
|
1505
|
+
"enum": [
|
|
1506
|
+
"sora",
|
|
1507
|
+
"fredoka",
|
|
1508
|
+
"jetbrains-mono"
|
|
1509
|
+
]
|
|
1510
|
+
},
|
|
1511
|
+
"fontSize": {
|
|
1512
|
+
"type": "integer"
|
|
1513
|
+
},
|
|
1514
|
+
"fontWeight": {
|
|
1515
|
+
"type": "integer"
|
|
1516
|
+
},
|
|
1517
|
+
"lineHeight": {
|
|
1518
|
+
"type": "integer"
|
|
1519
|
+
},
|
|
1520
|
+
"minFontSize": {
|
|
1521
|
+
"type": "integer"
|
|
1522
|
+
},
|
|
1523
|
+
"textAlign": {
|
|
1524
|
+
"type": "string",
|
|
1525
|
+
"enum": [
|
|
1526
|
+
"left",
|
|
1527
|
+
"center"
|
|
1528
|
+
]
|
|
1529
|
+
}
|
|
1530
|
+
}
|
|
1531
|
+
},
|
|
1394
1532
|
"types.EnvelopesResp": {
|
|
1395
1533
|
"type": "object",
|
|
1396
1534
|
"properties": {
|
|
@@ -1498,6 +1636,11 @@
|
|
|
1498
1636
|
"type": "string",
|
|
1499
1637
|
"example": "0x1111111111111111111111111111111111111111"
|
|
1500
1638
|
},
|
|
1639
|
+
"display_handle": {
|
|
1640
|
+
"description": "DisplayHandle is the handle's original casing (display only).\nReceiver side falls back to the lowercase identifier; sender side\nstays empty when the sponsor had no X connection (address-only).",
|
|
1641
|
+
"type": "string",
|
|
1642
|
+
"example": "AmyhRyoon"
|
|
1643
|
+
},
|
|
1501
1644
|
"display_name": {
|
|
1502
1645
|
"type": "string",
|
|
1503
1646
|
"example": "Amy Ryoon"
|
|
@@ -1548,6 +1691,11 @@
|
|
|
1548
1691
|
"type": "string",
|
|
1549
1692
|
"example": "12043000000000000000000"
|
|
1550
1693
|
},
|
|
1694
|
+
"display_handle": {
|
|
1695
|
+
"description": "DisplayHandle is the identifier's original-casing handle (display\nonly); falls back to the lowercase identifier when unknown.",
|
|
1696
|
+
"type": "string",
|
|
1697
|
+
"example": "Theo_13303"
|
|
1698
|
+
},
|
|
1551
1699
|
"identifier": {
|
|
1552
1700
|
"type": "string",
|
|
1553
1701
|
"example": "realdonaldtrump"
|
|
@@ -1581,6 +1729,11 @@
|
|
|
1581
1729
|
"type": "string",
|
|
1582
1730
|
"example": "12043000000000000000000"
|
|
1583
1731
|
},
|
|
1732
|
+
"display_handle": {
|
|
1733
|
+
"description": "DisplayHandle is the identifier's original-casing handle (display\nonly); falls back to the lowercase identifier when unknown.",
|
|
1734
|
+
"type": "string",
|
|
1735
|
+
"example": "Theo_13303"
|
|
1736
|
+
},
|
|
1584
1737
|
"identifier": {
|
|
1585
1738
|
"type": "string",
|
|
1586
1739
|
"example": "theo_13303"
|
|
@@ -1791,6 +1944,11 @@
|
|
|
1791
1944
|
"types.XConnectionResp": {
|
|
1792
1945
|
"type": "object",
|
|
1793
1946
|
"properties": {
|
|
1947
|
+
"display_handle": {
|
|
1948
|
+
"description": "DisplayHandle is the handle's original casing (display only);\nfalls back to the lowercase handle for pre-migration rows.",
|
|
1949
|
+
"type": "string",
|
|
1950
|
+
"example": "Theo_13303"
|
|
1951
|
+
},
|
|
1794
1952
|
"display_name": {
|
|
1795
1953
|
"type": "string",
|
|
1796
1954
|
"example": "Theo"
|