@crossmint/wallets-sdk 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/__tests__/test-utils.cjs +1 -1
- package/dist/api/__tests__/test-utils.js +1 -1
- package/dist/api/client.cjs +1 -1
- package/dist/api/client.js +1 -1
- package/dist/api/gen/types.gen.d.cts +4 -0
- package/dist/api/gen/types.gen.d.ts +4 -0
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.js +1 -1
- package/dist/chains/chains.cjs +1 -1
- package/dist/chains/chains.js +1 -1
- package/dist/{chunk-W7LJS32A.js → chunk-2O6HQK34.js} +1 -1
- package/dist/{chunk-OXYFXOPU.js → chunk-3OY2R7OL.js} +1 -1
- package/dist/chunk-5OYPWGMX.js +1 -0
- package/dist/{chunk-K5TQ4QU3.cjs → chunk-6EUBBDIV.cjs} +1 -1
- package/dist/chunk-6LTDAENQ.js +1 -0
- package/dist/{chunk-Z3FS2L3S.cjs → chunk-7EF275IG.cjs} +1 -1
- package/dist/{chunk-76F327NK.cjs → chunk-7WACXZXY.cjs} +1 -1
- package/dist/{chunk-KB3MJ6GT.js → chunk-A73HLVAF.js} +1 -1
- package/dist/{chunk-DE5B5PD6.js → chunk-ARF3OETV.js} +1 -1
- package/dist/chunk-BA36HJOM.js +1 -0
- package/dist/{chunk-A3CW6G3D.cjs → chunk-BQYPF4FS.cjs} +1 -1
- package/dist/{chunk-KISYLMOO.js → chunk-C73NTGFV.js} +1 -1
- package/dist/{chunk-JUNCHOU4.js → chunk-CT65GLWK.js} +1 -1
- package/dist/{chunk-6EZCCLTK.cjs → chunk-E4EOD7MP.cjs} +1 -1
- package/dist/chunk-G4RVBYWJ.cjs +1 -0
- package/dist/{chunk-PMBSFTVS.cjs → chunk-GETUHEQB.cjs} +1 -1
- package/dist/{chunk-RQYFBGQD.cjs → chunk-IINCFP4K.cjs} +1 -1
- package/dist/{chunk-LKL6NBJS.js → chunk-J2CTZ3KC.js} +1 -1
- package/dist/{chunk-QPDUUKN6.js → chunk-JFGHOWZK.js} +1 -1
- package/dist/{chunk-YIO5XXQ4.js → chunk-JGWGYONV.js} +1 -1
- package/dist/chunk-KB32HFUC.js +3 -0
- package/dist/chunk-LPL33F57.js +1 -0
- package/dist/{chunk-QDXLE57M.js → chunk-MILCZTHF.js} +1 -1
- package/dist/{chunk-WJ3VUMAW.cjs → chunk-MXXBDP4U.cjs} +1 -1
- package/dist/{chunk-DYQSARFM.js → chunk-NFCZBR6G.js} +1 -1
- package/dist/{chunk-2SRITPJI.cjs → chunk-NLO5MHPW.cjs} +1 -1
- package/dist/chunk-OWQZPI3U.cjs +1 -0
- package/dist/{chunk-MG4Y6I7Q.js → chunk-PL6OYURB.js} +1 -1
- package/dist/chunk-PMM7CHUU.js +1 -0
- package/dist/{chunk-RSQAX3JE.cjs → chunk-QJC54AML.cjs} +1 -1
- package/dist/{chunk-2O4UWD4Z.cjs → chunk-QJV6W4U2.cjs} +1 -1
- package/dist/chunk-TK2Z4EWO.cjs +1 -0
- package/dist/{chunk-QO6YNC6N.js → chunk-TM5CSXH4.js} +1 -1
- package/dist/chunk-VJEQU7S4.cjs +3 -0
- package/dist/{chunk-TXJ4LU5K.cjs → chunk-VWHGZO7N.cjs} +1 -1
- package/dist/{chunk-A66TOJYU.cjs → chunk-WGDHVUGK.cjs} +1 -1
- package/dist/{chunk-RLD3OL3C.cjs → chunk-XHVSF356.cjs} +1 -1
- package/dist/{chunk-T6EM7RKO.cjs → chunk-YUVIKZL5.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/index.cjs +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/init.cjs +1 -1
- package/dist/logger/init.js +1 -1
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.js +1 -1
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.js +1 -1
- package/dist/signers/non-custodial/index.cjs +1 -1
- package/dist/signers/non-custodial/index.js +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
- package/dist/signers/solana-external-wallet.cjs +1 -1
- package/dist/signers/solana-external-wallet.js +1 -1
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
- package/dist/utils/device-signers/index.cjs +1 -1
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/utils/errors.cjs +1 -1
- package/dist/utils/errors.d.cts +13 -2
- package/dist/utils/errors.d.ts +13 -2
- package/dist/utils/errors.js +1 -1
- package/dist/utils/signer-validation.cjs +1 -1
- package/dist/utils/signer-validation.js +1 -1
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- package/dist/wallets/evm.js +1 -1
- package/dist/wallets/solana.cjs +1 -1
- package/dist/wallets/solana.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.d.cts +7 -0
- package/dist/wallets/wallet.d.ts +7 -0
- package/dist/wallets/wallet.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2PRGSMTK.js +0 -1
- package/dist/chunk-5FVPLT56.cjs +0 -3
- package/dist/chunk-7V7Y2XDA.js +0 -3
- package/dist/chunk-EXC7TCGL.js +0 -1
- package/dist/chunk-H5ZYPLFV.js +0 -1
- package/dist/chunk-JUUK4TW3.cjs +0 -1
- package/dist/chunk-T3U46LK3.cjs +0 -1
- package/dist/chunk-VGJF6V2I.cjs +0 -1
- package/dist/chunk-XWFHS6TV.js +0 -1
- package/dist/chunk-ZLOXOCRY.js +0 -1
package/dist/chunk-7V7Y2XDA.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as oe}from"./chunk-N4IWDL6M.js";import{a as L}from"./chunk-GOXB2RBF.js";import{b as j,c as _}from"./chunk-VADIEIDS.js";import{a as $}from"./chunk-MG4Y6I7Q.js";import{b as N}from"./chunk-RBSMBO4T.js";import{a as se}from"./chunk-KB3MJ6GT.js";import{a as ae,b as D}from"./chunk-6RX65NOA.js";import{f as ne}from"./chunk-QDXLE57M.js";import{B as ie,d as M,e as U,j as q,n as V,q as H,r as z,s as Y,t as Q,u as G,v as X,w as Z,x as ee,y as re,z as te}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-KISYLMOO.js";import{d as J}from"./chunk-XWFHS6TV.js";import{a as A,b as W,c as E,d as i,e as x,f as h,g as c}from"./chunk-J3R36SGJ.js";import{isValidAddress as le,WithLoggerContext as k}from"@crossmint/common-sdk-base";var S,C,p,w,R,b,I,O,F,T=class{constructor(e,r){x(this,S);x(this,C);x(this,p);x(this,w);x(this,R);x(this,b,!1);x(this,I,!1);x(this,O);x(this,F,null);let{chain:t,address:n,owner:s,options:d,alias:o,recovery:l,signers:g,signer:u}=e;h(this,p,r),this.chain=t,this.address=n,this.owner=s,h(this,C,d),this.alias=o,h(this,w,l),h(this,R,g!=null?g:[]),h(this,S,u),h(this,O,this.initDefaultSigner())}get signer(){return i(this,S)}waitForInit(){return c(this,null,function*(){yield i(this,O)})}initDeviceSigner(){return c(this,null,function*(){var n;let e=(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage;if(e==null)return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(s){a.error("wallet.initDeviceSigner.error",{error:s}),h(this,b,!0);return}if(i(this,b))return;let t=this.buildInternalSignerConfig(r);h(this,S,yield this.assembleFullSigner(t,e)),this.isApprovedSignerStatus(i(this,S).status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:i(this,S).locator(),status:i(this,S).status}),h(this,b,!0),h(this,I,!1))})}initDefaultSigner(){return c(this,null,function*(){if(i(this,S)!=null||(yield this.initDeviceSigner(),i(this,S)!=null||i(this,b)))return;let e=i(this,R).length===0?i(this,w):i(this,R).length===1?i(this,R)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===i(this,w);try{let t=this.buildInternalSignerConfig(e);h(this,S,yield this.assembleFullSigner(t,void 0,{isAdminSigner:r}))}catch(t){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,w).type,signerCount:i(this,R).length,error:t})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,w)}static getInitialSigners(e){return i(e,R)}get apiClient(){return i(this,p)}get options(){return i(this,C)}get recovery(){return i(this,w)}balances(e){return c(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let n=[t,"usdc",...e!=null?e:[]],s=yield i(this,p).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(s,t,e)})}stagingFund(e,r){return c(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let n=g=>{var y,m,P,K,B;let u=(y=g.chains)==null?void 0:y[this.chain],f={};return this.chain==="solana"&&u!=null&&"mintHash"in u?f={mintHash:u.mintHash}:this.chain==="stellar"&&u!=null&&"contractId"in u?f={contractId:u.contractId}:u!=null&&"contractAddress"in u&&(f={contractAddress:u.contractAddress}),A({symbol:(m=g.symbol)!=null?m:"",name:(P=g.name)!=null?P:"",amount:(K=g.amount)!=null?K:"0",decimals:g.decimals,rawAmount:(B=g.rawAmount)!=null?B:"0"},f)},s=e.find(g=>g.symbol===r),d=e.find(g=>g.symbol==="usdc"),o=e.filter(g=>{var u;return g.symbol!==r&&g.symbol!=="usdc"&&(t==null||t.includes((u=g.symbol)!=null?u:""))}),l=g=>{let u={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},f={};return this.chain==="solana"?f={mintHash:void 0}:this.chain==="stellar"?f={contractId:void 0}:f={contractAddress:void 0},A(A({},u),f)};return{nativeToken:s!=null?n(s):l(r),usdc:d!=null?n(d):l("usdc"),tokens:o.map(n)}}nfts(e){return c(this,null,function*(){return yield i(this,p).getNfts(W(A({},e),{chain:this.chain,address:this.address}))})}transactions(){return c(this,null,function*(){let e=yield i(this,p).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return c(this,null,function*(){let r=yield i(this,p).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return c(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return c(this,null,function*(){let s=this.resolveChainForEnvironment(),d=de(e),o=ue(r,s),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new Y(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",A({recipient:d,token:o,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),u;(n==null?void 0:n.signer)==null?u=g.locator():typeof n.signer=="string"?u=n.signer:u=`server:${N(n.signer,this.chain,i(this,p).projectId,i(this,p).environment).derivedAddress}`;let f=A({recipient:d,amount:t,signer:u},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield i(this,p).send(this.walletLocator,o,f);if("message"in y)throw a.error("wallet.send.error",{error:y}),new Q(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let m=yield this.approveTransactionAndWait(y.id);return a.info("wallet.send.success",{transactionId:y.id,hash:m.hash}),m})}approveTransaction(e){return c(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return c(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return c(this,null,function*(){a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${N(e,this.chain,i(this,p).projectId,i(this,p).environment).derivedAddress}`:e;return this.withRecoverySigner(()=>c(this,null,function*(){var u,f;let n=typeof t=="string"?t:L(t),s=yield this.getSignerState(n);if(s.signer!=null){if(this.isApprovedSignerStatus(s.signer.status))return a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null)return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}let d=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:L(t),o=yield i(this,p).registerSigner(this.walletLocator,{signer:d,chain:this.getSignerRegistrationChain()});if("error"in o)throw a.error("wallet.addSigner.error",{error:o}),new q(`Failed to register signer: ${JSON.stringify(o.message)}`);let l=j(o,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in o)||o.transaction==null)throw a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:o.transaction.id}}else{if(!("chains"in o))throw a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((f=(u=o.chains)==null?void 0:u[this.chain])==null?void 0:f.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_(o,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,t){return c(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return A({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),A(A({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),A(A({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return W(A({},e),{status:"success"})})}removeSigner(e,r){return c(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),this.withRecoverySigner(()=>c(this,null,function*(){let n=yield i(this,p).removeSigner(this.walletLocator,t,{chain:this.getSignerRegistrationChain()});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return c(this,null,function*(){a.info("wallet.useSigner.start"),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=this.buildInternalSignerConfig(e),n=L(e);h(this,S,yield this.assembleFullSigner(t,void 0,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return c(this,null,function*(){if(e.type!=="passkey"&&this.isRecoverySigner(e))return h(this,b,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return h(this,b,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return h(this,b,!1),!1;if(this.isRecoverySigner(e))return h(this,b,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){if(e.type==="server"){let{derivedAddress:r}=N(e,this.chain,i(this,p).projectId,i(this,p).environment);return`server:${r}`}return L(e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return c(this,null,function*(){var n;let r=this.signer;if(D(i(this,w)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(i(this,w));h(this,S,$(this.chain,t,(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{h(this,S,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return c(this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return c(this,null,function*(){var t;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((t=r.signer)==null?void 0:t.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return i(this,b)}recover(){return c(this,null,function*(){var s,d;if(a.info("wallet.recover.start"),i(this,I)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=()=>{h(this,b,!1),h(this,I,!0)};if(((s=i(this,S))==null?void 0:s.type)==="device"&&(yield this.checkAndResumeDeviceSigner(i(this,S)))){e();return}if(i(this,S)!=null&&i(this,S).type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),h(this,b,!1);return}let r=(d=i(this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null){if(!i(this,b))return;throw new Error("Device signer key storage is required to recover a device signer")}let t=yield this.findLocalDeviceSigner(r);if(t!=null&&(yield this.checkAndResumeDeviceSigner(t))){h(this,S,t),e();let o=t.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,o)}catch(l){a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let n=yield oe(r,this.address);try{yield this.addSigner(n)}catch(o){if(o instanceof Error&&o.message.toLowerCase().includes("delegated signer")&&o.message.toLowerCase().includes("already")&&o.message.toLowerCase().includes("approved"))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw o instanceof ae||o instanceof Error&&o.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),o):(a.error("wallet.recover.device.error",{error:o}),yield r.deleteKey(this.address),h(this,b,!1),h(this,I,!0),o)}h(this,S,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),i(this,S).type==="device"&&(i(this,S).status="success"),a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return c(this,null,function*(){var t;if(this.isApprovedSignerStatus(e.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(t=r.signer)==null?void 0:t.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return c(this,null,function*(){var s;let t=i(this,S);if(D(i(this,w)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(i(this,w));h(this,S,$(this.chain,n,(s=i(this,C))==null?void 0:s.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(d){throw h(this,S,e),d}finally{i(this,S)!==e&&h(this,S,t)}e.status="success",a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of t){let s=n.locator.replace("device:","");try{if(yield e.hasKey(s)){let o=$(this.chain,{type:"device",locator:n.locator,address:this.address},e);return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),o}}catch(d){a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:d})}}return null})}signers(){return c(this,null,function*(){var s,d;a.info("wallet.signers.start");let e=yield i(this,p).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new U(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new M(`Wallet type ${e.type} not supported`);let r=(d=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?d:[],n=(yield Promise.all(r.map(o=>c(this,null,function*(){try{return(yield this.getSignerState(o.locator)).signer}catch(l){return null}})))).filter(o=>o!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,p).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(i(this,S)==null)throw i(this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):i(this,w).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
|
|
2
|
-
Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):i(this,w).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(i(this,w))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
|
|
3
|
-
Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return i(this,S)}preAuthIfNeeded(){return c(this,null,function*(){yield i(this,O),i(this,F)==null&&h(this,F,this.recover());try{yield i(this,F)}finally{h(this,F,null)}let e=this.requireSigner();e instanceof se&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,w);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=d=>D(d)?d.address:N(d,this.chain,i(this,p).projectId,i(this,p).environment).derivedAddress,n=t(e),s=t(r);if(n!==s)return!1}else if(L(e)!==L(r))return!1;return h(this,w,e),!0}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return c(this,null,function*(){var d;let r=(d=i(this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let s=(yield this.signers()).filter(o=>o.locator.startsWith("device:"));for(let o of s){let l=o.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=o.locator;return}}h(this,b,!0),h(this,I,!1)})}assembleFullSigner(s){return c(this,arguments,function*(e,r=(n=>(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage)(),t){var o;let d=$(this.chain,e,r);if(t!=null&&t.isAdminSigner)d.status="active";else{let l=yield this.getSignerState(d.locator());d.status=(o=l.signer)==null?void 0:o.status}return d})}getSignerState(e){return c(this,null,function*(){let r=null;try{r=yield i(this,p).getSigner(this.walletLocator,e)}catch(n){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=j(r,this.chain);return{response:r,signer:t,pendingOperation:_(r,this.chain)}})}buildInternalSignerConfig(e){var r,t,n,s,d,o;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:i(this,p).crossmint,clientTEEConnection:(r=i(this,C))==null?void 0:r.clientTEEConnection,onAuthRequired:(n=(t=i(this,C))==null?void 0:t.callbacks)==null?void 0:n.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:i(this,p).crossmint,clientTEEConnection:(s=i(this,C))==null?void 0:s.clientTEEConnection,onAuthRequired:(o=(d=i(this,C))==null?void 0:d.callbacks)==null?void 0:o.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return W(A({},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:g}=N(e,this.chain,i(this,p).projectId,i(this,p).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=i(this,C))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!D(e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=ne(this.chain,i(this,p).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return c(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return c(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return c(this,null,function*(){var l,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),n=yield i(this,p).getSignature(this.walletLocator,e);if("error"in n)throw new H(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let u=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,u)}let s=(l=n.approvals)==null?void 0:l.pending;if(s==null||s.length===0)return n;let d=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],o=yield Promise.all(s.map(u=>c(this,null,function*(){let f=d.find(m=>m.locator()===u.signer.locator);if(f==null)throw new q(`Signer ${u.signer.locator} not found in pending approvals`);let y=yield f.signMessage(u.message);return W(A({},y),{signer:f.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,o)})}approveTransactionInternal(e,r){return c(this,null,function*(){var l,g,u,f,y;let t=yield i(this,p).getTransaction(this.walletLocator,e);if("error"in t)throw new G(JSON.stringify(t));yield(u=(g=(l=i(this,C))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:u.call(g);let n=this.requireSigner();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let s=(f=t.approvals)==null?void 0:f.pending;if(s==null||s.length===0)return t;let d=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],n],o=yield Promise.all(s.map(m=>c(this,null,function*(){let P=d.find(ge=>ge.locator()===m.signer.locator);if(P==null)throw new q(`Signer ${m.signer.locator} not found in pending approvals`);let K=P.type==="device",B=t.chainType==="solana"&&"transaction"in t.onChain&&!K?t.onChain.transaction:m.message,ce=yield P.signTransaction(B);return W(A({},ce),{signer:P.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,o)})}executeApproveTransactionWithErrorHandling(e,r){return c(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,p).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new te(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return c(this,null,function*(){let t=yield i(this,p).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}waitForSignature(e){return c(this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,J)),r=yield i(this,p).getSignature(this.walletLocator,e),"error"in r)throw new H(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new V("Signature signing failed");if(!r.outputSignature)throw new H("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(d){return c(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=J}={}){var f,y;a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let o=Date.now(),l;do{if(Date.now()-o>r)throw new X("Transaction confirmation timeout");if(l=yield i(this,p).getTransaction(this.walletLocator,e),l.error)throw new G(JSON.stringify(l));yield this.sleep(s),s=Math.min(s*t,n)}while(l.status==="pending");if(l.status==="failed")throw new Z(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new ee("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,u=(f=l.onChain.txId)!=null?f:g;if(u==null)throw new re("Transaction hash not found on transaction response");return{hash:u,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return c(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};S=new WeakMap,C=new WeakMap,p=new WeakMap,w=new WeakMap,R=new WeakMap,b=new WeakMap,I=new WeakMap,O=new WeakMap,F=new WeakMap,E([k({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"balances",1),E([k({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"stagingFund",1),E([k({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"send",1),E([k({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"approve",1),E([k({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"addSigner",1),E([k({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"removeSigner",1),E([k({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"useSigner",1),E([k({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"recover",1),E([k({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"signers",1);function de(v){if(typeof v=="string"){if(!le(v))throw new ie(`Invalid recipient address: "${v}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return v}if("email"in v)return`email:${v.email}`;if("x"in v)return`x:${v.x}`;if("twitter"in v)return`twitter:${v.twitter}`;if("phone"in v)return`phoneNumber:${v.phone}`;if("userId"in v)return`userId:${v.userId}`;throw new Error("Invalid recipient locator")}function ue(v,e){return le(v)?`${e}:${v}`:`${e}:${v.toLowerCase()}`}export{T as a};
|
package/dist/chunk-EXC7TCGL.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{CrossmintSDKError as t,WalletErrorCode as e}from"@crossmint/common-sdk-base";var o=class extends t{constructor(s,r){super(s,e.API_KEY_INVALID,r)}},c=class extends t{constructor(s,r){super(s,e.ENVIRONMENT_INVALID,r)}},p=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},A=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},I=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},i=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},x=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},g=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},u=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},N=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},E=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},L=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},_=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},T=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},l=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},a=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},d=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},D=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},S=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},O=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},R=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},C=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},G=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},F=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},V=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},W=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},P=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},m=class extends t{constructor(s,r){super(s,e.RECIPIENT_ADDRESS_INVALID,r)}};export{o as a,c as b,p as c,A as d,I as e,i as f,x as g,g as h,u as i,N as j,E as k,L as l,_ as m,T as n,l as o,a as p,d as q,D as r,S as s,O as t,R as u,C as v,G as w,F as x,V as y,W as z,P as A,m as B};
|
package/dist/chunk-H5ZYPLFV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as d}from"./chunk-7V7Y2XDA.js";import{b}from"./chunk-RBSMBO4T.js";import{a as W}from"./chunk-QDXLE57M.js";import{l,p as h,t as w}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-KISYLMOO.js";import{c as g,g as u}from"./chunk-J3R36SGJ.js";import{createPublicClient as x,encodeFunctionData as E,http as N}from"viem";import{isValidEvmAddress as P,WithLoggerContext as f}from"@crossmint/common-sdk-base";var c=class c extends d{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:d.getOptions(e),alias:e.alias,recovery:d.getRecovery(e),signer:e.signer,signers:d.getInitialSigners(e)},d.getApiClient(e))}static from(e){if(!P(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return u(this,null,function*(){var i;r.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return r.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return u(this,null,function*(){var i;r.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw r.error("evmWallet.signMessage.error",{error:t}),new h(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return r.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return u(this,null,function*(){var S;r.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:p,chain:m}=e;if(!t||!a||!p||!m)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:y,version:v,chainId:I,verifyingContract:C,salt:M}=t;if(!y||!v||!I||!C)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let o=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:y,version:v,chainId:Number(I),verifyingContract:C,salt:M},message:T(a),primaryType:i,types:p},signer:n.locator(),chain:m}});if("error"in o)throw r.error("evmWallet.signTypedData.error",{error:o}),new h(JSON.stringify(o));if((S=e.options)!=null&&S.prepareOnly)return r.info("evmWallet.signTypedData.prepared",{signatureId:o.id}),{signature:void 0,signatureId:o.id};let O=yield this.approveSignatureAndWait(o.id);return r.info("evmWallet.signTypedData.success",{signatureId:o.id}),O})}getViemClient(e){var n;return x({transport:(n=e==null?void 0:e.transport)!=null?n:N(),chain:W(this.chain)})}createTransaction(e,n){return u(this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${b(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,p;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(p=(i=e.value)==null?void 0:i.toString())!=null?p:"0",data:E({abi:e.abi,functionName:e.functionName,args:e.args})}}};g([f({logger:r,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),g([f({logger:r,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),g([f({logger:r,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var D=c;function T(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(T):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,n])=>[e,T(n)])):s}export{D as a};
|
package/dist/chunk-JUUK4TW3.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk2O4UWD4Zcjs = require('./chunk-2O4UWD4Z.cjs');var _chunk2SRITPJIcjs = require('./chunk-2SRITPJI.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunk2SRITPJIcjs.c,version:_chunk2SRITPJIcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunk2O4UWD4Zcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunk2O4UWD4Zcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunk2O4UWD4Zcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk2O4UWD4Zcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunk2O4UWD4Zcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunk2O4UWD4Zcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk2O4UWD4Zcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunk2O4UWD4Zcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunk2O4UWD4Zcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
|
package/dist/chunk-T3U46LK3.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.API_KEY_INVALID,r)}},c= exports.b =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.ENVIRONMENT_INVALID,r)}},p= exports.c =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},A= exports.d =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},I= exports.e =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},i= exports.f =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},x= exports.g =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},g= exports.h =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},u= exports.i =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},N= exports.j =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},E= exports.k =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},L= exports.l =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},_= exports.m =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},T= exports.n =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},l= exports.o =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},a= exports.p =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},d= exports.q =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},D= exports.r =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},S= exports.s =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},O= exports.t =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},R= exports.u =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},C= exports.v =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},G= exports.w =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},F= exports.x =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},V= exports.y =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},W= exports.z =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},P= exports.A =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},m= exports.B =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.RECIPIENT_ADDRESS_INVALID,r)}};exports.a = o; exports.b = c; exports.c = p; exports.d = A; exports.e = I; exports.f = i; exports.g = x; exports.h = g; exports.i = u; exports.j = N; exports.k = E; exports.l = L; exports.m = _; exports.n = T; exports.o = l; exports.p = a; exports.q = d; exports.r = D; exports.s = S; exports.t = O; exports.u = R; exports.v = C; exports.w = G; exports.x = F; exports.y = V; exports.z = W; exports.A = P; exports.B = m;
|
package/dist/chunk-VGJF6V2I.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK5TQ4QU3cjs = require('./chunk-K5TQ4QU3.cjs');var _chunk5FVPLT56cjs = require('./chunk-5FVPLT56.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkRSQAX3JEcjs = require('./chunk-RSQAX3JE.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk2O4UWD4Zcjs = require('./chunk-2O4UWD4Z.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var E="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a,n;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkT3U46LK3cjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");a=t,n=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");n=t,a=this.getWalletLocator(n)}let i=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},n),{chain:_chunkRSQAX3JEcjs.f.call(void 0, n.chain,this.apiClient.environment)});_chunk2O4UWD4Zcjs.a.info("walletFactory.getWallet.start");let r=yield this.apiClient.getWallet(a);if("error"in r)throw _chunk2O4UWD4Zcjs.a.warn("walletFactory.getWallet.notFound",{error:r.error}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(r));return _chunk2O4UWD4Zcjs.a.info("walletFactory.getWallet.success",{address:r.address}),yield this.createWalletInstance(r,i)})}createWallet(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,s,g,w,W,A,k,F;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkRSQAX3JEcjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(g=(s=(o=e.options)==null?void 0:o.callbacks)==null?void 0:s.onWalletCreationStart)==null?void 0:g.call(s),_chunk2O4UWD4Zcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunk2O4UWD4Zcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkT3U46LK3cjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let a=((w=e.options)==null?void 0:w.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],n=yield this.registerSigners(a,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),i;if(e.recovery.type==="passkey"&&e.recovery.id==null)i=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:D}=_chunk3VSFHDFHcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);i={type:"server",address:D}}else i=e.recovery;let r=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:i},e.plugins?{plugins:e.plugins}:{}),n!=null?{delegatedSigners:n}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in r)throw _chunk2O4UWD4Zcjs.a.error("walletFactory.createWallet.error",{error:r.error}),new (0, _chunkT3U46LK3cjs.g)(JSON.stringify(r));return _chunk2O4UWD4Zcjs.a.info("walletFactory.createWallet.success",{address:r.address}),yield this.createWalletInstance(r,e)})}createWalletInstance(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,g;this.validateExistingWalletConfig(t,e);let a=e,n=t.config.adminSigner,i=((s=a.recovery)==null?void 0:s.type)==="server"||((g=a.recovery)==null?void 0:g.type)==="external-wallet"?a.recovery:n,r=t.config.delegatedSigners;r!=null&&r.length===1&&(r[0].type==="server"||r[0].type==="external-wallet")&&(r=a.signers);let o=new (0, _chunk5FVPLT56cjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:i,signers:r!=null?r:[]},this.apiClient);return yield o.waitForInit(),o})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(n=t.name)!=null?n:`Crossmint Wallet ${Date.now()}`,a=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var n;let e=(n=t.signers)!=null?n:[];return e.some(i=>i.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunkK5TQ4QU3cjs.a.call(void 0, e.owner)!==_chunkK5TQ4QU3cjs.a.call(void 0, t.owner))throw new (0, _chunkT3U46LK3cjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkT3U46LK3cjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let a=e;if(a.recovery!=null||a.signers!=null){let n=t.config,i=n==null?void 0:n.adminSigner;if(a.recovery!=null&&i!=null){if(a.recovery.type!==i.type)throw new (0, _chunkT3U46LK3cjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkK5TQ4QU3cjs.b.call(void 0, a.recovery,i)}let r=a.signers;r!=null&&this.validateSigners(t,r,e.chain)}}validateSigners(t,e,a){let n=t.config,i=n==null?void 0:n.delegatedSigners;if(e.length!==0){if(i==null||i.length===0)throw new (0, _chunkT3U46LK3cjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${E}`);for(let r of e){let o=i.find(s=>{if(this.isMatchingPasskeySigner(r,s,n)||s.type==="device"&&r.type==="device")return!0;if(r.type==="server"){let{derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, r,a,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${g}`}return s.locator===_chunkNX256LAHcjs.a.call(void 0, r)});if(o==null){let s=i.map(g=>g.locator).join(", ");throw new (0, _chunkT3U46LK3cjs.g)(`Signer '${r.type}' does not exist in wallet "${t.address}". Available signers: ${s}. ${E}`)}_chunkK5TQ4QU3cjs.b.call(void 0, r,o)}}}isMatchingPasskeySigner(t,e,a){var i,r;let n=((r=(i=a.delegatedSigners)==null?void 0:i.filter(o=>o.type==="passkey").length)!=null?r:0)+(a.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&n===1)return e.type==="passkey";if(t.id==null&&n>1)throw new (0, _chunkT3U46LK3cjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;return yield Promise.all((n=t==null?void 0:t.map(i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.type==="passkey")return i.id==null?{signer:yield this.createPasskeySigner(i)}:{signer:i};if(i.type==="device"){if(i.publicKey!=null)return{signer:{type:"device",publicKey:i.publicKey,name:i.name}};if(i.locator!=null)return{signer:i.locator};if(a==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");let r=yield _chunkYHV3672Rcjs.a.call(void 0, a);return{signer:{type:"device",publicKey:r.publicKey,name:r.name}}}if(i.type==="server"&&e!=null){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, i,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${r}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, i)}})))!=null?n:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk2O4UWD4Zcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let n=e[1];return{walletLocator:e[0],chain:n==null?void 0:n.chain}}let a=e[0];return{chain:a==null?void 0:a.chain}}})],h.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk2O4UWD4Zcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);exports.a = h;
|
package/dist/chunk-XWFHS6TV.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var s="@crossmint/wallets-sdk",t="1.1.1";var c="WALLETS_SDK",r=t,a=s,d=500;export{c as a,r as b,a as c,d};
|
package/dist/chunk-ZLOXOCRY.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-KISYLMOO.js";import{b as p,c}from"./chunk-XWFHS6TV.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:c,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return t(this,null,function*(){a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===d.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return t(this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===g.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{h as a};
|