superstack-wallet-sdk 0.5.6 → 0.5.8

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.
@@ -1,2 +1,2 @@
1
- import t from"axios";import{Network as e,WalletType as a,isVersionedTransaction as r}from"./types.js";import{Storage as i}from"./storage.js";import{Connection as s,PublicKey as n,LAMPORTS_PER_SOL as o}from"@solana/web3.js";import l from"bs58";import{PhantomWalletAdapter as d}from"./adapters/phantom.js";import{v4 as h}from"uuid";import{getOnrampBuyUrl as c}from"./utils/coinbaseUtils.js";import{Buffer as u}from"../_virtual/_polyfill-node.buffer.js";import"./polyfills.js";import{createPublicClient as w}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/clients/createPublicClient.js";import{http as p}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/clients/transports/http.js";import{serializeSignature as m}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/utils/signature/serializeSignature.js";import{formatEther as f}from"../node_modules/.pnpm/ethers@6.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/lib.esm/utils/units.js";class g{constructor(a){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.backupWalletType="embedded_backup",this.ethereumNetwork=null,this.defaultNetwork=e.Solana,this.api=t.create({baseURL:a.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=t.create({baseURL:a.middleAccountBaseURL||"https://yeezy-payment-service-sit-a0dchfccbufeh5bx.z03.azurefd.net",headers:{"Content-Type":"application/json"}}),this.solanaCluster=a.solanaCluster,this.solanaConnection=new s(a.solanaCluster.rpcUrl),a.ethereumNetwork&&(this.ethereumNetwork={...a.ethereumNetwork,chainId:Number(a.ethereumNetwork.chainId)},this.ethereumProvider=w({transport:p(a.ethereumNetwork.rpcUrl)})),this.defaultNetwork=a.defaultNetwork||e.Solana}setWallet(t){this.walletInfo=t}setWalletType(t){this.walletType=t,i.saveWalletType(t)}setBackupWalletType(t){this.backupWalletType=t,i.saveBackupWalletType(t),console.log(33)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}getBackupWalletType(){return this.backupWalletType}get wallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===this.defaultNetwork))||null}get address(){var t;return(null===(t=this.wallet)||void 0===t?void 0:t.address)||null}get network(){var t;return(null===(t=this.wallet)||void 0===t?void 0:t.network)||null}get ethereumWallet(){var t,a;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.address===i.getSwitchedAccountAddress()))||(null===(a=this.walletInfo)||void 0===a?void 0:a.wallets.find(t=>t.network===e.Ethereum&&"Main"===t.wallet_set))||null}get ethereumAddress(){var t;return(null===(t=this.ethereumWallet)||void 0===t?void 0:t.address)||null}get solanaWallet(){var t,a,r,s;const n=null===(a=null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.address===i.getSwitchedAccountAddress()))||void 0===a?void 0:a.wallet_set;return n?(null===(r=this.walletInfo)||void 0===r?void 0:r.wallets.find(t=>t.network===e.Solana&&t.wallet_set===n))||null:(null===(s=this.walletInfo)||void 0===s?void 0:s.wallets.find(t=>t.network===e.Solana&&"Main"===t.wallet_set))||null}get forwardSolanaWallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===e.Solana&&"Forward-0"===t.wallet_set))||null}get forwardSolanaAddress(){var t;return(null===(t=this.forwardSolanaWallet)||void 0===t?void 0:t.address)||null}get forwardEthereumWallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===e.Ethereum&&"Forward-0"===t.wallet_set))||null}get forwardEthereumAddress(){var t;return(null===(t=this.forwardEthereumWallet)||void 0===t?void 0:t.address)||null}get solanaAddress(){var t;return(null===(t=this.solanaWallet)||void 0===t?void 0:t.address)||null}get id(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.id)||null}get social_links(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.social_links)||null}async reconnect(t){try{if(i.getWalletType()==="phantom"+(t?"_backup":"")){return await this.connectPhantom()}if(!t){const t=await this.getSession();return this.setWallet(t),t}const e=i.getBackupWalletInfo();return this.setWallet(e),e}catch(t){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new d),await this.phantomAdapter.connect(),!this.phantomAdapter.publicKey)throw new Error("Failed to connect to Phantom wallet");const t=this.phantomAdapter.publicKey.toString(),r={id:h(),is_exported:!1,address:t,network:e.Solana,type:a.Phantom,wallets:[{id:t,address:t,network:e.Solana,wallet_type:a.Phantom,wallet_set:"Main"}],social_links:[],social_infos:[],account_info:{name:null}};return this.setWallet(r),this.setWalletType("phantom"),r}catch(t){throw console.error("Phantom connect error:",t),new Error(t instanceof Error?t.message:"Failed to connect to Phantom wallet")}}async updateAccountName(t){if(!this.walletInfo)throw new Error("No wallet info");const e=await this.api.post("/account/update",{name:t},{withCredentials:!0});return this.walletInfo.account_info.name=t,e.data}async signSolanaTransaction(t){try{if(!this.walletInfo)throw new Error("No wallet info");if(!this.solanaConnection)throw new Error("No rpc connection");const{blockhash:a}=await this.solanaConnection.getLatestBlockhash();if(r(t)?t.message.recentBlockhash=a:t.recentBlockhash=a,this.phantomAdapter&&this.phantomAdapter.publicKey)return await this.phantomAdapter.signTransaction(t);const i=this.solanaWallet;if(!i)throw new Error("No solana wallet available");const s={user_id:this.walletInfo.id,address:i.address,network:e.Solana,tx:{Solana:l.encode(r(t)?t.message.serialize():t.serializeMessage())}},o=await this.api.post("/sign2",s,{withCredentials:!0}),{signature:d}=o.data;return t.addSignature(new n(i.address),u.from(l.decode(d))),t}catch(t){throw new Error(t instanceof Error?t.message:"Failed to sign transaction")}}async signEthereumEip712(t){if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const a={user_id:this.walletInfo.id,address:this.ethereumAddress,network:e.Ethereum,tx:{EthereumEip712:t}},r=await this.api.post("/sign2",a,{withCredentials:!0}),{signature:i}=r.data;return i}async sendSolanaTransaction(t){if(!this.solanaConnection)throw new Error("No rpc connection");try{return await this.solanaConnection.sendRawTransaction(t,{maxRetries:3,skipPreflight:!1})}catch(t){throw t}}async sendEthereumTransaction(t){if(!this.ethereumProvider)throw new Error("No Ethereum provider");try{return await this.ethereumProvider.sendRawTransaction({serializedTransaction:t})}catch(t){throw t}}async sendEmailVerificationCode(t){await this.api.post("/send_verification",{email:t})}async sendPhoneVerificationCode(t){t.startsWith("+")||(t=`+${t}`),await this.api.post("/send_verification",{phone:t,type:"phone"})}async verifyEmailVerificationCode({email:t,code:e}){const a={type:"Email",data:{network:this.defaultNetwork,email:t,code:e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async verifyPhoneVerificationCode({phone:t,code:e}){const a={type:"Phone",data:{network:this.defaultNetwork,phone:t,code:e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async twitterLogin(t){const e={type:"TwitterOAuth",data:{network:this.defaultNetwork,...t}},a=(await this.api.post("/login",e,{withCredentials:!0})).data;return this.setWallet(a),this.setWalletType("embedded"),a}async googleLogin(t){const e={type:"GoogleOAuth",data:{network:this.defaultNetwork,...t}},a=(await this.api.post("/login",e,{withCredentials:!0})).data;return this.setWallet(a),this.setWalletType("embedded"),a}async oauthLogin(t,e){const a={type:t,data:{network:e.network||this.defaultNetwork,...e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),e.isBackup?this.setBackupWalletType("embedded_backup"):this.setWalletType("embedded"),r}async loginWithChallenge(t,e){const a={type:t,data:{network:e.network||this.defaultNetwork,...e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),console.log(11),e.isBackup?(console.log(22),this.setBackupWalletType("embedded_backup")):this.setWalletType("embedded"),r}async oauthInit(t){return(await this.api.post("/oauth/init",t)).data}async getSignChallenge(t){return(await this.api.get(`/challenge?method=${t.method}&id=${t.id}`)).data}async getSession(){const t=(await this.api.get("/session",{withCredentials:!0})).data,{access_token:e,...a}=t;return e&&i.saveAccessToken(e),t}async logout(t){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),t?i.clearBackup():i.clear()}async getOAuth2ClientId(t){return(await this.api.get(`/oauth_id/${t}`)).data.client_id}setSelectedWallet(t){this.selectedWalletId=t}getSelectedWallet(){return this.selectedWalletId}async getSolanaBalance(){if(!this.solanaConnection||!this.solanaAddress)throw new Error("Solana connection not available");return(await this.solanaConnection.getBalance(new n(this.solanaAddress))/o).toString()}async getEthereumBalance(){if(!this.ethereumProvider||!this.ethereumAddress)throw new Error("Ethereum provider not available");const t=await this.ethereumProvider.getBalance({address:this.ethereumAddress});return f(t)}async fetchCoinbaseToken(t,e="solana"){return(await this.api.post("/ramp/coinbase",{addresses:[{address:t,blockchains:[e]}],assets:["solana"===e?"SOL":"ETH"]})).data.token}viemSignerAdapter(){return{signTypedData:async t=>{if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const a={user_id:this.walletInfo.id,address:this.ethereumAddress,network:e.Ethereum,tx:{EthereumEip712:t}},r=await this.api.post("/sign2",a,{withCredentials:!0}),{signature:i}=r.data,s=l.decode(i),n=s[64];return m({r:`0x${u.from(s.slice(0,32)).toString("hex")}`,s:`0x${u.from(s.slice(32,64)).toString("hex")}`,v:BigInt(n+27)})}}}async createMiddleAccount(t){try{return(await this.middleAccountApi.post("/create",t)).data}catch(t){throw new Error(t instanceof Error?t.message:"Failed to create middle account")}}async getCoinbaseOnrampUrlForMiddleAccount(t){try{const a={sessionToken:await this.fetchCoinbaseToken(t.middleAccountAddress,t.network===e.Solana?"solana":"ethereum"),presetCryptoAmount:Number(t.amount),redirectUrl:t.redirectUrl||window.location.href};return c(a)}catch(t){throw new Error(t instanceof Error?t.message:"Failed to get Coinbase onramp URL")}}async getOrderState(t){try{return(await this.middleAccountApi.get(`/order/${t}`)).data}catch(t){throw new Error(t instanceof Error?t.message:"Failed to get order status")}}async transfer(t){var e,a;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,from:t.from,to:t.to,amount:t.amount,decimals:t.decimals,token:t.token,network:t.network,chain_id:t.chain_id};try{return(await this.api.post("/transfer",r,{withCredentials:!0})).data}catch(t){if(null===(a=null===(e=t.response)||void 0===e?void 0:e.data)||void 0===a?void 0:a.error)throw new Error(t.response.data.error);throw new Error(t instanceof Error?t.message:"Transfer failed")}}async buildTransaction(t){var e,a;try{return(await this.api.post("/build_transaction",t,{withCredentials:!0})).data}catch(t){if(null===(a=null===(e=t.response)||void 0===e?void 0:e.data)||void 0===a?void 0:a.error)throw new Error(t.response.data.error);throw new Error(t instanceof Error?t.message:"Failed to build transaction")}}async getCrossMarginGeneralInfo(){return(await this.api.get("/crossmargin/general_info")).data}async getCrossMarginBorrowQuote(t){return(await this.api.post("/crossmargin/borrow/quote",t,{withCredentials:!0})).data}async borrowCrossMargin(t){return(await this.api.post("/crossmargin/borrow",t,{withCredentials:!0})).data}async getCrossMarginRepayQuote(t){return(await this.api.post("/crossmargin/repay/quote",t,{withCredentials:!0})).data}async repayCrossMargin(t){return(await this.api.post("/crossmargin/repay",t,{withCredentials:!0})).data}async adjustCrossMarginMargin(t){return(await this.api.post("/crossmargin/margin",t,{withCredentials:!0})).data}async getCrossMarginOpenPositions(){return(await this.api.get("/crossmargin/positions",{withCredentials:!0})).data}async getCrossMarginHistory(){return(await this.api.get("/crossmargin/history",{withCredentials:!0})).data}}export{g as WalletClient};
1
+ import t from"axios";import{Network as e,WalletType as a,isVersionedTransaction as r}from"./types.js";import{Storage as n}from"./storage.js";import{Connection as o,PublicKey as i,LAMPORTS_PER_SOL as s}from"@solana/web3.js";import l from"bs58";import{PhantomWalletAdapter as d}from"./adapters/phantom.js";import{v4 as h}from"uuid";import{getOnrampBuyUrl as c}from"./utils/coinbaseUtils.js";import{Buffer as u}from"../_virtual/_polyfill-node.buffer.js";import"./polyfills.js";import{createPublicClient as w}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/clients/createPublicClient.js";import{http as p}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/clients/transports/http.js";import{serializeSignature as m}from"../node_modules/.pnpm/viem@2.37.8_bufferutil@4.0.9_typescript@5.9.2_utf-8-validate@5.0.10/node_modules/viem/_esm/utils/signature/serializeSignature.js";import{formatEther as f}from"../node_modules/.pnpm/ethers@6.15.0_bufferutil@4.0.9_utf-8-validate@5.0.10/node_modules/ethers/lib.esm/utils/units.js";class v{constructor(a){this.selectedWalletId=null,this.solanaConnection=null,this.ethereumProvider=null,this.walletInfo=null,this.phantomAdapter=null,this.walletType="embedded",this.backupWalletType="embedded_backup",this.ethereumNetwork=null,this.defaultNetwork=e.Solana,this.api=t.create({baseURL:a.baseURL,headers:{"Content-Type":"application/json"}}),this.middleAccountApi=t.create({baseURL:a.middleAccountBaseURL||"https://yeezy-payment-service-sit-a0dchfccbufeh5bx.z03.azurefd.net",headers:{"Content-Type":"application/json"}}),this.solanaCluster=a.solanaCluster,this.solanaConnection=new o(a.solanaCluster.rpcUrl),a.ethereumNetwork&&(this.ethereumNetwork={...a.ethereumNetwork,chainId:Number(a.ethereumNetwork.chainId)},this.ethereumProvider=w({transport:p(a.ethereumNetwork.rpcUrl)})),this.defaultNetwork=a.defaultNetwork||e.Solana}setWallet(t){this.walletInfo=t}setWalletType(t){this.walletType=t,n.saveWalletType(t)}setBackupWalletType(t){this.backupWalletType=t,n.saveBackupWalletType(t),console.log(33)}getWallet(){return this.walletInfo}getPhantomAdapter(){return this.phantomAdapter}getWalletType(){return this.walletType}getBackupWalletType(){return this.backupWalletType}get wallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===this.defaultNetwork))||null}get address(){var t;return(null===(t=this.wallet)||void 0===t?void 0:t.address)||null}get network(){var t;return(null===(t=this.wallet)||void 0===t?void 0:t.network)||null}get ethereumWallet(){var t,a;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.address===n.getSwitchedAccountAddress()))||(null===(a=this.walletInfo)||void 0===a?void 0:a.wallets.find(t=>t.network===e.Ethereum&&"Main"===t.wallet_set))||null}get ethereumAddress(){var t;return(null===(t=this.ethereumWallet)||void 0===t?void 0:t.address)||null}get solanaWallet(){var t,a,r,o;const i=null===(a=null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.address===n.getSwitchedAccountAddress()))||void 0===a?void 0:a.wallet_set;return i?(null===(r=this.walletInfo)||void 0===r?void 0:r.wallets.find(t=>t.network===e.Solana&&t.wallet_set===i))||null:(null===(o=this.walletInfo)||void 0===o?void 0:o.wallets.find(t=>t.network===e.Solana&&"Main"===t.wallet_set))||null}get forwardSolanaWallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===e.Solana&&"Forward-0"===t.wallet_set))||null}get forwardSolanaAddress(){var t;return(null===(t=this.forwardSolanaWallet)||void 0===t?void 0:t.address)||null}get forwardEthereumWallet(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.wallets.find(t=>t.network===e.Ethereum&&"Forward-0"===t.wallet_set))||null}get forwardEthereumAddress(){var t;return(null===(t=this.forwardEthereumWallet)||void 0===t?void 0:t.address)||null}get solanaAddress(){var t;return(null===(t=this.solanaWallet)||void 0===t?void 0:t.address)||null}get id(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.id)||null}get social_links(){var t;return(null===(t=this.walletInfo)||void 0===t?void 0:t.social_links)||null}async reconnect(t){try{if(n.getWalletType()==="phantom"+(t?"_backup":"")){return await this.connectPhantom()}if(!t){const t=await this.getSession();return this.setWallet(t),t}const e=n.getBackupWalletInfo();return this.setWallet(e),e}catch(t){return null}}async connectPhantom(){try{if(this.phantomAdapter||(this.phantomAdapter=new d),await this.phantomAdapter.connect(),!this.phantomAdapter.publicKey)throw new Error("Failed to connect to Phantom wallet");const t=this.phantomAdapter.publicKey.toString(),r={id:h(),wallets:[{id:t,address:t,network:e.Solana,wallet_type:a.Phantom,wallet_set:"Main",account_index:0,is_enabled:!0}],social_links:[],social_infos:[],account_info:{name:null,sub_accounts:[]},created_at:Date.now(),is_exported:!1};return this.setWallet(r),this.setWalletType("phantom"),r}catch(t){throw console.error("Phantom connect error:",t),new Error(t instanceof Error?t.message:"Failed to connect to Phantom wallet")}}async updateAccountName(t,e){if(!this.walletInfo)throw new Error("No wallet info");const a={name:t};void 0!==e&&(a.account_index=e);const r=(await this.api.post("/account/update",a,{withCredentials:!0})).data;return this.setWallet(r),r}async manageMultiAccount(t){if(!this.walletInfo)throw new Error("No wallet info");const e=(await this.api.post("/account/multi",t,{withCredentials:!0})).data;return this.setWallet(e),e}async createSubAccount(t){return this.manageMultiAccount({type:"Create",data:{name:null!=t?t:null}})}async enableSubAccount(t){return this.manageMultiAccount({type:"Enable",data:{index:t}})}async disableSubAccount(t){return this.manageMultiAccount({type:"Disable",data:{index:t}})}async signSolanaTransaction(t){try{if(!this.walletInfo)throw new Error("No wallet info");if(!this.solanaConnection)throw new Error("No rpc connection");const{blockhash:a}=await this.solanaConnection.getLatestBlockhash();if(r(t)?t.message.recentBlockhash=a:t.recentBlockhash=a,this.phantomAdapter&&this.phantomAdapter.publicKey)return await this.phantomAdapter.signTransaction(t);const n=this.solanaWallet;if(!n)throw new Error("No solana wallet available");const o={user_id:this.walletInfo.id,address:n.address,network:e.Solana,tx:{Solana:l.encode(r(t)?t.message.serialize():t.serializeMessage())}},s=await this.api.post("/v3/sign",o,{withCredentials:!0}),{signature:d}=s.data;return t.addSignature(new i(n.address),u.from(l.decode(d))),t}catch(t){throw new Error(t instanceof Error?t.message:"Failed to sign transaction")}}async signEthereumEip712(t){if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const a={user_id:this.walletInfo.id,address:this.ethereumAddress,network:e.Ethereum,tx:{EthereumEip712:t}},r=await this.api.post("/v2/sign",a,{withCredentials:!0}),{signature:n}=r.data;return n}async sendSolanaTransaction(t){if(!this.solanaConnection)throw new Error("No rpc connection");try{return await this.solanaConnection.sendRawTransaction(t,{maxRetries:3,skipPreflight:!1})}catch(t){throw t}}async sendEthereumTransaction(t){if(!this.ethereumProvider)throw new Error("No Ethereum provider");try{return await this.ethereumProvider.sendRawTransaction({serializedTransaction:t})}catch(t){throw t}}async sendEmailVerificationCode(t){await this.api.post("/send_verification",{email:t})}async sendPhoneVerificationCode(t){t.startsWith("+")||(t=`+${t}`),await this.api.post("/send_verification",{phone:t,type:"phone"})}async verifyEmailVerificationCode({email:t,code:e}){const a={type:"Email",data:{network:this.defaultNetwork,email:t,code:e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async verifyPhoneVerificationCode({phone:t,code:e}){const a={type:"Phone",data:{network:this.defaultNetwork,phone:t,code:e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),this.setWalletType("embedded"),r}async twitterLogin(t){const e={type:"TwitterOAuth",data:{network:this.defaultNetwork,...t}},a=(await this.api.post("/login",e,{withCredentials:!0})).data;return this.setWallet(a),this.setWalletType("embedded"),a}async googleLogin(t){const e={type:"GoogleOAuth",data:{network:this.defaultNetwork,...t}},a=(await this.api.post("/login",e,{withCredentials:!0})).data;return this.setWallet(a),this.setWalletType("embedded"),a}async oauthLogin(t,e){const a={type:t,data:{network:e.network||this.defaultNetwork,...e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),e.isBackup?this.setBackupWalletType("embedded_backup"):this.setWalletType("embedded"),r}async loginWithChallenge(t,e){const a={type:t,data:{network:e.network||this.defaultNetwork,...e}},r=(await this.api.post("/login",a,{withCredentials:!0})).data;return this.setWallet(r),console.log(11),e.isBackup?(console.log(22),this.setBackupWalletType("embedded_backup")):this.setWalletType("embedded"),r}async oauthInit(t){return(await this.api.post("/oauth/init",t)).data}async getSignChallenge(t){return(await this.api.get(`/challenge?method=${t.method}&id=${t.id}`)).data}async getSession(){const t=(await this.api.get("/session",{withCredentials:!0})).data,{access_token:e,...a}=t;return e&&n.saveAccessToken(e),t}async logout(t){this.phantomAdapter?(this.phantomAdapter.disconnect(),this.phantomAdapter=null):await this.api.post("/logout",{},{withCredentials:!0}),this.setWallet(null),t?n.clearBackup():n.clear()}async getOAuth2ClientId(t){return(await this.api.get(`/oauth_id/${t}`)).data.client_id}setSelectedWallet(t){this.selectedWalletId=t}getSelectedWallet(){return this.selectedWalletId}async getSolanaBalance(){if(!this.solanaConnection||!this.solanaAddress)throw new Error("Solana connection not available");return(await this.solanaConnection.getBalance(new i(this.solanaAddress))/s).toString()}async getEthereumBalance(){if(!this.ethereumProvider||!this.ethereumAddress)throw new Error("Ethereum provider not available");const t=await this.ethereumProvider.getBalance({address:this.ethereumAddress});return f(t)}async fetchCoinbaseToken(t,e="solana"){return(await this.api.post("/ramp/coinbase",{addresses:[{address:t,blockchains:[e]}],assets:["solana"===e?"SOL":"ETH"]})).data.token}viemSignerAdapter(){return{signTypedData:async t=>{if(!this.ethereumNetwork)throw new Error("No Ethereum network");if(!this.ethereumProvider)throw new Error("No Ethereum provider");if(!this.walletInfo)throw new Error("No wallet info");if(!this.ethereumAddress)throw new Error("No Ethereum address");const a={user_id:this.walletInfo.id,address:this.ethereumAddress,network:e.Ethereum,tx:{EthereumEip712:t}},r=await this.api.post("/v2/sign",a,{withCredentials:!0}),{signature:n}=r.data,o=l.decode(n),i=o[64];return m({r:`0x${u.from(o.slice(0,32)).toString("hex")}`,s:`0x${u.from(o.slice(32,64)).toString("hex")}`,v:BigInt(i+27)})}}}async createMiddleAccount(t){try{return(await this.middleAccountApi.post("/create",t)).data}catch(t){throw new Error(t instanceof Error?t.message:"Failed to create middle account")}}async getCoinbaseOnrampUrlForMiddleAccount(t){try{const a={sessionToken:await this.fetchCoinbaseToken(t.middleAccountAddress,t.network===e.Solana?"solana":"ethereum"),presetCryptoAmount:Number(t.amount),redirectUrl:t.redirectUrl||window.location.href};return c(a)}catch(t){throw new Error(t instanceof Error?t.message:"Failed to get Coinbase onramp URL")}}async getOrderState(t){try{return(await this.middleAccountApi.get(`/order/${t}`)).data}catch(t){throw new Error(t instanceof Error?t.message:"Failed to get order status")}}async transfer(t){var e,a;if(!this.walletInfo)throw new Error("No wallet info available");const r={user_id:this.walletInfo.id,from:t.from,to:t.to,amount:t.amount,decimals:t.decimals,token:t.token,network:t.network,chain_id:t.chain_id};try{return(await this.api.post("/transfer",r,{withCredentials:!0})).data}catch(t){if(null===(a=null===(e=t.response)||void 0===e?void 0:e.data)||void 0===a?void 0:a.error)throw new Error(t.response.data.error);throw new Error(t instanceof Error?t.message:"Transfer failed")}}async buildTransaction(t,e){var a,r;if(!this.walletInfo)throw new Error("No wallet info available");try{const a={};e&&(a["Wallet-Address"]=e);return(await this.api.post("/v3/build_transaction",t,{withCredentials:!0,headers:a})).data}catch(t){if(null===(r=null===(a=t.response)||void 0===a?void 0:a.data)||void 0===r?void 0:r.error)throw new Error(t.response.data.error);throw new Error(t instanceof Error?t.message:"Failed to build transaction")}}}export{v as WalletClient};
2
2
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":[null],"names":["WalletClient","constructor","config","this","selectedWalletId","solanaConnection","ethereumProvider","walletInfo","phantomAdapter","walletType","backupWalletType","ethereumNetwork","defaultNetwork","Network","Solana","api","axios","create","baseURL","headers","middleAccountApi","middleAccountBaseURL","solanaCluster","Connection","rpcUrl","chainId","Number","createPublicClient","transport","http","setWallet","wallet","setWalletType","type","Storage","saveWalletType","setBackupWalletType","saveBackupWalletType","console","log","getWallet","getPhantomAdapter","getWalletType","getBackupWalletType","_a","wallets","find","network","address","ethereumWallet","getSwitchedAccountAddress","_b","Ethereum","wallet_set","ethereumAddress","solanaWallet","_c","_d","forwardSolanaWallet","forwardSolanaAddress","forwardEthereumWallet","forwardEthereumAddress","solanaAddress","id","social_links","reconnect","isBackup","connectPhantom","getSession","getBackupWalletInfo","error","PhantomWalletAdapter","connect","publicKey","Error","toString","uuidv4","is_exported","WalletType","Phantom","wallet_type","social_infos","account_info","name","message","updateAccountName","response","post","withCredentials","data","signSolanaTransaction","transaction","blockhash","getLatestBlockhash","isVersionedTransaction","recentBlockhash","signTransaction","signRequest","user_id","tx","bs58","encode","serialize","serializeMessage","signature","addSignature","PublicKey","Buffer","from","decode","signEthereumEip712","params","EthereumEip712","sendSolanaTransaction","sendRawTransaction","maxRetries","skipPreflight","sendEthereumTransaction","signedTransaction","serializedTransaction","sendEmailVerificationCode","email","sendPhoneVerificationCode","phone","startsWith","verifyEmailVerificationCode","code","verifyPhoneVerificationCode","twitterLogin","googleLogin","oauthLogin","loginWithChallenge","oauthInit","getSignChallenge","get","method","access_token","rest","saveAccessToken","logout","disconnect","clearBackup","clear","getOAuth2ClientId","provider","client_id","setSelectedWallet","walletId","getSelectedWallet","getSolanaBalance","getBalance","LAMPORTS_PER_SOL","getEthereumBalance","balance","ethers.formatEther","fetchCoinbaseToken","blockchain","addresses","blockchains","assets","token","viemSignerAdapter","signTypedData","async","signatureBytes","recId","signatureToHex","r","slice","s","v","BigInt","createMiddleAccount","request","getCoinbaseOnrampUrlForMiddleAccount","sessionToken","middleAccountAddress","presetCryptoAmount","amount","redirectUrl","window","location","href","getOnrampBuyUrl","getOrderState","orderId","transfer","transferRequest","to","decimals","chain_id","buildTransaction","getCrossMarginGeneralInfo","getCrossMarginBorrowQuote","payload","borrowCrossMargin","getCrossMarginRepayQuote","repayCrossMargin","adjustCrossMarginMargin","getCrossMarginOpenPositions","getCrossMarginHistory"],"mappings":"uoCA4EaA,EAeT,WAAAC,CAAYC,GAZJC,KAAAC,iBAAkC,KAClCD,KAAAE,iBAAsC,KAEtCF,KAAAG,iBAAwC,KACxCH,KAAAI,WAAgC,KAChCJ,KAAAK,eAA8C,KAC9CL,KAAAM,WAAqC,WACrCN,KAAAO,iBAAyD,kBAEzDP,KAAAQ,gBAA0C,KAC1CR,KAAAS,eAA0BC,EAAQC,OAGtCX,KAAKY,IAAMC,EAAMC,OAAO,CACpBC,QAAShB,EAAOgB,QAChBC,QAAS,CACL,eAAgB,sBAIxBhB,KAAKiB,iBAAmBJ,EAAMC,OAAO,CACjCC,QAAShB,EAAOmB,sBAAwB,qEACxCF,QAAS,CACL,eAAgB,sBAexBhB,KAAKmB,cAAgBpB,EAAOoB,cAC5BnB,KAAKE,iBAAmB,IAAIkB,EAAWrB,EAAOoB,cAAcE,QAExDtB,EAAOS,kBAEPR,KAAKQ,gBAAkB,IAChBT,EAAOS,gBACVc,QAASC,OAAOxB,EAAOS,gBAAgBc,UAO3CtB,KAAKG,iBAAmBqB,EAAmB,CACvCC,UAAWC,EAAK3B,EAAOS,gBAAgBa,WAI/CrB,KAAKS,eAAiBV,EAAOU,gBAAkBC,EAAQC,MAC3D,CAEQ,SAAAgB,CAAUC,GACd5B,KAAKI,WAAawB,CACtB,CAEQ,aAAAC,CAAcC,GAClB9B,KAAKM,WAAawB,EAClBC,EAAQC,eAAeF,EAC3B,CAEQ,mBAAAG,CAAoBH,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1G,iBAAiB,KAELC,IACpB,CAEA,sBAAM4G,CAAiBH,GAInB,aAHuB/L,KAAKY,IAAIwE,KAA+B,qBAAsB2G,EAAS,CAC1F1G,iBAAiB,KAELC,IACpB,CAEA,6BAAM6G,CAAwBJ,GAI1B,aAHuB/L,KAAKY,IAAIwE,KAAsC,sBAAuB2G,EAAS,CAClG1G,iBAAiB,KAELC,IACpB,CAEA,iCAAM8G,GAIF,aAHuBpM,KAAKY,IAAIuH,IAA+B,yBAA0B,CACrF9C,iBAAiB,KAELC,IACpB,CAEA,2BAAM+G,GAIF,aAHuBrM,KAAKY,IAAIuH,IAAyB,uBAAwB,CAC7E9C,iBAAiB,KAELC,IACpB"}
1
+ {"version":3,"file":"client.js","sources":["../../../../src/client.ts"],"sourcesContent":[null],"names":["WalletClient","constructor","config","this","selectedWalletId","solanaConnection","ethereumProvider","walletInfo","phantomAdapter","walletType","backupWalletType","ethereumNetwork","defaultNetwork","Network","Solana","api","axios","create","baseURL","headers","middleAccountApi","middleAccountBaseURL","solanaCluster","Connection","rpcUrl","chainId","Number","createPublicClient","transport","http","setWallet","wallet","setWalletType","type","Storage","saveWalletType","setBackupWalletType","saveBackupWalletType","console","log","getWallet","getPhantomAdapter","getWalletType","getBackupWalletType","_a","wallets","find","network","address","ethereumWallet","getSwitchedAccountAddress","_b","Ethereum","wallet_set","ethereumAddress","solanaWallet","_c","_d","forwardSolanaWallet","forwardSolanaAddress","forwardEthereumWallet","forwardEthereumAddress","solanaAddress","id","social_links","reconnect","isBackup","connectPhantom","getSession","getBackupWalletInfo","error","PhantomWalletAdapter","connect","publicKey","Error","toString","uuidv4","wallet_type","WalletType","Phantom","account_index","is_enabled","social_infos","account_info","name","sub_accounts","created_at","Date","now","is_exported","message","updateAccountName","accountIndex","payload","undefined","post","withCredentials","data","manageMultiAccount","request","createSubAccount","enableSubAccount","index","disableSubAccount","signSolanaTransaction","transaction","blockhash","getLatestBlockhash","isVersionedTransaction","recentBlockhash","signTransaction","signRequest","user_id","tx","bs58","encode","serialize","serializeMessage","response","signature","addSignature","PublicKey","Buffer","from","decode","signEthereumEip712","params","EthereumEip712","sendSolanaTransaction","sendRawTransaction","maxRetries","skipPreflight","sendEthereumTransaction","signedTransaction","serializedTransaction","sendEmailVerificationCode","email","sendPhoneVerificationCode","phone","startsWith","verifyEmailVerificationCode","code","verifyPhoneVerificationCode","twitterLogin","googleLogin","oauthLogin","loginWithChallenge","oauthInit","getSignChallenge","get","method","access_token","rest","saveAccessToken","logout","disconnect","clearBackup","clear","getOAuth2ClientId","provider","client_id","setSelectedWallet","walletId","getSelectedWallet","getSolanaBalance","getBalance","LAMPORTS_PER_SOL","getEthereumBalance","balance","ethers.formatEther","fetchCoinbaseToken","blockchain","addresses","blockchains","assets","token","viemSignerAdapter","signTypedData","async","signatureBytes","recId","signatureToHex","r","slice","s","v","BigInt","createMiddleAccount","getCoinbaseOnrampUrlForMiddleAccount","sessionToken","middleAccountAddress","presetCryptoAmount","amount","redirectUrl","window","location","href","getOnrampBuyUrl","getOrderState","orderId","transfer","transferRequest","to","decimals","chain_id","buildTransaction","walletAddress"],"mappings":"uoCA+DaA,EAeT,WAAAC,CAAYC,GAZJC,KAAAC,iBAAkC,KAClCD,KAAAE,iBAAsC,KAEtCF,KAAAG,iBAAwC,KACxCH,KAAAI,WAAgC,KAChCJ,KAAAK,eAA8C,KAC9CL,KAAAM,WAAqC,WACrCN,KAAAO,iBAAyD,kBAEzDP,KAAAQ,gBAA0C,KAC1CR,KAAAS,eAA0BC,EAAQC,OAGtCX,KAAKY,IAAMC,EAAMC,OAAO,CACpBC,QAAShB,EAAOgB,QAChBC,QAAS,CACL,eAAgB,sBAIxBhB,KAAKiB,iBAAmBJ,EAAMC,OAAO,CACjCC,QAAShB,EAAOmB,sBAAwB,qEACxCF,QAAS,CACL,eAAgB,sBAexBhB,KAAKmB,cAAgBpB,EAAOoB,cAC5BnB,KAAKE,iBAAmB,IAAIkB,EAAWrB,EAAOoB,cAAcE,QAExDtB,EA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CAAE,MAAO3B,GAEL,GAAwB,QAApBnB,UAAAP,EAAA0B,EAAMgD,+BAAUrB,YAAI,IAAA9C,OAAA,EAAAA,EAAEmB,MACtB,MAAM,IAAII,MAAMJ,EAAMgD,SAASrB,KAAK3B,OAExC,MAAM,IAAII,MAAMJ,aAAiBI,MAAQJ,EAAMoB,QAAU,kBAC7D,CACJ,CAOA,sBAAMmH,CAAiB1G,EAAkC2G,WACrD,IAAK3M,KAAKI,WACN,MAAM,IAAImE,MAAM,4BAGpB,IACI,MAAMvD,EAAkC,CAAA,EACpC2L,IACA3L,EAAQ,kBAAoB2L,GAOhC,aAJuB3M,KAAKY,IAAIgF,KAA+B,wBAAyBI,EAAS,CAC7FH,iBAAiB,EACjB7E,aAEY8E,IACpB,CAAE,MAAO3B,GAEL,GAAwB,QAApBnB,UAAAP,EAAA0B,EAAMgD,+BAAUrB,YAAI,IAAA9C,OAAA,EAAAA,EAAEmB,MACtB,MAAM,IAAII,MAAMJ,EAAMgD,SAASrB,KAAK3B,OAExC,MAAM,IAAII,MAAMJ,aAAiBI,MAAQJ,EAAMoB,QAAU,8BAC7D,CACJ"}
@@ -1,2 +1,2 @@
1
- import"./polyfills.js";export{WalletClient}from"./client.js";export{WalletProvider,useWallet}from"./context.js";export{WalletProviderBackup,useWalletBackup}from"./context_backup.js";export{useActiveWallet,useConnect,useLoginModal,useWalletBackupStatus,useWalletStatus}from"./hooks.js";export{ACCESS_TOKEN_KEY,BACKUP_WALLET_INFO,BACKUP_WALLET_TYPE_KEY,STORAGE_STATE_KEY,SWITCHED_ACCOUNT_ADDRESS,Storage,WALLET_TYPE_KEY}from"./storage.js";export{BorrowedAsset,CollateralAsset,CrossMarginOperationType,CrossMarginPositionStatus,Network,SocialType,VaultId,WalletType,isVersionedTransaction}from"./types.js";export{injectStyles}from"./styles/index.js";export{useCoinbaseOnramp}from"./coinbase.js";export{theme}from"./styles/theme.js";"undefined"!=typeof window&&import("./styles/index.js").then(({injectStyles:e})=>{e()});
1
+ import"./polyfills.js";export{WalletClient}from"./client.js";export{WalletProvider,useWallet}from"./context.js";export{WalletProviderBackup,useWalletBackup}from"./context_backup.js";export{useActiveWallet,useConnect,useLoginModal,useWalletBackupStatus,useWalletStatus}from"./hooks.js";export{ACCESS_TOKEN_KEY,BACKUP_WALLET_INFO,BACKUP_WALLET_TYPE_KEY,STORAGE_STATE_KEY,SWITCHED_ACCOUNT_ADDRESS,Storage,WALLET_TYPE_KEY}from"./storage.js";export{Network,SocialType,VaultId,WalletType,isVersionedTransaction}from"./types.js";export{injectStyles}from"./styles/index.js";export{useCoinbaseOnramp}from"./coinbase.js";export{theme}from"./styles/theme.js";"undefined"!=typeof window&&import("./styles/index.js").then(({injectStyles:e})=>{e()});
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":[null],"names":["window","import","then","injectStyles"],"mappings":"ytBAasB,oBAAXA,QACPC,OAAO,qBAAYC,KAAK,EAAGC,mBACvBA"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/index.ts"],"sourcesContent":[null],"names":["window","import","then","injectStyles"],"mappings":"woBAasB,oBAAXA,QACPC,OAAO,qBAAYC,KAAK,EAAGC,mBACvBA"}
@@ -1,2 +1,2 @@
1
- function e(e){return"version"in e}var t,a,n,r,o,i,p,d;!function(e){e.Solana="Solana",e.Ethereum="Ethereum"}(t||(t={})),function(e){e.Phantom="Phantom",e.Embedded="Embedded"}(a||(a={})),function(e){e.Email="Email",e.Google="Google",e.Twitter="Twitter",e.Phantom="Phantom",e.Phone="Phone",e.Okx="Okx"}(n||(n={})),function(e){e.HyperbeatUltraHype="HyperbeatUltraHype",e.HyperbeatUltraUbtc="HyperbeatUltraUbtc",e.HyperbeatUsdt="HyperbeatUsdt",e.HyperbeatUsdc="HyperbeatUsdc",e.HyperbeatXaut="HyperbeatXaut",e.VentualsVlp="VentualsVlp",e.DnHype="DnHype",e.DnPump="DnPump"}(r||(r={})),function(e){e.HypercorePerpsUSDC="HypercorePerpsUSDC"}(o||(o={})),function(e){e.HypercoreSpotBTC="HypercoreSpotBTC"}(i||(i={})),function(e){e.Open="Open",e.Closed="Closed",e.PartiallyLiquidated="PartiallyLiquidated",e.AllLiquidated="AllLiquidated"}(p||(p={})),function(e){e.Borrow="Borrow",e.Repay="Repay",e.AddMargin="AddMargin",e.RemoveMargin="RemoveMargin",e.Liquidation="Liquidation"}(d||(d={}));export{o as BorrowedAsset,i as CollateralAsset,d as CrossMarginOperationType,p as CrossMarginPositionStatus,t as Network,n as SocialType,r as VaultId,a as WalletType,e as isVersionedTransaction};
1
+ function e(e){return"version"in e}var t,a,r,n;!function(e){e.Solana="Solana",e.Ethereum="Ethereum"}(t||(t={})),function(e){e.Phantom="Phantom",e.Embedded="Embedded"}(a||(a={})),function(e){e.Google="Google",e.Twitter="Twitter",e.Telegram="Telegram",e.Apple="Apple"}(r||(r={})),function(e){e.HyperbeatUltraHype="HyperbeatUltraHype",e.HyperbeatUltraUbtc="HyperbeatUltraUbtc",e.HyperbeatUsdt="HyperbeatUsdt",e.HyperbeatUsdc="HyperbeatUsdc",e.HyperbeatXaut="HyperbeatXaut",e.VentualsVlp="VentualsVlp",e.DnHype="DnHype",e.DnPump="DnPump"}(n||(n={}));export{t as Network,r as SocialType,n as VaultId,a as WalletType,e as isVersionedTransaction};
2
2
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../../src/types.ts"],"sourcesContent":[null],"names":["isVersionedTransaction","transaction","Network","WalletType","SocialType","VaultId","BorrowedAsset","CollateralAsset","CrossMarginPositionStatus","CrossMarginOperationType"],"mappings":"AAkBM,SAAUA,EACdC,GAEA,MAAO,YAAaA,CACtB,KAgBYC,EAKAC,EAKAC,EAqKAC,EA2GAC,EAIAC,EAIAC,EAOAC,GAzSZ,SAAYP,GACVA,EAAA,OAAA,SACAA,EAAA,SAAA,UACD,CAHD,CAAYA,IAAAA,EAAO,CAAA,IAKnB,SAAYC,GACVA,EAAA,QAAA,UACAA,EAAA,SAAA,UACD,CAHD,CAAYA,IAAAA,EAAU,CAAA,IAKtB,SAAYC,GACVA,EAAA,MAAA,QACAA,EAAA,OAAA,SACAA,EAAA,QAAA,UACAA,EAAA,QAAA,UACAA,EAAA,MAAA,QACAA,EAAA,IAAA,KACD,CAPD,CAAYA,IAAAA,EAAU,CAAA,IAqKtB,SAAYC,GACVA,EAAA,mBAAA,qBACAA,EAAA,mBAAA,qBACAA,EAAA,cAAA,gBACAA,EAAA,cAAA,gBACAA,EAAA,cAAA,gBACAA,EAAA,YAAA,cACAA,EAAA,OAAA,SACAA,EAAA,OAAA,QACD,CATD,CAAYA,IAAAA,EAAO,CAAA,IA2GnB,SAAYC,GACVA,EAAA,mBAAA,oBACD,CAFD,CAAYA,IAAAA,EAAa,CAAA,IAIzB,SAAYC,GACVA,EAAA,iBAAA,kBACD,CAFD,CAAYA,IAAAA,EAAe,CAAA,IAI3B,SAAYC,GACVA,EAAA,KAAA,OACAA,EAAA,OAAA,SACAA,EAAA,oBAAA,sBACAA,EAAA,cAAA,eACD,CALD,CAAYA,IAAAA,EAAyB,CAAA,IAOrC,SAAYC,GACVA,EAAA,OAAA,SACAA,EAAA,MAAA,QACAA,EAAA,UAAA,YACAA,EAAA,aAAA,eACAA,EAAA,YAAA,aACD,CAND,CAAYA,IAAAA,EAAwB,CAAA"}
1
+ {"version":3,"file":"types.js","sources":["../../../../src/types.ts"],"sourcesContent":[null],"names":["isVersionedTransaction","transaction","Network","WalletType","SocialType","VaultId"],"mappings":"AAkBM,SAAUA,EACdC,GAEA,MAAO,YAAaA,CACtB,KAiBYC,EAKAC,EAKAC,EAiMAC,GA3MZ,SAAYH,GACVA,EAAA,OAAA,SACAA,EAAA,SAAA,UACD,CAHD,CAAYA,IAAAA,EAAO,CAAA,IAKnB,SAAYC,GACVA,EAAA,QAAA,UACAA,EAAA,SAAA,UACD,CAHD,CAAYA,IAAAA,EAAU,CAAA,IAKtB,SAAYC,GACVA,EAAA,OAAA,SACAA,EAAA,QAAA,UACAA,EAAA,SAAA,WACAA,EAAA,MAAA,OACD,CALD,CAAYA,IAAAA,EAAU,CAAA,IAiMtB,SAAYC,GACVA,EAAA,mBAAA,qBACAA,EAAA,mBAAA,qBACAA,EAAA,cAAA,gBACAA,EAAA,cAAA,gBACAA,EAAA,cAAA,gBACAA,EAAA,YAAA,cACAA,EAAA,OAAA,SACAA,EAAA,OAAA,QACD,CATD,CAAYA,IAAAA,EAAO,CAAA"}
@@ -1,4 +1,4 @@
1
- import { Wallet, Social, WalletInfo, Network, IModalManager, MiddleAccountRequest, MiddleAccount, CoinbaseOnrampRequest, OrderState, LoginType, BuildTransactionRequest, BuildTransactionResponse, CrossMarginAdjustMarginRequest, CrossMarginAdjustMarginResponse, CrossMarginBorrowQuoteRequest, CrossMarginBorrowQuoteResponse, CrossMarginBorrowRequest, CrossMarginBorrowResponse, CrossMarginGeneralInfoResponse, CrossMarginRepayQuoteRequest, CrossMarginRepayQuoteResponse, CrossMarginRepayRequest, CrossMarginRepayResponse, UserHistoryResponse, UserOpenPositionsResponse } from "./types";
1
+ import { Wallet, Social, WalletInfo, Network, IModalManager, MiddleAccountRequest, MiddleAccount, CoinbaseOnrampRequest, OrderState, LoginType, BuildTransactionRequest, BuildTransactionResponse, MultiAccountRequest } from "./types";
2
2
  import { Transaction, VersionedTransaction } from "@solana/web3.js";
3
3
  import { PhantomWalletAdapter } from "./adapters/phantom";
4
4
  import * as viem from "viem";
@@ -60,8 +60,44 @@ export declare class WalletClient {
60
60
  get social_links(): Social[] | null;
61
61
  reconnect(isBackup?: boolean): Promise<WalletInfo | null>;
62
62
  connectPhantom(): Promise<WalletInfo | null>;
63
- updateAccountName(name: string): Promise<any>;
63
+ updateAccountName(name: string, accountIndex?: number): Promise<WalletInfo>;
64
+ /**
65
+ * Create, enable, or disable a sub-account
66
+ * @param request Multi-account request with type and data
67
+ * @returns Updated wallet info
68
+ */
69
+ manageMultiAccount(request: MultiAccountRequest): Promise<WalletInfo>;
70
+ /**
71
+ * Create a new sub-account
72
+ * @param name Optional name for the sub-account
73
+ * @returns Updated wallet info
74
+ */
75
+ createSubAccount(name?: string | null): Promise<WalletInfo>;
76
+ /**
77
+ * Enable a sub-account by index
78
+ * @param index Account index to enable
79
+ * @returns Updated wallet info
80
+ */
81
+ enableSubAccount(index: number): Promise<WalletInfo>;
82
+ /**
83
+ * Disable a sub-account by index
84
+ * @param index Account index to disable
85
+ * @returns Updated wallet info
86
+ */
87
+ disableSubAccount(index: number): Promise<WalletInfo>;
88
+ /**
89
+ * This method is used to sign a solana transaction with v3 sign api,
90
+ * which is enabled in default.
91
+ * @param transaction Solana transaction to sign
92
+ * @returns signed transaction
93
+ */
64
94
  signSolanaTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
95
+ /**
96
+ * This method is used to sign a ethereum eip712 transaction with v2 sign api,
97
+ * which is disabled in default.
98
+ * @param params Ethereum eip712 transaction parameters
99
+ * @returns signature
100
+ */
65
101
  signEthereumEip712(params: {
66
102
  domain: {
67
103
  name: string;
@@ -136,6 +172,11 @@ export declare class WalletClient {
136
172
  getSolanaBalance(): Promise<string>;
137
173
  getEthereumBalance(): Promise<string>;
138
174
  fetchCoinbaseToken(address: string, blockchain?: "solana" | "ethereum"): Promise<string>;
175
+ /**
176
+ * This method is used to sign a ethereum eip712 transaction with v2 sign api,
177
+ * which is disabled in default.
178
+ * @returns viem signer adapter
179
+ */
139
180
  viemSignerAdapter(): {
140
181
  signTypedData: (params: {
141
182
  domain: {
@@ -189,15 +230,7 @@ export declare class WalletClient {
189
230
  * @param request Build transaction request
190
231
  * @returns Build transaction response with raw transaction
191
232
  */
192
- buildTransaction(request: BuildTransactionRequest): Promise<BuildTransactionResponse>;
193
- getCrossMarginGeneralInfo(): Promise<CrossMarginGeneralInfoResponse>;
194
- getCrossMarginBorrowQuote(payload: CrossMarginBorrowQuoteRequest): Promise<CrossMarginBorrowQuoteResponse>;
195
- borrowCrossMargin(payload: CrossMarginBorrowRequest): Promise<CrossMarginBorrowResponse>;
196
- getCrossMarginRepayQuote(payload: CrossMarginRepayQuoteRequest): Promise<CrossMarginRepayQuoteResponse>;
197
- repayCrossMargin(payload: CrossMarginRepayRequest): Promise<CrossMarginRepayResponse>;
198
- adjustCrossMarginMargin(payload: CrossMarginAdjustMarginRequest): Promise<CrossMarginAdjustMarginResponse>;
199
- getCrossMarginOpenPositions(): Promise<UserOpenPositionsResponse>;
200
- getCrossMarginHistory(): Promise<UserHistoryResponse>;
233
+ buildTransaction(request: BuildTransactionRequest, walletAddress?: string): Promise<BuildTransactionResponse>;
201
234
  }
202
235
  export type SignTransactionReturnType<serializer extends viem.SerializeTransactionFn<viem.TransactionSerializable> = viem.SerializeTransactionFn<viem.TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]> = viem.TransactionSerialized<viem.GetTransactionType<transaction>>;
203
236
  export {};
@@ -3,7 +3,7 @@ import { WalletClient } from "./client";
3
3
  export type SupportedTransactionVersions = ReadonlySet<TransactionVersion> | null | undefined;
4
4
  export type TransactionOrVersionedTransaction<S extends SupportedTransactionVersions> = S extends null | undefined ? Transaction : Transaction | VersionedTransaction;
5
5
  export declare function isVersionedTransaction(transaction: Transaction | VersionedTransaction): transaction is VersionedTransaction;
6
- export type LoginType = "TwitterOAuth" | "GoogleOAuth" | "Phantom" | "Okx" | "Email" | "Phone" | "Telegram" | "TelegramOAuth" | "MetaMask" | "Rabby" | "Coinbase" | "WalletConnect";
6
+ export type LoginType = "Email" | "Phone" | "TwitterOAuth" | "GoogleOAuth" | "Telegram" | "TelegramOAuth" | "Apple" | "Phantom" | "Okx" | "MetaMask" | "Rabby" | "Coinbase" | "WalletConnect";
7
7
  export declare enum Network {
8
8
  Solana = "Solana",
9
9
  Ethereum = "Ethereum"
@@ -13,12 +13,10 @@ export declare enum WalletType {
13
13
  Embedded = "Embedded"
14
14
  }
15
15
  export declare enum SocialType {
16
- Email = "Email",
17
16
  Google = "Google",
18
17
  Twitter = "Twitter",
19
- Phantom = "Phantom",
20
- Phone = "Phone",
21
- Okx = "Okx"
18
+ Telegram = "Telegram",
19
+ Apple = "Apple"
22
20
  }
23
21
  export type Social = {
24
22
  [key in SocialType]: string;
@@ -39,36 +37,72 @@ export interface Wallet {
39
37
  address: string;
40
38
  network: Network;
41
39
  wallet_type: WalletType;
42
- wallet_set: "Main" | "Forward-0" | string;
40
+ wallet_set: "Main" | `Forward-${number}` | `Secondary-${number}` | `SecondaryForward-${number}-${number}`;
41
+ account_index: number;
42
+ is_enabled: boolean;
43
43
  }
44
44
  export interface WalletInfo {
45
- account_info: AccountInfo;
46
45
  id: string;
47
- is_exported: boolean;
48
46
  wallets: Wallet[];
49
47
  social_links: Social[];
50
48
  social_infos: SocialInfo[];
49
+ account_info: AccountInfo;
50
+ created_at: number;
51
+ is_exported: boolean;
51
52
  access_token?: string;
52
53
  }
54
+ export interface SubAccountInfo {
55
+ account_index: number;
56
+ secondary_index: number;
57
+ name?: string;
58
+ created_at: number;
59
+ is_exported: boolean;
60
+ is_enabled: boolean;
61
+ }
53
62
  export interface AccountInfo {
54
63
  name: string | null;
64
+ sub_accounts: SubAccountInfo[];
55
65
  }
66
+ export type MultiAccountRequest = {
67
+ type: "Create";
68
+ data: {
69
+ name?: string | null;
70
+ };
71
+ } | {
72
+ type: "Enable";
73
+ data: {
74
+ index: number;
75
+ };
76
+ } | {
77
+ type: "Disable";
78
+ data: {
79
+ index: number;
80
+ };
81
+ };
56
82
  export interface SignRequestV1 {
83
+ user_id: string;
84
+ network: string;
57
85
  address: string;
58
- userId: string;
59
86
  message: string;
60
- network: string;
61
- requestId: string;
62
87
  }
63
- export interface UnsignedTx {
88
+ export interface UnsignedTxV2 {
64
89
  Solana?: string;
65
90
  EthereumEip712?: Record<string, unknown>;
66
91
  }
67
92
  export interface SignRequestV2 {
93
+ user_id: string;
94
+ network: string;
68
95
  address: string;
96
+ tx: UnsignedTxV2;
97
+ }
98
+ export interface UnsignedTxV3 {
99
+ Solana?: string;
100
+ }
101
+ export interface SignRequestV3 {
69
102
  user_id: string;
70
103
  network: string;
71
- tx: UnsignedTx;
104
+ address: string;
105
+ tx: UnsignedTxV3;
72
106
  }
73
107
  export interface UserSession {
74
108
  id: string;
@@ -134,13 +168,13 @@ export interface OrderState {
134
168
  }
135
169
  export interface TransferRequest {
136
170
  user_id: string;
171
+ network: Network;
172
+ chain_id: number;
137
173
  from: string;
138
174
  to: string;
139
175
  amount: string;
140
176
  decimals: number;
141
177
  token?: string;
142
- network: Network;
143
- chain_id: number;
144
178
  }
145
179
  export declare enum VaultId {
146
180
  HyperbeatUltraHype = "HyperbeatUltraHype",
@@ -232,136 +266,5 @@ export type BuildTransactionRequest = {
232
266
  };
233
267
  export interface BuildTransactionResponse {
234
268
  raw_transaction: string;
235
- }
236
- export type BigDecimalString = string;
237
- export declare enum BorrowedAsset {
238
- HypercorePerpsUSDC = "HypercorePerpsUSDC"
239
- }
240
- export declare enum CollateralAsset {
241
- HypercoreSpotBTC = "HypercoreSpotBTC"
242
- }
243
- export declare enum CrossMarginPositionStatus {
244
- Open = "Open",
245
- Closed = "Closed",
246
- PartiallyLiquidated = "PartiallyLiquidated",
247
- AllLiquidated = "AllLiquidated"
248
- }
249
- export declare enum CrossMarginOperationType {
250
- Borrow = "Borrow",
251
- Repay = "Repay",
252
- AddMargin = "AddMargin",
253
- RemoveMargin = "RemoveMargin",
254
- Liquidation = "Liquidation"
255
- }
256
- export interface CollateralAssetInfo {
257
- amount: BigDecimalString;
258
- contribution?: number;
259
- liquidation_price?: number;
260
- }
261
- export interface CrossMarginBorrowQuoteRequest {
262
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
263
- }
264
- export interface CrossMarginBorrowQuoteResponse {
265
- quote_id: string;
266
- collateral_asset_infos: Record<CollateralAsset, CollateralAssetInfo>;
267
- total_collateral_value: number;
268
- borrowed_asset: BorrowedAsset;
269
- max_borrowed_amount: BigDecimalString;
270
- max_borrowed_value: number;
271
- created_at: number;
272
- expires_at: number;
273
- }
274
- export interface CrossMarginBorrowRequest {
275
- network: Network;
276
- address: string;
277
- quote_id: string;
278
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
279
- borrowed_asset: BorrowedAsset;
280
- borrowed_amount: BigDecimalString;
281
- }
282
- export interface CrossMarginBorrowResponse {
283
- position_id: string;
284
- }
285
- export interface CrossMarginRepayQuoteRequest {
286
- position_id: string;
287
- }
288
- export interface CrossMarginRepayQuoteResponse {
289
- quote_id: string;
290
- repay_asset: BorrowedAsset;
291
- borrowed_amount: BigDecimalString;
292
- interest_cost: BigDecimalString;
293
- repay_amount: BigDecimalString;
294
- created_at: number;
295
- expires_at: number;
296
- }
297
- export interface CrossMarginRepayRequest {
298
- position_id: string;
299
- quote_id: string;
300
- repay_asset: BorrowedAsset;
301
- repay_amount: BigDecimalString;
302
- }
303
- export interface CrossMarginRepayResponse {
304
- position_id: string;
305
- }
306
- export interface CrossMarginAdjustMarginRequest {
307
- position_id: string;
308
- is_add_margin: boolean;
309
- collateral_assets: Partial<Record<CollateralAsset, BigDecimalString>>;
310
- }
311
- export interface CrossMarginAdjustMarginResponse {
312
- position_id: string;
313
- }
314
- export interface BorrowedAssetGeneralInfo {
315
- interest_rate_hourly: number;
316
- interest_rate_annual: number;
317
- available_amount: number;
318
- max_borrowable_amount: number;
319
- }
320
- export interface CollateralAssetGeneralInfo {
321
- liquidation_threshold: number;
322
- h_vol: number;
323
- price: number;
324
- }
325
- export interface CrossMarginGeneralInfoResponse {
326
- collateral_info: Record<CollateralAsset, CollateralAssetGeneralInfo>;
327
- borrowed_info: Record<BorrowedAsset, BorrowedAssetGeneralInfo>;
328
- }
329
- export interface UserOpenPositionInfo {
330
- position_id: string;
331
- collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
332
- borrowed_asset: BorrowedAsset;
333
- borrowed_amount: BigDecimalString;
334
- created_at: number;
335
- updated_at: number;
336
- current_ltv: number;
337
- margin_call_ltv: number;
338
- liquidation_ltv: number;
339
- interest_cost: number;
340
- }
341
- export interface UserOpenPositionsResponse {
342
- positions: UserOpenPositionInfo[];
343
- }
344
- export interface UserClosedPositionInfo {
345
- position_id: string;
346
- collateral_assets: Record<CollateralAsset, CollateralAssetInfo>;
347
- borrowed_asset: BorrowedAsset;
348
- borrowed_amount: BigDecimalString;
349
- created_at: number;
350
- closed_at: number;
351
- interest_cost: number;
352
- status: CrossMarginPositionStatus;
353
- repaid_amount?: number;
354
- }
355
- export interface UserOperationInfo {
356
- position_id: string;
357
- operation_id: string;
358
- created_at: number;
359
- finished_at: number;
360
- operation_type: CrossMarginOperationType;
361
- amount: BigDecimalString;
362
- symbol: string;
363
- }
364
- export interface UserHistoryResponse {
365
- positions: UserClosedPositionInfo[];
366
- operations: UserOperationInfo[];
269
+ metadata?: any;
367
270
  }