repo_id
stringclasses
563 values
file_path
stringlengths
40
166
content
stringlengths
1
2.94M
__index_level_0__
int64
0
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom/package.json
{ "name": "@solana/wallet-adapter-phantom", "version": "0.9.24", "author": "Solana Maintainers <maintainers@solana.foundation>", "repository": "https://github.com/anza-xyz/wallet-adapter", "license": "Apache-2.0", "publishConfig": { "access": "public" }, "files": [ "lib", "src", "LICENSE" ], "engines": { "node": ">=18" }, "type": "module", "sideEffects": false, "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", "types": "./lib/types/index.d.ts", "exports": { "require": "./lib/cjs/index.js", "import": "./lib/esm/index.js", "types": "./lib/types/index.d.ts" }, "scripts": { "build": "tsc --build --verbose && pnpm run package", "clean": "shx mkdir -p lib && shx rm -rf lib", "lint": "prettier --check 'src/{*,**/*}.{ts,tsx,js,jsx,json}' && eslint", "package": "shx mkdir -p lib/cjs && shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json" }, "peerDependencies": { "@solana/web3.js": "^1.77.3" }, "dependencies": { "@solana/wallet-adapter-base": "workspace:^" }, "devDependencies": { "@solana/web3.js": "^1.77.3", "shx": "^0.3.4" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom/tsconfig.cjs.json
{ "extends": "../../../tsconfig.cjs.json", "include": ["src"], "compilerOptions": { "outDir": "lib/cjs" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom/tsconfig.json
{ "extends": "../../../tsconfig.root.json", "references": [ { "path": "./tsconfig.cjs.json" }, { "path": "./tsconfig.esm.json" } ] }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom/src/adapter.ts
import type { EventEmitter, SendTransactionOptions, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, isIosAndRedirectable, isVersionedTransaction, scopePollingDetectionStrategy, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSendTransactionError, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { Connection, SendOptions, Transaction, TransactionSignature, TransactionVersion, VersionedTransaction, } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface PhantomWalletEvents { connect(...args: unknown[]): unknown; disconnect(...args: unknown[]): unknown; accountChanged(newPublicKey: PublicKey): unknown; } interface PhantomWallet extends EventEmitter<PhantomWalletEvents> { isPhantom?: boolean; publicKey?: { toBytes(): Uint8Array }; isConnected: boolean; signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>; signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>; signAndSendTransaction<T extends Transaction | VersionedTransaction>( transaction: T, options?: SendOptions ): Promise<{ signature: TransactionSignature }>; signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; connect(): Promise<void>; disconnect(): Promise<void>; } interface PhantomWindow extends Window { phantom?: { solana?: PhantomWallet; }; solana?: PhantomWallet; } declare const window: PhantomWindow; export interface PhantomWalletAdapterConfig {} export const PhantomWalletName = 'Phantom' as WalletName<'Phantom'>; export class PhantomWalletAdapter extends BaseMessageSignerWalletAdapter { name = PhantomWalletName; url = 'https://phantom.app'; icon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiB2aWV3Qm94PSIwIDAgMTA4IDEwOCIgZmlsbD0ibm9uZSI+CjxyZWN0IHdpZHRoPSIxMDgiIGhlaWdodD0iMTA4IiByeD0iMjYiIGZpbGw9IiNBQjlGRjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik00Ni41MjY3IDY5LjkyMjlDNDIuMDA1NCA3Ni44NTA5IDM0LjQyOTIgODUuNjE4MiAyNC4zNDggODUuNjE4MkMxOS41ODI0IDg1LjYxODIgMTUgODMuNjU2MyAxNSA3NS4xMzQyQzE1IDUzLjQzMDUgNDQuNjMyNiAxOS44MzI3IDcyLjEyNjggMTkuODMyN0M4Ny43NjggMTkuODMyNyA5NCAzMC42ODQ2IDk0IDQzLjAwNzlDOTQgNTguODI1OCA4My43MzU1IDc2LjkxMjIgNzMuNTMyMSA3Ni45MTIyQzcwLjI5MzkgNzYuOTEyMiA2OC43MDUzIDc1LjEzNDIgNjguNzA1MyA3Mi4zMTRDNjguNzA1MyA3MS41NzgzIDY4LjgyNzUgNzAuNzgxMiA2OS4wNzE5IDY5LjkyMjlDNjUuNTg5MyA3NS44Njk5IDU4Ljg2ODUgODEuMzg3OCA1Mi41NzU0IDgxLjM4NzhDNDcuOTkzIDgxLjM4NzggNDUuNjcxMyA3OC41MDYzIDQ1LjY3MTMgNzQuNDU5OEM0NS42NzEzIDcyLjk4ODQgNDUuOTc2OCA3MS40NTU2IDQ2LjUyNjcgNjkuOTIyOVpNODMuNjc2MSA0Mi41Nzk0QzgzLjY3NjEgNDYuMTcwNCA4MS41NTc1IDQ3Ljk2NTggNzkuMTg3NSA0Ny45NjU4Qzc2Ljc4MTYgNDcuOTY1OCA3NC42OTg5IDQ2LjE3MDQgNzQuNjk4OSA0Mi41Nzk0Qzc0LjY5ODkgMzguOTg4NSA3Ni43ODE2IDM3LjE5MzEgNzkuMTg3NSAzNy4xOTMxQzgxLjU1NzUgMzcuMTkzMSA4My42NzYxIDM4Ljk4ODUgODMuNjc2MSA0Mi41Nzk0Wk03MC4yMTAzIDQyLjU3OTVDNzAuMjEwMyA0Ni4xNzA0IDY4LjA5MTYgNDcuOTY1OCA2NS43MjE2IDQ3Ljk2NThDNjMuMzE1NyA0Ny45NjU4IDYxLjIzMyA0Ni4xNzA0IDYxLjIzMyA0Mi41Nzk1QzYxLjIzMyAzOC45ODg1IDYzLjMxNTcgMzcuMTkzMSA2NS43MjE2IDM3LjE5MzFDNjguMDkxNiAzNy4xOTMxIDcwLjIxMDMgMzguOTg4NSA3MC4yMTAzIDQyLjU3OTVaIiBmaWxsPSIjRkZGREY4Ii8+Cjwvc3ZnPg=='; supportedTransactionVersions: ReadonlySet<TransactionVersion> = new Set(['legacy', 0]); private _connecting: boolean; private _wallet: PhantomWallet | null; private _publicKey: PublicKey | null; private _readyState: WalletReadyState = typeof window === 'undefined' || typeof document === 'undefined' ? WalletReadyState.Unsupported : WalletReadyState.NotDetected; constructor(config: PhantomWalletAdapterConfig = {}) { super(); this._connecting = false; this._wallet = null; this._publicKey = null; if (this._readyState !== WalletReadyState.Unsupported) { if (isIosAndRedirectable()) { // when in iOS (not webview), set Phantom as loadable instead of checking for install this._readyState = WalletReadyState.Loadable; this.emit('readyStateChange', this._readyState); } else { scopePollingDetectionStrategy(() => { if (window.phantom?.solana?.isPhantom || window.solana?.isPhantom) { this._readyState = WalletReadyState.Installed; this.emit('readyStateChange', this._readyState); return true; } return false; }); } } } get publicKey() { return this._publicKey; } get connecting() { return this._connecting; } get readyState() { return this._readyState; } async autoConnect(): Promise<void> { // Skip autoconnect in the Loadable state // We can't redirect to a universal link without user input if (this.readyState === WalletReadyState.Installed) { await this.connect(); } } async connect(): Promise<void> { try { if (this.connected || this.connecting) return; if (this.readyState === WalletReadyState.Loadable) { // redirect to the Phantom /browse universal link // this will open the current URL in the Phantom in-wallet browser const url = encodeURIComponent(window.location.href); const ref = encodeURIComponent(window.location.origin); window.location.href = `https://phantom.app/ul/browse/${url}?ref=${ref}`; return; } if (this.readyState !== WalletReadyState.Installed) throw new WalletNotReadyError(); this._connecting = true; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const wallet = window.phantom?.solana || window.solana!; if (!wallet.isConnected) { try { await wallet.connect(); } catch (error: any) { throw new WalletConnectionError(error?.message, error); } } if (!wallet.publicKey) throw new WalletAccountError(); let publicKey: PublicKey; try { publicKey = new PublicKey(wallet.publicKey.toBytes()); } catch (error: any) { throw new WalletPublicKeyError(error?.message, error); } wallet.on('disconnect', this._disconnected); wallet.on('accountChanged', this._accountChanged); this._wallet = wallet; this._publicKey = publicKey; this.emit('connect', publicKey); } catch (error: any) { this.emit('error', error); throw error; } finally { this._connecting = false; } } async disconnect(): Promise<void> { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); wallet.off('accountChanged', this._accountChanged); this._wallet = null; this._publicKey = null; try { await wallet.disconnect(); } catch (error: any) { this.emit('error', new WalletDisconnectionError(error?.message, error)); } } this.emit('disconnect'); } async sendTransaction<T extends Transaction | VersionedTransaction>( transaction: T, connection: Connection, options: SendTransactionOptions = {} ): Promise<TransactionSignature> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { const { signers, ...sendOptions } = options; if (isVersionedTransaction(transaction)) { signers?.length && transaction.sign(signers); } else { transaction = (await this.prepareTransaction(transaction, connection, sendOptions)) as T; signers?.length && (transaction as Transaction).partialSign(...signers); } sendOptions.preflightCommitment = sendOptions.preflightCommitment || connection.commitment; const { signature } = await wallet.signAndSendTransaction(transaction, sendOptions); return signature; } catch (error: any) { if (error instanceof WalletError) throw error; throw new WalletSendTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signTransaction(transaction)) || transaction; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signAllTransactions(transactions)) || transactions; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signMessage(message: Uint8Array): Promise<Uint8Array> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { const { signature } = await wallet.signMessage(message); return signature; } catch (error: any) { throw new WalletSignMessageError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } private _disconnected = () => { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); wallet.off('accountChanged', this._accountChanged); this._wallet = null; this._publicKey = null; this.emit('error', new WalletDisconnectedError()); this.emit('disconnect'); } }; private _accountChanged = (newPublicKey: PublicKey) => { const publicKey = this._publicKey; if (!publicKey) return; try { newPublicKey = new PublicKey(newPublicKey.toBytes()); } catch (error: any) { this.emit('error', new WalletPublicKeyError(error?.message, error)); return; } if (publicKey.equals(newPublicKey)) return; this._publicKey = newPublicKey; this.emit('connect', newPublicKey); }; }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/phantom/src/index.ts
export * from './adapter.js';
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/tsconfig.esm.json
{ "extends": "../../../tsconfig.esm.json", "include": ["src"], "compilerOptions": { "outDir": "lib/esm", "declarationDir": "lib/types" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/package.json
{ "name": "@solana/wallet-adapter-salmon", "version": "0.1.14", "author": "Solana Maintainers <maintainers@solana.foundation>", "repository": "https://github.com/anza-xyz/wallet-adapter", "license": "Apache-2.0", "publishConfig": { "access": "public" }, "files": [ "lib", "src", "LICENSE" ], "engines": { "node": ">=18" }, "type": "module", "sideEffects": false, "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", "types": "./lib/types/index.d.ts", "exports": { "require": "./lib/cjs/index.js", "import": "./lib/esm/index.js", "types": "./lib/types/index.d.ts" }, "scripts": { "build": "tsc --build --verbose && pnpm run package", "clean": "shx mkdir -p lib && shx rm -rf lib", "lint": "prettier --check 'src/{*,**/*}.{ts,tsx,js,jsx,json}' && eslint", "package": "shx mkdir -p lib/cjs && shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json" }, "peerDependencies": { "@solana/web3.js": "^1.77.3" }, "dependencies": { "@solana/wallet-adapter-base": "workspace:^", "salmon-adapter-sdk": "^1.1.1" }, "devDependencies": { "@solana/web3.js": "^1.77.3", "shx": "^0.3.4" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/tsconfig.cjs.json
{ "extends": "../../../tsconfig.cjs.json", "include": ["src"], "compilerOptions": { "outDir": "lib/cjs" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/tsconfig.json
{ "extends": "../../../tsconfig.root.json", "references": [ { "path": "./tsconfig.cjs.json" }, { "path": "./tsconfig.esm.json" } ] }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/src/adapter.ts
import type { WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, WalletAccountError, WalletAdapterNetwork, WalletConfigError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletLoadError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { Transaction } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; import type { default as Salmon, SalmonWallet } from 'salmon-adapter-sdk'; interface SalmonWindow extends Window { salmon?: SalmonWallet; } declare const window: SalmonWindow; export interface SalmonWalletAdapterConfig { network?: WalletAdapterNetwork; } export const SalmonWalletName = 'Salmon' as WalletName<'Salmon'>; export class SalmonWalletAdapter extends BaseMessageSignerWalletAdapter { name = SalmonWalletName; url = 'https://salmonwallet.io'; icon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4KPHN2ZyB3aWR0aD0iODgiIGhlaWdodD0iODgiIHZpZXdCb3g9IjAgMCA4OCA4OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9Ijg4IiBoZWlnaHQ9Ijg4IiByeD0iMzAiIGZpbGw9InVybCgjcGFpbnQwX2xpbmVhcl84NTVfNTgwKSIvPgo8cGF0aCBkPSJNNTkuODA1NSAyNy42M0M1Ni43OTU1IDI1LjgyMzkgNTMuNjIyMiAyNC41Mzg4IDUwLjM1OTcgMjMuODE0NEw0Ni45MDQyIDE2LjEyODdDNDYuNDkzMyAxNC44NTg1IDQ1LjMwMDIgMTQuMDAwMSA0My45NTM3IDE0LjAwMDFINDMuODE1QzQyLjQ2ODUgMTQuMDAwMSA0MS4yNzU0IDE0Ljg2MzUgNDAuODY0NSAxNi4xMjg3TDM3LjQwOSAyMy44MDk1QzM0LjE0MTYgMjQuNTM4OCAzMC45NTgzIDI1LjgyODkgMjcuOTQzNCAyNy42MzQ5QzIxLjk1MzIgMzkuMjYwMyAyMC4zMjk0IDUwLjU5MjggMjEuMTQxMyA2MS43NjY2QzI0LjY1MTMgNjUuMTY1NCAzMi40MzM2IDY5LjM2OCAzNi42MDcgNzEuMDMwMkMzOS4wNTI2IDcyLjAwMjcgMzkuODAwMSA3Mi40OTM5IDQyLjI1MDYgNzIuOTAwN0M0NC40Mjg5IDczLjUxNiA0NS4wODczIDczLjI3NzggNDYuNzU1NyA3My4xMDQyQzQ5LjMyNTEgNzIuNDE5NSA1MC4zOTQ0IDcxLjcyNDggNTEuNDM0IDcxLjE2NDFDNTUuODQ5OSA2OC44NzY4IDYzLjExNzQgNjUuMTcwNCA2Ni42Mjc0IDYxLjc3MTZDNjcuNTc3OSA0OC44MTE2IDY0Ljk5ODYgMzcuNTgzMiA1OS44MDU1IDI3LjYyNVYyNy42M1pNMzcuNTI3OCA1MS4xNDg1QzM1LjY0MTYgNTEuMTQ4NSAzNC4wODIyIDQ4LjkwMDkgMzQuMDgyMiA0Ni4xMzIyQzM0LjA4MjIgNDMuMzYzNiAzNS41ODcxIDQxLjA5NjEgMzcuNTE3OSA0MS4wOTYxQzM5LjQ0ODYgNDEuMDk2MSA0MC45OTgxIDQzLjM2MzYgNDAuOTYzNSA0Ni4xMzIyQzQwLjkyODggNDguOTAwOSAzOS40NDM3IDUxLjE0ODUgMzcuNTIyOCA1MS4xNDg1SDM3LjUyNzhaTTUwLjIzMSA1MS4xNDg1QzQ4LjMzOTkgNTEuMTQ4NSA0Ni43OTAzIDQ4LjkwMDkgNDYuNzkwMyA0Ni4xMzIyQzQ2Ljc5MDMgNDMuMzYzNiA0OC4yOTUzIDQxLjA5NjEgNTAuMjMxIDQxLjA5NjFDNTIuMTY2NyA0MS4wOTYxIDUzLjcwMTQgNDMuMzYzNiA1My42NjY3IDQ2LjEzMjJDNTMuNjMyMSA0OC45MDA5IDUyLjE1MTggNTEuMTQ4NSA1MC4yMzEgNTEuMTQ4NVoiIGZpbGw9IiNGQ0ZDRkMiLz4KPHBhdGggZD0iTTc1LjQwNTEgNTYuMTIwM0w3MC45NzkzIDQyLjE3MjlDNzAuNDM0NyA0MC40NjYxIDY4Ljg1NTUgMzkuMzA1MSA2Ny4wNjMzIDM5LjMwNTFDNjYuNTI4NyAzOS4zMDUxIDY2LjAwODkgMzkuNDA5MiA2NS41Mjg3IDM5LjYwMjhDNjcuNTQ4NSA0Ni4zMjU5IDY4LjM2MDQgNTMuNTc5OSA2Ny43MjY3IDYxLjQ4NEg3MS40ODQyQzc0LjI2NjUgNjEuNDg0IDc2LjI0MTcgNTguNzc0OSA3NS40MDAxIDU2LjEyMDNINzUuNDA1MVoiIGZpbGw9IiNGQ0ZDRkMiLz4KPHBhdGggZD0iTTEyLjE5MDggNTYuMzgzNUwxNi42MTY2IDQyLjQzNjFDMTcuMTYxMiA0MC43MjkyIDE4Ljc0MDUgMzkuNTY4MiAyMC41MzI2IDM5LjU2ODJDMjEuMDY3MiAzOS41NjgyIDIxLjU4NyAzOS42NzI0IDIyLjA2NzMgMzkuODY1OUMyMC4wNDc0IDQ2LjU4OSAxOS4yMzU1IDUzLjg0MzEgMTkuODY5MiA2MS43NDcxSDE2LjExMTdDMTMuMzI5NSA2MS43NDcxIDExLjM1NDIgNTkuMDM4IDEyLjE5NTggNTYuMzgzNUgxMi4xOTA4WiIgZmlsbD0iI0ZDRkNGQyIvPgo8ZGVmcz4KPGxpbmVhckdyYWRpZW50IGlkPSJwYWludDBfbGluZWFyXzg1NV81ODAiIHgxPSI0NCIgeTE9IjAiIHgyPSI0NCIgeTI9Ijg4IiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CjxzdG9wIHN0b3AtY29sb3I9IiNGRjgxNzAiLz4KPHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjRkY1QzQ1Ii8+CjwvbGluZWFyR3JhZGllbnQ+CjwvZGVmcz4KPC9zdmc+'; readonly supportedTransactionVersions = null; private _connecting: boolean; private _wallet: Salmon | null; private _publicKey: PublicKey | null; private _network: WalletAdapterNetwork; private _readyState: WalletReadyState = typeof window === 'undefined' || typeof document === 'undefined' ? WalletReadyState.Unsupported : WalletReadyState.Loadable; constructor({ network = WalletAdapterNetwork.Mainnet }: SalmonWalletAdapterConfig = {}) { super(); this._network = network; this._connecting = false; this._wallet = null; this._publicKey = null; if (this._readyState !== WalletReadyState.Unsupported) { scopePollingDetectionStrategy(() => { if (window.salmon) { this._readyState = WalletReadyState.Installed; this.emit('readyStateChange', this._readyState); return true; } return false; }); } } get publicKey() { return this._publicKey; } get connecting() { return this._connecting; } get connected() { return !!this._wallet?.connected; } get readyState() { return this._readyState; } async connect(): Promise<void> { try { if (this.connected || this.connecting) return; if (this._readyState !== WalletReadyState.Loadable && this._readyState !== WalletReadyState.Installed) throw new WalletNotReadyError(); this._connecting = true; let SalmonClass: typeof Salmon; try { SalmonClass = (await import('salmon-adapter-sdk')).default; } catch (error: any) { throw new WalletLoadError(error?.message, error); } let wallet: Salmon; try { wallet = new SalmonClass({ network: this._network }); } catch (error: any) { throw new WalletConfigError(error?.message, error); } if (!wallet.connected) { try { await wallet.connect(); } catch (error: any) { throw new WalletConnectionError(error?.message, error); } } if (!wallet.publicKey) throw new WalletAccountError(); let publicKey: PublicKey; try { publicKey = new PublicKey(wallet.publicKey.toBytes()); } catch (error: any) { throw new WalletPublicKeyError(error?.message, error); } wallet.on('disconnect', this._disconnected); this._wallet = wallet; this._publicKey = publicKey; this.emit('connect', publicKey); } catch (error: any) { this.emit('error', error); throw error; } finally { this._connecting = false; } } async disconnect(): Promise<void> { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); this._wallet = null; this._publicKey = null; try { await wallet.disconnect(); } catch (error: any) { this.emit('error', new WalletDisconnectionError(error?.message, error)); } } this.emit('disconnect'); } async signTransaction<T extends Transaction>(transaction: T): Promise<T> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return ((await wallet.signTransaction(transaction)) as T) || transaction; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return ((await wallet.signAllTransactions(transactions)) as T[]) || transactions; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signMessage(message: Uint8Array): Promise<Uint8Array> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return await wallet.signMessage(message, 'utf8'); } catch (error: any) { throw new WalletSignMessageError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } private _disconnected = () => { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); this._wallet = null; this._publicKey = null; this.emit('error', new WalletDisconnectedError()); this.emit('disconnect'); } }; }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/salmon/src/index.ts
export * from './adapter.js';
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/LICENSE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/tsconfig.esm.json
{ "extends": "../../../tsconfig.esm.json", "include": ["src"], "compilerOptions": { "outDir": "lib/esm", "declarationDir": "lib/types" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/package.json
{ "name": "@solana/wallet-adapter-spot", "version": "0.1.15", "author": "Solana Maintainers <maintainers@solana.foundation>", "repository": "https://github.com/anza-xyz/wallet-adapter", "license": "Apache-2.0", "publishConfig": { "access": "public" }, "files": [ "lib", "src", "LICENSE" ], "engines": { "node": ">=18" }, "type": "module", "sideEffects": false, "main": "./lib/cjs/index.js", "module": "./lib/esm/index.js", "types": "./lib/types/index.d.ts", "exports": { "require": "./lib/cjs/index.js", "import": "./lib/esm/index.js", "types": "./lib/types/index.d.ts" }, "scripts": { "build": "tsc --build --verbose && pnpm run package", "clean": "shx mkdir -p lib && shx rm -rf lib", "lint": "prettier --check 'src/{*,**/*}.{ts,tsx,js,jsx,json}' && eslint", "package": "shx mkdir -p lib/cjs && shx echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json" }, "peerDependencies": { "@solana/web3.js": "^1.77.3" }, "dependencies": { "@solana/wallet-adapter-base": "workspace:^" }, "devDependencies": { "@solana/web3.js": "^1.77.3", "shx": "^0.3.4" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/tsconfig.cjs.json
{ "extends": "../../../tsconfig.cjs.json", "include": ["src"], "compilerOptions": { "outDir": "lib/cjs" } }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/tsconfig.json
{ "extends": "../../../tsconfig.root.json", "references": [ { "path": "./tsconfig.cjs.json" }, { "path": "./tsconfig.esm.json" } ] }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/src/adapter.ts
import type { EventEmitter, WalletName } from '@solana/wallet-adapter-base'; import { BaseMessageSignerWalletAdapter, scopePollingDetectionStrategy, WalletAccountError, WalletConnectionError, WalletDisconnectedError, WalletDisconnectionError, WalletNotConnectedError, WalletNotReadyError, WalletPublicKeyError, WalletReadyState, WalletSignMessageError, WalletSignTransactionError, } from '@solana/wallet-adapter-base'; import type { Transaction } from '@solana/web3.js'; import { PublicKey } from '@solana/web3.js'; interface SpotWalletEvents { connect(...args: unknown[]): unknown; disconnect(...args: unknown[]): unknown; } interface SpotWallet extends EventEmitter<SpotWalletEvents> { publicKey?: { toBytes(): Uint8Array }; isConnected: boolean; signTransaction(transaction: Transaction): Promise<Transaction>; signAllTransactions(transactions: Transaction[]): Promise<Transaction[]>; signMessage(message: Uint8Array): Promise<{ signature: Uint8Array }>; connect(): Promise<void>; disconnect(): Promise<void>; } interface SpotWindow extends Window { spotSolWallet?: SpotWallet; } declare const window: SpotWindow; export interface SpotWalletAdapterConfig {} export const SpotWalletName = 'Spot' as WalletName<'Spot'>; export class SpotWalletAdapter extends BaseMessageSignerWalletAdapter { name = SpotWalletName; url = 'https://spot-wallet.com'; icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFYAAABWCAYAAABVVmH3AAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAVqADAAQAAAABAAAAVgAAAAA6XCzdAAAmhUlEQVR4Aa2dC8xmR3nf57yX79tdr9d3e218JQRwguKAcGMVtw0tqtQgimhap4oUxQ1JS6kaqZIVpVJFBVJviKYlEa6KQgIFkcShTiOD6AVCiG3VsY3bdc1N0GKvCWvA1/Xuer/L+779//7PPOfM++77re0kA/PNzDPPzJn5nec8Z86c86678qcIf2exGP+XY+WG2U65sXTltYtSrlE3lyteXBbloNKD3bxMu65MulkZS1bG81I60lnkRzV1ebeUicoj6UzJK1ouGeVxldFmgzxtV9Js4zrVU57MFrUfpeo7jk1+oWMtZpOy2O3mi51JmZ0YL7rny2L21HgxOzYu3WOjbvE1jeeBS99y3pFbbtEsXmboXo7+9NuLm2az8m7xeZvanb9nWykAc6REgCOvMnlPsE4SUBPlDbmCCiADOJepU1wCuwO4kAMs25FyjCivgBXQMbAXgJ0r5WQq1WDHi7lOPDLVqTwqtVwWz467xV2j8eL2X/gPh+/bc84rFS8J7OTbizfP5uV9Ot7NK+3XFwGrMCIFqCdQwSoPCEMGiGKCnSq/CsmAKljqsNi04N5ya30PGrAARJ5WK6gTwHIiBVMWa4gABWxn0JIvQzVgQ7Z8cc+0K+/52Q9f+QVP8Cx/zgr23G8vLjo5Lx/QSbz1LH2srxJAoKbV9nAlM0xNEFBEW64hBDQA2/KUTtMylSZY1yXM2i5PADrT3QAYfSgvGZc/YA3UECMvdyADmAVYDRmII8EmHWO1PeiwYkPuuo8e2hjf9rc+dOVT6ycf815bt3F08boTu+UhHePWtQovUQhfQpv2eZ1W8dXga1DG+SqwXl+ZSstpVpNm5GBcEZ0sImRKax6LTL3ID3VAXI70mfXZzifi1pPbWw/99ru++brl0QwlDOqMMHl88eM783KvKq52ZZI4Q/NFBMygDTkjpQsidVVGmZDyPGSm1GH14uOG5N2ElLNDqsgN0FdJ1bderQMuHYyATGqQ+FLy9Ic8rRSQRMphwekSkMudXD3fWdz7Wz//jR9X0zPCGWCxVN2gfl+ah5a0NaY/TaCZoQEy4SGjM8qKulJdN0eHvKLrSM8WrBiq+HMgurXzQBLkCtLgnEe/wlW6BNgA5ToMM6C6PXo1+mRU+F2ZHRrNZ79/5zu/coblLoHFp+7Mymc0umWoOTkPPAsvklaIaCVQDIuQAIFnGUCr/tJJqHIOu+7QrTVaQUpYb0Ju69NKDai3VgGT3zVodbAMcfC1fT3A7X8TOtY8OzQvi8/c+Y++epEnV/8sgT25U/6t5FfnIFvFPr9uhn3lS8gAkKgj05XWugFVKcCpQ94eps2rypUtNJTdVMD61DKVkSnaBahpWDD6A6R0Cb5xqTOD7AHiJsIVtIB9oqRLW938rh6d3vmAx1b/DGAfXbxZh//ZtpIBrw17ydcqV1AJrQGHddp6kVFPIM1owfKfrEp1ai3jjq98WitpQvTkDQALC1BO7Y+RYZ0BKfKABHCkkTdAQw6rzTpSn6RbP/1z//vNOdoBrNap9cRmXaR7QdxLvtw6Zt3I8tJv3QFk6M6gldpyKdeIVWfAUrOCfIBk0jqUOg8LXU2pB1TAHkBW0Krr/aotNWClpcYJCt3BFXAiKlROgtrpbvG+HGeA/dbiJtXdnEIAL4XVclbuJc/6Bkj6Ts8OuWJaKd2Q73VWymccpvbrblSZsNtywKBOkwcqEatWOay1gjFIoEcZwLZAl0N/pNvrcDJqO8kMVv3Gutfpzf/j5790E9MPsIvybgpt+HOD23Za8y2oHih1CVfZVqc2W0oSJkIDJTVAytkaYFEmHVzCmTLaAI+Quu7PfQVM6lMv3UOckGhLfjbfNUvVL3ii49k/ZsOY6rjWws0xu0H9s07W1tcuU43UUTPoZTXfy5ld6kW2/2uotdTDBKpk4R6wHi57rBUZ5QpHCrZgLLO31rBS5GmxUQfI0HMf5G2p9EU/UbaO6/S0Nl+8bXHHYjwp3yw3qHVsqNTJeMzMkMmSkl1TFzX1b9VfkmWBtrUfiyjTd43kU97LqqhPUkf9kA2AkZJ3bHxsQiVlY4Vo66rugMs4/KrgGVCFmyArKNqHVVbIPdCw0tZyw8Ln59/92ftumKjVjUuTzpkw+gYWgF8SXNonhOyrpkADgOFlnWSUc3WQ4gRM2gfGo2CIZIAlGc//YaFYabVI6iTvLVp3ttDD2gJ2AuutNGFmaqgAjzaG2J+EFbAcV3pY76IsbmQP4rWKy4HJIMuUWuXV1qEHnO3ayaORbck3fSAGVA+XPqss4c7l9XPFsIg7AL30wYdSI8PNVLVRFgTJAq5S9U4XeZNhJysuX2BhgboB9aBC1pdX5ByXzZqEFydF/UuPfJadX8xfO1H/16rNEgCX2z/0CgHPSlkmVPNWa+r6ZikjbUPTV2+V1Lf9kV8pZ3fZVfhNqWGZquxhYjmOQMQFhHX2Mk049lyXIQf8FbjSzZOS4OKERN+dDtyCDsCALtdONNDDYTZ1MkyohZHlTOvMUqUHvDpz9FKJfG3fq3ED1pZf0XagDKeMlD8g2T4pHFDcP1ZeVRtqN1V+U1GzKHPpL7QtuNhWWSltO+25JmD8ZUAfAOcNCCi2WoABnHKVoWOXILlh+iYVAAMmEKmLy90pJ1CyANpa7fwwFnuxhthP3Pl15awAEKESUt+D9SIjpE6Uhr/UA3FLp3Rayht15B8+V2dWp/dygTsHiFLhbBMzv5qy878lwCdOdeX/PbYof3zvonz/cU1MJ8a7W7bYeoevVmsoPYi6BtUk4tJnnZp54PE+KU6QYSvPhNs+EvASVGBYb3FxV76yOKZeD0syAEkwL5Y2bXrLdUdNX5Qr0OkLpbxFWxXvuERgIdcEDnU2mMBtAbd5jPnUC4vyrW8syh/9993yJ0d3y4ZgbMgnsrk9mSsljzUqDStt0/S1wAs/mv40rDSsEpjpU9NSB8DCx9WCTrd4oitfXjyvcR2UJAJp5pG05ZTvlaKeddlWUDtZ6Os3S/nFq0q5Agp7hL3AJtSEuaH2mSdt73ELWc2xb87LXf/phfLMk7vSm5WpJgzUyWJ3CSqwDVJ1aZlhlVhtxrBUuxdB8w3PKXKVdbzBagOsrqgTWOxp1WvaNSQY0nV51F5E3sPVFTSRlf7Dq/X2UZf8iwUA7QWxla/mczht/3NZ6tH7t8tnP3mizE4LMK+LsVYAc6nbctNSB7DIY8EfQMMX5yUOOHQrTEMdrLmH3HVbXfd/dCvopLs6uiyTtnlG35bbfM5MMvzdfkH9Z68q5UbuQi8h0FVaLVZJPq1zNQVu6ii7Z9g5OSuf/ZWnyrHHtnQjBEpADbhhlcjOsFRbMQBDJ60y9AbQZ1qtrXgGWLQiaGYsgZYC5ZS1aZunQaPn5c/pUt77A6X82MuACqiMq1YJZLwIMYGjexbPotoIeoVSHvzN75cv33dCcAVWEddgoL0bqHABKZn9aQM1AKZ11rR1A21eALruSAXbgGE4BpzwELT1KV8js0hLoXe9Qjep82i4d8A7XKhICkgC7RNgLO7DhyKnnIfEGjKv7NmDlBdyDY//t6fL3Xc8WTb0Wji+JBlcAZbYL8V6oAPksNgKvIWYeV0NMR6lOh5PXjFC0sxXEeUecNYzhXZGTRuqdFWVH5EpvWP9yx2r4NCvVTygeFLt79Ya9qunSnlct9GnT2qtqpudv4hRX/vlUja1TiUeVoPrdLKu1pm47lBXLuVq6B268utCHXenQV/91y8qbzq1XR749FO2Wix3WAVgwYAbYuwhhD9NKzZgWTQI0OUhARlPTXETjXKAXTegKqODDL2bqIN1742CXYCg/ONXqUUjz/akWKgWBwb6S8dKueNegRQ8P4pK7m8ABDQ/NdrQZRxRbkJXwsaWIGsNO92aaSmzKO/4K6PyN//yuBzUNlK3CjnH2aTXvO1wee7xk+XokeOGGzenAWb4UMANNy+7AZWXQDPZaq081RHSqpl61z3kWlf4TwLJFKE1Q6W34CgOddLpZHl/VV9u/fI1WbmcXqDitYpHBPLvfb6U7z2nscm6u3MEVr5gLB8w0Rj5oAOwmwK5ub0o+08LpvL7tFbdOKWo8lTp4oTSLX0ktj0vN71mVP7+uzbL5sGwG4xor7jQSfmf/+LL5fknTpapnih6q8VabY3Veis438AyXy00LLdaM9B9MHBEvuu+tAJW43FoYBoswka2DvBY1vrBHyrlNdxVVgKi6xW/Kqh/41N6GtVlvLhcsfrh/DpmU0AnssgNRaDuU5+A3SdLPaD0gODuF8wDp+eSa2kkwDP5k23FiQD/wk9ulje8fb+GqsHqWHvBnT1zuvzBLz8kf7sjy8UvhoXiDtIyfakDiptZAk3ACVApFk0IuOhLhkWzNHJdnmW0yKc805SpTJuM6JK/THNZB5XurlUUk/Izf6DtAcHcfbUOgQmrjf6/FDiMB+CKKOUa0Zcq315pskA4qO+ILtu/U645d6ucLx/xiU+dKHe+/2nfrOz0aK6xLc1PsvH5G+WGn7iEDy9009rVzUZrXR4g6vo2l2Vjye17gUtkuaYO2+gxSeYx1XElbFHWBDPmQOr8esjIs64ZMO3YUHmjHldhsQpKV3oh/pvvl3JMy7DZdSpw61c7msYfMsq2gihIWn1eBcoGRzxJ6e6ux1WAnNPtlKv3n1Z8oTz48AvlI7f9ScCtx1kat+BpJ6dc8teuLBN95RZ9xI0MwPH4C1DWvDxQAF7HcgQqcKkbIm1SHieAiawCkygt2VbpyTLrGlO/SfGvr2uWVy1cDFNXdfn43eJ/TeWoslZA/YmCIceU55RQQQLKHqTyXgpVqxmnlWkyPKYSp3MsbqdcNDldXn3gRHniia3yxV/5jlY16oS1HN2qXZFOxN3S7V+U173jGu2OAWiwWEAmJD9ICFBY6gASfXTsnz0ulm6UpevVBgdcjQks5SrnZU8ag2zSKrtixbem9bJOfVg6L+jOvdDqXuNw7K2otk+4XPYxJsEVfcNV6lcshiorVRowA+qGYGC5U6WHtDnxQ/ueK/c/cLx859O6TLifsdxIqD6wZLq2Dt58WZlqj3JUQSVQ0oAaMG2RaZUAzJOcIAUGvwrYXA8PFssE6ySX4CXgmqYVYwxEt9G4L+WRaE1gufk1uYA5pksbHcPtap4m9qGCx0Ke/gJm+C1/z8qkvEslC5V12lKxUsUNAZvOt8uGNmuJ5A9ob/L6zWfLb33su2Whx1ptFugoSh3ylOu4k1G54scuFwxAcsnLEskDWjGviP6yxwXUpzevgwXYT3FOq0VrAnVtUo8HJGICznRVtqJnwBrzecu9uVNcHNN4VA8ABFt89qsU69U4HTmu+6pw850V68T0e1NN2pYpmABdikX7AYst7SiF/DztAL1q85nyyG98Sx1rFFN8AqMhDHDPf/0VPpH2ocAELgB1LF/qFSSXuG9kGmje0Hp3IP3Y+eJ+AFgmmaDa1AevdeisRk5+tlUKsInGmsPN4QOW8IzWoUDUmMNwlOKXbUS8Aeijrloue31Cji+dyP9NZpqs0qnSqX74kJa5Kevc1KsEYBqo8lGWrES8anKifOmPvlfmz+lgkzzNOboY7eQH9Jgoo5iov7DQcAM89sYNC6CRT8uNfd2Qx6qAExFuAAuOVUECasEiy9jK2zz1AFacIl8JDDuN+IVqlZwA3B1fcYelAlWKmjeykV63dLsaIGCVTpRODTXAbgBWcXMmy9QlT9xX4xLUCnkqwD+48XR57sGn1LlG1DGiABrD1YpXbuLiH71SYxUcrJJIniirteXWNOWsTKI+YdY3FpKHxSaohLiaUp+yvXQl54lpXWAKBPGp4FRIS1U61k16pMdW3nmNlQJzzKfuyk92ZSX6rnSqdGM3gBqqNhNsrfPTSskr4gLaaLewrZvZdrlYVvvIXY8yDA20BZuj68o51x8OiHYDemioPjZWAyy5ADlE7gF5k0In3YBdh8pYrU9gHsIHb/8IGE9Zrt8DHupaRp412HcCtAl+QlHZ76l0+fPefyKoE8GdAlRxY0c3px1BFdhNxX27stBZxLBWyXQJ75O/3RSMWB1wQ6mXribpy/KYll56cuumAquTFmGY9eTwIVssAD1W+0fmrTb9mIFBOdtHfVZ7q6JWxSYM+lm7Rzp03ig0QrJNsVEKOb9WsU+tegw+vwGwexBUllCGWsFubAfYTcHdFFzAbgK1gQvkzXoT26wPC7yOiQU7l2csjS4ZH9fegtauF7Y3MIYZox5fcMD+FP2QBJGEmPNDCkAvCWtz5uKQqQqcoKUQnQ6i1fJQM+R80BexWLS53HMQtlYNBGudANQ3rGqtgFXcBOyWoG7LIok7Ferulqx2q+wHMtZaLXbDFhuXITcdL9l01kaKh3Tw+fHtMrpoFWzMo9P79Q4/qnYmq7EtW6vKhqEK19X5K9+aZfKahNlXpdXEjZaFhihRdpCmnjepZe1BD4C4C1/29KvoDyoMNFYCUzniDQHdkE/dlBvY3N4VTEXB3bctiNsCqrgpsI7cvOwCcANyF/KPLMfyxpILdu5ZY1HZfWarTF7Jw3U/+mG4G2NBZZkVlhYQGecAwUaRlpG9uDp1hn4NduidjpZKg4UtddTopP6K5TcaznK5s2vllQB+SmX/mE3t+ZHbRkYslQhYRcBisQEZq90p++UKsNa4cQmoLDafunADeZPBtxJteVoNzPkYgdBTi6L/ij5LKHayMqRaugOfkJxvr4RAKwvLh7YTJticBKub+2oH2RFp1inFUmV0AazVWcn7XgxYHSx+aqlUDblhGSowZbGGaovFr0YE7n7cQHUFmwK7AVhFL78E1k9fguqnIMMFKksfpg3ckVdblPYKI7mLEZdUzk+6CTfaeDMyslUnegPAcq8T+ulD32EvaQ4iWXZGP02epRY/r2xDHsdAVeFfDmpPlWWkgcqV+WMKWapdgFPeDgAYS424fxeoslSlEQMoKwLghrXKYnUZx0oglkT4VVsrY2WwXr+2Izwz36mNY1+lWdC0LzeZvYTSJ/SrApeqkLzBrSnTn8eJEgclKut1KHXIFTJl+4DnnX26/Kd6+sICOJn8WJgfKA9Q5wKny98xLNf+VUA3HVkRyDIz1t2siXxrQOVRFP/K8qpCZRyeiI6ZA5VsrxAno7U0aXoiOZthXtlHdJ/1FYYqeWrrLRHlOo6llGYpT5i2XsBXuJqPAeYh3EbV+RCJPx0LLFbkfLXQaVpqdQX7lAI4rBPQAqtHWcp+KFCeuz9bhN7dsqVqQV9vPN4Y0WDj8ldaB9RvR2pMa4P0eGJiod836hWjk/bvchUgFPqXgoDVhA2t1tVxWJbyHmpzMt2OziTjcl9okyUh0kdGZNSzwzWRKyCfLsBrVvlY+9XevwosrgDLFUTXsYOVj7Veq+rhQXBjs0R+UYPwpoigBBwuaR1Lg8j5cHOvU9QI9ghcSkzMofrTvlH2RGWbD+1oMsgnPJ870IEiEwckxQSbI2JBb52aUm8dxqIbU+4a0n3GBHuBNhNwBXyewyog44aetLhp7TNYYNZosJHfAKbkpLHLVe/8osX7Kj8EkCqydsVa+xuXB8h4ZLPDvDXCM4NPSn/TqcqeK3kyQxIzRBB6cWVIpx4kwAKobUS5yhKmx5dypViqdZCR181L63y99awnpx6SfolXard7Qy8G8XVsrHiJpct+Q3mvXQHbRlyDQG5w6avjaYWa61Tf/StIQ8RCgKr+e6vVccMSlMT8LXGeOawE37gAazgo1EaePMoq9+2yvhdEfdW1K0hlZG1Ebr118gRLqsi8jgvuZXqLwHCItn6lHPq6g3q3pLerYwnj9TarAcGuMA3YeWCGdfL0NZVVxjup+nSm3niwWPKh6tPjroONOh00J6ZcjgmpA4IMDJDQTtYtmLgUs96ZtidV9HXIs6C5AqTtz8ejHmAcSyn6HnibIgcoMqVsBT4rP8vrmTw0YImsxF6Dxer19EgNuGHFQwGXuNaxtk6sNy955auVYqnsIfg9lw4IVKzebxxINTg2xH0gJaTIcpJwQfesN68cMBMxDDWnj7Rc6h3cmXJKOQShB4+gKmIMAOnHoboeII3qcXysJm8LRRdZjSy3vvusXijqvVYC5TDked65SJlrL9K3q98VWIHCHdhKAah8+NCQBcwAyj5C/pzIT1KA1YB9QtUvx/B0GAdQc8KSO0g/IK1W1PomCU1OVg19Z/Uo7os6aVqJP+SVunv+uEInH4tVxHKJgPZGtEABK2PK8t9jIc06/xMhKh85EjewvGGREvW6S8fuyj/9mWmZ8hWLXtmyH8A/MbKhBwHy6WsDMpd9+GFbquFitdUNCKLnwzyIlDMy+ZRnquqYOJmzBTUQTN7stk37g6QVAdzQU4uzSkSuVGd9lEATqkEntIStMhvSCRCgLiNTJA/4B+9Xx5pYAs2Ucwjc1x/WB8h/aeJPglgN4AISJJvZWKpXAIYqsLoZ9daqfn35e07k1SGx/+2SHIDyRF/C1BEADXQlHQ5+ryCXZCX0rRywDFkHwyvYM9ggWx06VpNWrgPyeNzv7KcFJmSs0pZZAWd9As56Q9bAXhC9hx9XGx1nNQKWhdAv3jIuP3h4ZLiGab8qwIJpFwHUGvMdkm9WGj9YgGtQyhssiWeNQEHVwQYSlCMF+OiC/VZZ+0cnuTaI6oRlK1RH1Vqx5YQcKQehLScCPWUVB4uVPK3Xl326BKBWwMiBmoAHuaxUVruh3ZXfuQMfGGAzNWQdU17A23f/7r37y0+99Rw9ickitTfgF4aCyevt/tLXYt+vPmS18SpcjeUKcuwxF1koswtzMUTKEWOuBi2op6fnl/E1+mJPc1gXZs9ty13pGA5K03Lj7Eha6zwAIFaQS6DRkVyRx+MlcAmVdaktV6ktFNAVcAJdtVw2Y77+9VK+8ugyXG40+VCjvWsNqis/+bc3yq/96iXlLX/xUPXpGozcA98Q8G9g1fEpFaiZVqZK5/rZ4kxxt42zUdlReWc2VtSzmNLdXaU17ig9ObmwHPzgbfqGQCdBc1gXtr+jj3Mru75+tbxOoQctZeX95Y0O0131qzo1TJxO6knIkwEMP4jQhroaE1LUy4okZ1PFcj1dXbCxKB/5wEg/gmOPM/pwqkP0VqwMN1MCA5jp9wo7x+dl59Rc+6bqUP0JqdqTSld5+1hS5E5DbuuqfVnZnUpPLw67Q5ulu3yfVgxSACqRua6Exz98b7ni4d+THpNVZfaHXptfardXRbuOBRoQ6Fd5UoNGXmNfl2Xu0ugSZYkjwdA/V1eeeqaUD//mvPyTn9MeqC5N2gE0oZLSp4PGxophos2EiT712W/vXOv+PJI6D72sjauAPuGBvIbF89vl6fv/uLxC33K18h5o6p7BMSuyp1TQOhYgrTX3QNXGKwRSReslUGSC6jcAtHceyJKp7hztB/7Xz5Xyykt1yf8EW8wD2MznUDwRtVmaEOV1YS85uuvq1smy3wbu0Tu+XK4ayRrQb+RWTVYUXJ+dqqKtc33Wab6CM7MvxeJ0mfRrWuXTEr0yoCwdfDDv/fubmKyUR1Tvr9Z0qhEc3JiX//ix7fKpO3ndwaWr9oqrY2E8a6G44s/4Z+3Bmj5Vf+qB75ajX7yvXDA+FVdRsiHN2DeRoJdlpkk5nqIuwBmrgl1g2TqV+sZkQACM2Mq43AEckGWh1tWNx6nKgo4l75fpnyu4H/3t0+Xff3C7bOmr4z3B9gOvk2nLf9b8WeDOjp0q99z+ufLqze/pKKFoFwUrQjLDbaXMFU1dlp3WBt1iF7A7aaW+tNUJkHrQQESm6H8i1ADRqVB1B6eOZ39/FiTrzCXTOTLlQ4qfv2e7vPMfHC//6/5dLeBXRrhSXBrnyymcBeC6bk7e+0T53C/dWa7UT4kvHfGrVwUv3TR3zae/B1RWAXnlIFkXrdu/O931710cUyeH7UfVIR1kxwBL/+t/naKW7UuBzyVe/SswuYNzclh/+oMJUslniqe2dIfWIvzKS0blnX/3QPmRv6DHW36IsQp2tdwO92x16J2tvtbN9Qr8sU8+Ur5+98PlgunJ8sbNo97UscF6suqHlCCOZ/xjFLD1jcga8QdZw1w34ye6H/7ni28I5Kt8hgSFNgarNC3Vn1NSV+uBiU7AzLRaqtr5QzLB5JHU76EMeFZO7XZlW2vSkQAD/PpXTsrNb9xXrnrFpJx3mVYEh0ZlrLXmSDvmfKjmsXqOLLEUnI+58JdlVxuSR8q4OhZ6CJk/u1VeOPp8+c79j5ZvPfRNbV3Oy1XTZ8pr5ALYg+2hcBBDU78VlI0YH5YBuePysUMWSvKx32B360nN22AZGPAYL5aXgEkDsiyUY6psqMjV2FaLtdpiI/WXLerQj6WCyKuTC+UWOnW0pVGw+vm/j+2Uo4+ekO/V46xftdQ3BHo84ifxU8n9WaXK/hW3FqGctHxpyIcZ+fLQbxE0cL+iMWGNVQP1ulRy1syUL5xslesmT5ZLxic0T+BAiUlFQtbK1EnmrjRPA04dqVjQWi7tCOiU7ik2uo/Zn9KPOki45L04R6bIzhJ1RLb86JP63hUIMDr+WEIg/R5KEHoZ9dLHRZyjHW5ALgRZTex32fVnogEOoAGZN7D5LVa+4naZR15FwPqYau9jKmUtrc5Crsnt00+Ozh2dLpeNny/ndqfNjel7A8dwKjESPeEFBKV0Q1/6v5O8+yInpC7tCMiJo3KMt7SPGSgggVg74fJ3GblkRD4OTtiGWmEmYFsvsNV7As5Jx3M/EIAXEPjB8FTPzlMtO/LzoPj+ijexfIQRcuoiH1+8WBeZwQb4gEy/vGTkFQ3zU1mTw2pjH4BZQ0EpUJgUIocqd6I/nHFAYqo+UUrEgua933VbNxi6oMmiPMYDwtcMs4LlQD1U+nYULKDqYOgGSA1aeayQcr+9BzisxlYLZCyVCYeciXIC3I6JS97HelL4zMePsKoLP6oDEUj6eWTN4GlDS2VR5cZab/K1HUSkke0z7QUcoAqd6E+r31aL1dngjrruqxON4QE/GEh5sFbBq2UAcKYMto7Ll7fyvaUCB1hKgeofYzgPcEBGyiXqevR7qAE3HiICZF5xzC/nE3SqQAACosrKkAcmYNyDiSKNcir5t7a2xAotQZLSHJApo2yrriIlPhCQ9H/cp+G6HZVkCNSPHhy98sZyRLrPAs+Xui0zwNpCWcc2PpW1quV2FQFN/+pvAANivVHZauUn7R6wWoNEv0YNYIAbVluxaIjgGQL5KEeO6RPiNFSZYMIlZFFvk7WydEirCZtfHiHNWvP3UVLP7SRCTsxypmjDrCmj0y26Z8tbbjwy+l39xxPk5u6Km1AFqiO7DFQAqoGtE3mNWGK4gbDUkAuaAaZetWJgVhcQ9ehJp4lYbAs2EQXQYfRDbsCfp8GpFVRnC45eAmj0NMBrYCU4UgJ9ADwP5nyWM7WmoRtwLWoMd3W33KLNTAXtrt2e9A0RoOrUl6dBVsAVcvhHhsilDSDVOwaskAU8dADItAJkppItwYz+0CNkGqUz/+ach5raQhXUqesIaZGpmOWst5y22X6PI7vTrFPatidfT8qoG99OlwZ77691943m3T2GWV2Bb2BAVYOwWuXVQW9lttiAx40q7/SGSp0tV/q2Vtqiq0ifBq28riPbXQu4zVuvnYFGrGJKpFo16CXlmpLhpUyp5mDdbAhEN2gAZQeps1oPrSVZ07bWjWbdPd2vv/8+igZLRq9P3mMfq0HYUu1DAVOhqFPnJQ9LDqgBirt4dQkGmgBXZRywttMo4yTFCiCt2aBVN/iunCmjVHAxtNLGQ0MT5TQlMyvnH4RRn3BcxMqyAaoWKuWmRaeOTR6dpTbZLxUK4/F7ItOA/eKHuy/o1cpHmdCZfhWowAJKWCfvsXroyDSK3udyMlyWvjoM+MiGZRSyAWLkGXUiY1agIGQapZhv5jPlLUS0RlJ7XvKzapewUEmIyDiCU2UBR1gHPGpCN9tbVz3ov+bR/cb7v5AqvcVasH90myZ81Je8/SmWU8FUWGFZyAAdsNLyAjqyqGd6fZ1023J8YxXwKgbpBpIcHDMw1Jz0UOGce1Rd2nxW929t+8nXU5Pltj/yLifcTJHvkedAtKmWrd2No+WcjdsQZ1gC+/kPdU9tTsZv1T7BcUMTjLDCAJQW2ddpSnlpUxcLe6ZZ5V4J8CEw7ZFFP0yTvEH75ESewVKXJ4C8BaR9sNQl86gtEEQvUZ9vatGJKLkyy9BrX7683WX8aYGmW6Cmlbus4S2643rmfmv3oX+lnz4OYQks4s98pHtEl/nbVdHDHaDgBgTHMBIgT1/KK+IOWlgBsroM1Q2A08bQH2Cm5dbpepRcMYEm/lIK9KEVc+VU1jLacgGh5wINFLLXmgK5l6naDVSXDVuIe+R1mONaU729+8gHHvEhmj9ngKXu05+Y/qE+x3yTDnM0rcyXPo+pmmi/2NcoDFUp8NPS3Kb3rcijrgXH9FzmpKh9ljk++ZhhztKCpT/JwVbkGrwsIVrX3qtsgNicp/CneQjS7DRl2Zfr1G/KBVr/O1q6jTd1n/jXf8hRV8NasCj93sc3Hzlvsu8NUvhY+tmcfIKgMfm0TPK2aKWrukN5mHLIEkW24ehtnvJyyPkhHfLtEbIHNJBnyHymyJv80Fk0aMvOS1epoH5MG8dv6D7+L8+w1NUjZXlt+tM//fyb9QXE+wTw5nALuQogxT3ErhVWTZm9SH4z5f1S11V53eLLrb7cGnSb1GfHyvnYEvTea9aRKvI7g9w6ZMOcL7n5bJ7jMT6njIVxVBkLBAwgnUa/wS05BiFfFnMPaxnKcK91+jbhHk3sPd0nh7v/WmA02atinfzWn3rqJp2ydwvg2zT48w2SidbB+zFXeX++XmGkjMnm1l6fao8BecJLef5WCzkAV/doAZvt/O2syj459cTRj68cyQGbvj/g8jsFJq47Vr1e+0+LAEhllQNUxWeV3iXZ7d3vxOJ/HZtV2csCm43v0L/z/8X//OQNi9nOjdpLfa1uXNdq7XtYm7sXa916UFZ1UL54Oul29Tuyuf6bAAE1Jt8AlrWF9VZLlB5vDfItAfr+50nzBPhkDRDjhKCvWK04QHIMrhrkabWCpNlSb/fln8foVyOjbkf8TmhHRa8yFk/KZz8hpUcVv6bGD5T5jx7pfvcWPeS/vPD/AUg2fXs/C6zNAAAAAElFTkSuQmCC'; readonly supportedTransactionVersions = null; private _connecting: boolean; private _wallet: SpotWallet | null; private _publicKey: PublicKey | null; private _readyState: WalletReadyState = typeof window === 'undefined' || typeof document === 'undefined' ? WalletReadyState.Unsupported : WalletReadyState.NotDetected; constructor(config: SpotWalletAdapterConfig = {}) { super(); this._connecting = false; this._wallet = null; this._publicKey = null; if (this._readyState !== WalletReadyState.Unsupported) { scopePollingDetectionStrategy(() => { if (window.spotSolWallet) { this._readyState = WalletReadyState.Installed; this.emit('readyStateChange', this._readyState); return true; } return false; }); } } get publicKey() { return this._publicKey; } get connecting() { return this._connecting; } get connected() { return !!this._wallet?.isConnected; } get readyState() { return this._readyState; } async connect(): Promise<void> { try { if (this.connected || this.connecting) return; if (this._readyState !== WalletReadyState.Installed) throw new WalletNotReadyError(); this._connecting = true; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const wallet = window.spotSolWallet!; try { await wallet.connect(); } catch (error: any) { throw new WalletConnectionError(error?.message, error); } if (!wallet.publicKey) throw new WalletAccountError(); let publicKey: PublicKey; try { publicKey = new PublicKey(wallet.publicKey.toBytes()); } catch (error: any) { throw new WalletPublicKeyError(error?.message, error); } wallet.on('disconnect', this._disconnected); this._wallet = wallet; this._publicKey = publicKey; this.emit('connect', publicKey); } catch (error: any) { this.emit('error', error); throw error; } finally { this._connecting = false; } } async disconnect(): Promise<void> { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); this._wallet = null; this._publicKey = null; try { await wallet.disconnect(); } catch (error: any) { this.emit('error', new WalletDisconnectionError(error?.message, error)); } } this.emit('disconnect'); } async signTransaction<T extends Transaction>(transaction: T): Promise<T> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signTransaction(transaction)) as T; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signAllTransactions<T extends Transaction>(transactions: T[]): Promise<T[]> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { return (await wallet.signAllTransactions(transactions)) as T[]; } catch (error: any) { throw new WalletSignTransactionError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } async signMessage(message: Uint8Array): Promise<Uint8Array> { try { const wallet = this._wallet; if (!wallet) throw new WalletNotConnectedError(); try { const { signature } = await wallet.signMessage(message); return signature; } catch (error: any) { throw new WalletSignMessageError(error?.message, error); } } catch (error: any) { this.emit('error', error); throw error; } } private _disconnected = () => { const wallet = this._wallet; if (wallet) { wallet.off('disconnect', this._disconnected); this._wallet = null; this._publicKey = null; this.emit('error', new WalletDisconnectedError()); this.emit('disconnect'); } }; }
0
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot
solana_public_repos/anza-xyz/wallet-adapter/packages/wallets/spot/src/index.ts
export * from './adapter.js';
0
solana_public_repos/solana-playground
solana_public_repos/solana-playground/solana-playground/LICENSE-APACHE
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "{}" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2022 Solana Playground Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
0
solana_public_repos/solana-playground
solana_public_repos/solana-playground/solana-playground/LICENSE-GPL
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/licenses/why-not-lgpl.html>.
0
solana_public_repos/solana-playground
solana_public_repos/solana-playground/solana-playground/supported-packages.json
{ "global": { "@coral-xyz/anchor": { "as": "anchor" }, "@solana/buffer-layout": { "as": "BufferLayout" }, "@solana/web3.js": { "as": "web3" }, "assert": { "default": "assert" }, "bn.js": { "default": "BN" }, "borsh": { "as": "borsh" }, "buffer": { "named": "Buffer" }, "mocha": { "as": "mocha" } }, "importable": [ "@clockwork-xyz/sdk", "@coral-xyz/anchor", "@metaplex-foundation/js", "@metaplex-foundation/mpl-bubblegum", "@metaplex-foundation/mpl-token-metadata", "@project-serum/anchor", "@solana/buffer-layout", "@solana/spl-account-compression", "@solana/spl-token", "@solana/spl-token-metadata", "@solana/web3.js", "assert", "bn.js", "borsh", "buffer", "mocha" ] }
0
solana_public_repos/solana-playground
solana_public_repos/solana-playground/solana-playground/supported-crates.json
{ "anchor-lang": "0.29.0", "anchor-spl": "0.29.0", "arrayref": "0.3.7", "borsh": "0.10.3", "borsh-derive": "0.10.3", "bytemuck": "1.14.0", "bytemuck_derive": "1.5.0", "mpl-bubblegum": "1.0.0", "mpl-token-auth-rules": "1.4.3", "mpl-token-metadata": "3.2.3", "num-derive": "0.4.0", "num-traits": "0.2.16", "pyth-sdk": "0.8.0", "pyth-sdk-solana": "0.8.0", "serde": "1.0.193", "solana-program": "1.16.24", "spl-account-compression": "0.2.0", "spl-associated-token-account": "2.2.0", "spl-pod": "0.1.0", "spl-tlv-account-resolution": "0.4.0", "spl-token": "4.0.0", "spl-token-2022": "0.9.0", "spl-token-metadata-interface": "0.2.0", "spl-transfer-hook-interface": "0.3.0", "spl-type-length-value": "0.3.0", "switchboard-solana": "0.29.79", "switchboard-v2": "0.4.0", "thiserror": "1.0.48" }
0
solana_public_repos/solana-playground/solana-playground
solana_public_repos/solana-playground/solana-playground/wasm/Cargo.toml
[workspace] members = [ "anchor-cli", "seahorse-compile", "solana-cli", "solana-client", "spl-token-cli", "sugar-cli", "utils/*", ] exclude = ["playnet", "rust-analyzer"] resolver = "2"
0
solana_public_repos/solana-playground/solana-playground
solana_public_repos/solana-playground/solana-playground/wasm/Cargo.lock
# This file is automatically @generated by Cargo. # It is not intended for manual editing. version = 3 [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" [[package]] name = "ahash" version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" dependencies = [ "getrandom 0.2.10", "once_cell", "version_check", ] [[package]] name = "ahash" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2c99f64d1e06488f620f932677e24bc6e2897582980441ae90a671415bd7ec2f" dependencies = [ "cfg-if", "once_cell", "version_check", ] [[package]] name = "aho-corasick" version = "0.7.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" dependencies = [ "memchr", ] [[package]] name = "anchor-attribute-access-control" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5f619f1d04f53621925ba8a2e633ba5a6081f2ae14758cbb67f38fd823e0a3e" dependencies = [ "anchor-syn", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "anchor-attribute-account" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e7f2a3e1df4685f18d12a943a9f2a7456305401af21a07c9fe076ef9ecd6e400" dependencies = [ "anchor-syn", "bs58 0.5.0", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "anchor-attribute-constant" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9423945cb55627f0b30903288e78baf6f62c6c8ab28fb344b6b25f1ffee3dca7" dependencies = [ "anchor-syn", "quote", "syn 1.0.107", ] [[package]] name = "anchor-attribute-error" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93ed12720033cc3c3bf3cfa293349c2275cd5ab99936e33dd4bf283aaad3e241" dependencies = [ "anchor-syn", "quote", "syn 1.0.107", ] [[package]] name = "anchor-attribute-event" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eef4dc0371eba2d8c8b54794b0b0eb786a234a559b77593d6f80825b6d2c77a2" dependencies = [ "anchor-syn", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "anchor-attribute-program" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b18c4f191331e078d4a6a080954d1576241c29c56638783322a18d308ab27e4f" dependencies = [ "anchor-syn", "quote", "syn 1.0.107", ] [[package]] name = "anchor-cli-wasm" version = "0.29.0" dependencies = [ "anchor-lang", "anchor-syn", "anyhow", "clap", "console", "console_error_panic_hook", "flate2", "serde", "serde_derive", "serde_json", "solana-client-wasm", "solana-playground-utils-wasm", "solana-sdk", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "anchor-derive-accounts" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5de10d6e9620d3bcea56c56151cad83c5992f50d5960b3a9bebc4a50390ddc3c" dependencies = [ "anchor-syn", "quote", "syn 1.0.107", ] [[package]] name = "anchor-derive-serde" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4e2e5be518ec6053d90a2a7f26843dbee607583c779e6c8395951b9739bdfbe" dependencies = [ "anchor-syn", "borsh-derive-internal 0.10.3", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "anchor-derive-space" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1ecc31d19fa54840e74b7a979d44bcea49d70459de846088a1d71e87ba53c419" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "anchor-lang" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35da4785497388af0553586d55ebdc08054a8b1724720ef2749d313494f2b8ad" dependencies = [ "anchor-attribute-access-control", "anchor-attribute-account", "anchor-attribute-constant", "anchor-attribute-error", "anchor-attribute-event", "anchor-attribute-program", "anchor-derive-accounts", "anchor-derive-serde", "anchor-derive-space", "arrayref", "base64 0.13.0", "bincode", "borsh 0.10.3", "bytemuck", "getrandom 0.2.10", "solana-program", "thiserror", ] [[package]] name = "anchor-syn" version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9101b84702fed2ea57bd22992f75065da5648017135b844283a2f6d74f27825" dependencies = [ "anyhow", "bs58 0.5.0", "heck 0.3.3", "proc-macro2", "quote", "serde", "serde_json", "sha2 0.10.8", "syn 1.0.107", "thiserror", ] [[package]] name = "android-tzdata" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" [[package]] name = "android_system_properties" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" dependencies = [ "libc", ] [[package]] name = "anyhow" version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" [[package]] name = "ark-bn254" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a22f4561524cd949590d78d7d4c5df8f592430d221f7f3c9497bbafd8972120f" dependencies = [ "ark-ec", "ark-ff", "ark-std", ] [[package]] name = "ark-ec" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "defd9a439d56ac24968cca0571f598a61bc8c55f71d50a89cda591cb750670ba" dependencies = [ "ark-ff", "ark-poly", "ark-serialize", "ark-std", "derivative", "hashbrown 0.13.2", "itertools 0.10.5", "num-traits", "zeroize", ] [[package]] name = "ark-ff" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec847af850f44ad29048935519032c33da8aa03340876d351dfab5660d2966ba" dependencies = [ "ark-ff-asm", "ark-ff-macros", "ark-serialize", "ark-std", "derivative", "digest 0.10.7", "itertools 0.10.5", "num-bigint 0.4.4", "num-traits", "paste", "rustc_version", "zeroize", ] [[package]] name = "ark-ff-asm" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed4aa4fe255d0bc6d79373f7e31d2ea147bcf486cba1be5ba7ea85abdb92348" dependencies = [ "quote", "syn 1.0.107", ] [[package]] name = "ark-ff-macros" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7abe79b0e4288889c4574159ab790824d0033b9fdcb2a112a3182fac2e514565" dependencies = [ "num-bigint 0.4.4", "num-traits", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "ark-poly" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d320bfc44ee185d899ccbadfa8bc31aab923ce1558716e1997a1e74057fe86bf" dependencies = [ "ark-ff", "ark-serialize", "ark-std", "derivative", "hashbrown 0.13.2", ] [[package]] name = "ark-serialize" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adb7b85a02b83d2f22f89bd5cac66c9c89474240cb6207cb1efc16d098e822a5" dependencies = [ "ark-serialize-derive", "ark-std", "digest 0.10.7", "num-bigint 0.4.4", ] [[package]] name = "ark-serialize-derive" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae3281bc6d0fd7e549af32b52511e1302185bd688fd3359fa36423346ff682ea" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "ark-std" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94893f1e0c6eeab764ade8dc4c0db24caf4fe7cbbaafc0eba0a9030f447b5185" dependencies = [ "num-traits", "rand 0.8.5", ] [[package]] name = "arrayref" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" [[package]] name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" [[package]] name = "arrayvec" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" [[package]] name = "ascii-canvas" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff8eb72df928aafb99fe5d37b383f2fe25bd2a765e3e5f7c365916b6f2463a29" dependencies = [ "term", ] [[package]] name = "assert_matches" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b34d609dfbaf33d6889b2b7106d3ca345eacad44200913df5ba02bfd31d2ba9" [[package]] name = "atty" version = "0.2.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", "winapi", ] [[package]] name = "autocfg" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0dde43e75fd43e8a1bf86103336bc699aa8d17ad1be60c76c0bdfd4828e19b78" dependencies = [ "autocfg 1.1.0", ] [[package]] name = "autocfg" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base58" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6107fe1be6682a68940da878d9e9f5e90ca5745b3dec9fd1bb393c8777d4f581" [[package]] name = "base64" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" [[package]] name = "base64" version = "0.21.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567" [[package]] name = "base64" version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" [[package]] name = "bincode" version = "1.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" dependencies = [ "serde", ] [[package]] name = "bit-set" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" dependencies = [ "bit-vec", ] [[package]] name = "bit-vec" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" [[package]] name = "bitflags" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf" dependencies = [ "serde", ] [[package]] name = "bitmaps" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "031043d04099746d8db04daf1fa424b2bc8bd69d92b25962dcde24da39ab64a2" dependencies = [ "typenum", ] [[package]] name = "blake2b_simd" version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afa748e348ad3be8263be728124b24a24f268266f6f5d58af9d75f6a40b5c587" dependencies = [ "arrayref", "arrayvec 0.5.2", "constant_time_eq 0.1.5", ] [[package]] name = "blake3" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0231f06152bf547e9c2b5194f247cd97aacf6dcd8b15d8e5ec0663f64580da87" dependencies = [ "arrayref", "arrayvec 0.7.4", "cc", "cfg-if", "constant_time_eq 0.3.0", "digest 0.10.7", ] [[package]] name = "block-buffer" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0940dc441f31689269e10ac70eb1002a3a1d3ad1390e030043662eb7fe4688b" dependencies = [ "block-padding", "byte-tools", "byteorder", "generic-array 0.12.4", ] [[package]] name = "block-buffer" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" dependencies = [ "generic-array 0.14.7", ] [[package]] name = "block-buffer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71" dependencies = [ "generic-array 0.14.7", ] [[package]] name = "block-padding" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa79dedbb091f449f1f39e53edf88d5dbe95f895dae6135a8d7b881fb5af73f5" dependencies = [ "byte-tools", ] [[package]] name = "borsh" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" dependencies = [ "borsh-derive 0.9.3", "hashbrown 0.11.2", ] [[package]] name = "borsh" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4114279215a005bc675e386011e594e1d9b800918cea18fcadadcce864a2046b" dependencies = [ "borsh-derive 0.10.3", "hashbrown 0.13.2", ] [[package]] name = "borsh" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f58b559fd6448c6e2fd0adb5720cd98a2506594cafa4737ff98c396f3e82f667" dependencies = [ "borsh-derive 1.3.1", "cfg_aliases", ] [[package]] name = "borsh-derive" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" dependencies = [ "borsh-derive-internal 0.9.3", "borsh-schema-derive-internal 0.9.3", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.107", ] [[package]] name = "borsh-derive" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0754613691538d51f329cce9af41d7b7ca150bc973056f1156611489475f54f7" dependencies = [ "borsh-derive-internal 0.10.3", "borsh-schema-derive-internal 0.10.3", "proc-macro-crate 0.1.5", "proc-macro2", "syn 1.0.107", ] [[package]] name = "borsh-derive" version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7aadb5b6ccbd078890f6d7003694e33816e6b784358f18e15e7e6d9f065a57cd" dependencies = [ "once_cell", "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.52", "syn_derive", ] [[package]] name = "borsh-derive-internal" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "borsh-derive-internal" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "afb438156919598d2c7bad7e1c0adf3d26ed3840dbc010db1a882a65583ca2fb" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "borsh-schema-derive-internal" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "borsh-schema-derive-internal" version = "0.10.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "634205cc43f74a1b9046ef87c4540ebda95696ec0f315024860cad7c5b0f5ccd" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "bs58" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3" [[package]] name = "bs58" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f5353f36341f7451062466f0b755b96ac3a9547e4d7f6b70d603fc721a7d7896" dependencies = [ "tinyvec", ] [[package]] name = "bumpalo" version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "bv" version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8834bb1d8ee5dc048ee3124f2c7c1afcc6bc9aed03f11e9dfd8c69470a5db340" dependencies = [ "feature-probe", "serde", ] [[package]] name = "byte-tools" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7" [[package]] name = "bytemuck" version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6" dependencies = [ "bytemuck_derive", ] [[package]] name = "bytemuck_derive" version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdde5c9cd29ebd706ce1b35600920a33550e402fc998a2e53ad3b42c3c47a192" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "byteorder" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" [[package]] name = "cc" version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" dependencies = [ "jobserver", "libc", ] [[package]] name = "cfg-if" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "cfg_aliases" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" [[package]] name = "chrono" version = "0.4.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "serde", "wasm-bindgen", "windows-targets 0.48.1", ] [[package]] name = "clap" version = "3.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83" dependencies = [ "atty", "bitflags 1.3.2", "clap_derive", "clap_lex", "indexmap 1.9.1", "once_cell", "strsim", "termcolor", "textwrap", ] [[package]] name = "clap_derive" version = "3.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902" dependencies = [ "heck 0.4.0", "proc-macro-error", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "clap_lex" version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" dependencies = [ "os_str_bytes", ] [[package]] name = "cloudabi" version = "0.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "combine" version = "4.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" dependencies = [ "bytes", "memchr", ] [[package]] name = "console" version = "0.15.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e1f83fc076bd6dd27517eacdf25fef6c4dfe5f1d7448bafaaf3a26f13b5e4eb" dependencies = [ "encode_unicode", "lazy_static", "libc", "unicode-width", "windows-sys 0.52.0", ] [[package]] name = "console_error_panic_hook" version = "0.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc" dependencies = [ "cfg-if", "wasm-bindgen", ] [[package]] name = "console_log" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89f72f65e8501878b8a004d5a1afb780987e2ce2b4532c562e367a72c57499f" dependencies = [ "log", "web-sys", ] [[package]] name = "const_format" version = "0.2.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "939dc9e2eb9077e0679d2ce32de1ded8531779360b003b4a972a7a39ec263495" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef196d5d972878a48da7decb7686eded338b4858fbabeed513d63a7c98b2b82d" dependencies = [ "proc-macro2", "quote", "unicode-xid 0.2.3", ] [[package]] name = "constant_time_eq" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" [[package]] name = "constant_time_eq" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7144d30dcf0fafbce74250a3963025d8d52177934239851c917d29f1df280c2" [[package]] name = "core-foundation-sys" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" [[package]] name = "cpufeatures" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59a6001667ab124aebae2a495118e11d30984c3a653e99d86d58971708cf5e4b" dependencies = [ "libc", ] [[package]] name = "crc32fast" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" dependencies = [ "cfg-if", ] [[package]] name = "crossbeam-channel" version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c02a4d71819009c192cf4872265391563fd6a84c81ff2c0f2a7026ca4c1d85c" dependencies = [ "cfg-if", "crossbeam-utils", ] [[package]] name = "crossbeam-deque" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if", "crossbeam-epoch", "crossbeam-utils", ] [[package]] name = "crossbeam-epoch" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07db9d94cbd326813772c968ccd25999e5f8ae22f4f8d1b11effa37ef6ce281d" dependencies = [ "autocfg 1.1.0", "cfg-if", "crossbeam-utils", "memoffset 0.6.5", "once_cell", "scopeguard", ] [[package]] name = "crossbeam-utils" version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d82ee10ce34d7bc12c2122495e7593a9c41347ecdd64185af4ecf72cb1a7f83" dependencies = [ "cfg-if", "once_cell", ] [[package]] name = "crunchy" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "crypto-common" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5999502d32b9c48d492abe66392408144895020ec4709e549e840799f3bb74c0" dependencies = [ "generic-array 0.14.7", "typenum", ] [[package]] name = "crypto-mac" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" dependencies = [ "generic-array 0.14.7", "subtle", ] [[package]] name = "curve25519-dalek" version = "3.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90f9d052967f590a76e62eb387bd0bbb1b000182c3cefe5364db6b7211651bc0" dependencies = [ "byteorder", "digest 0.9.0", "rand_core 0.5.1", "serde", "subtle", "zeroize", ] [[package]] name = "darling" version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0558d22a7b463ed0241e993f76f09f30b126687447751a8638587b864e4b3944" dependencies = [ "darling_core", "darling_macro", ] [[package]] name = "darling_core" version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab8bfa2e259f8ee1ce5e97824a3c55ec4404a0d772ca7fa96bf19f0752a046eb" dependencies = [ "fnv", "ident_case", "proc-macro2", "quote", "strsim", "syn 2.0.52", ] [[package]] name = "darling_macro" version = "0.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29a358ff9f12ec09c3e61fef9b5a9902623a695a46a917b07f269bff1445611a" dependencies = [ "darling_core", "quote", "syn 2.0.52", ] [[package]] name = "deranged" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" dependencies = [ "powerfmt", "serde", ] [[package]] name = "derivation-path" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e5c37193a1db1d8ed868c03ec7b152175f26160a5b740e5e484143877e0adf0" [[package]] name = "derivative" version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "dialoguer" version = "0.10.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "59c6f2989294b9a498d3ad5491a79c6deb604617378e1cdc4bfc1c1361fe2f87" dependencies = [ "console", "shell-words", "tempfile", "zeroize", ] [[package]] name = "diff" version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56254986775e3233ffa9c4d7d3faaf6d36a2c09d30b20687e9f88bc8bafc16c8" [[package]] name = "digest" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ "generic-array 0.12.4", ] [[package]] name = "digest" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" dependencies = [ "generic-array 0.14.7", ] [[package]] name = "digest" version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer 0.10.4", "crypto-common", "subtle", ] [[package]] name = "dirs" version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fd78930633bd1c6e35c4b42b1df7b0cbc6bc191146e512bb3bedf243fcc3901" dependencies = [ "libc", "redox_users 0.3.5", "winapi", ] [[package]] name = "dirs-next" version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" dependencies = [ "cfg-if", "dirs-sys-next", ] [[package]] name = "dirs-sys-next" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users 0.4.3", "winapi", ] [[package]] name = "docopt" version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f3f119846c823f9eafcf953a8f6ffb6ed69bf6240883261a7f13b634579a51f" dependencies = [ "lazy_static", "regex", "serde", "strsim", ] [[package]] name = "ed25519" version = "1.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e9c280362032ea4203659fc489832d0204ef09f247a0506f170dafcac08c369" dependencies = [ "signature", ] [[package]] name = "ed25519-dalek" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c762bae6dcaf24c4c84667b8579785430908723d5c889f469d76a41d59cc7a9d" dependencies = [ "curve25519-dalek", "ed25519", "rand 0.7.3", "serde", "sha2 0.9.9", "zeroize", ] [[package]] name = "ed25519-dalek-bip32" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d2be62a4061b872c8c0873ee4fc6f101ce7b889d039f019c5fa2af471a59908" dependencies = [ "derivation-path", "ed25519-dalek", "hmac 0.12.1", "sha2 0.10.8", ] [[package]] name = "either" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "ena" version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8944dc8fa28ce4a38f778bd46bf7d923fe73eed5a439398507246c8e017e6f36" dependencies = [ "log", ] [[package]] name = "encode_unicode" version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "env_logger" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" dependencies = [ "atty", "humantime", "log", "regex", "termcolor", ] [[package]] name = "equivalent" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fastrand" version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3fcf0cee53519c866c09b5de1f6c56ff9d647101f81c1964fa632e148896cdf" dependencies = [ "instant", ] [[package]] name = "feature-probe" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "835a3dc7d1ec9e75e2b5fb4ba75396837112d2060b03f7d43bc1897c7f7211da" [[package]] name = "fixedbitset" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "86d4de0081402f5e88cdac65c8dcdcc73118c1a7a465e2a05f0da05843a8ea33" [[package]] name = "flate2" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", "miniz_oxide", ] [[package]] name = "fluvio-wasm-timer" version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b768c170dc045fa587a8f948c91f9bcfb87f774930477c6215addf54317f137f" dependencies = [ "futures", "js-sys", "parking_lot 0.11.2", "pin-utils", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", ] [[package]] name = "fnv" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" dependencies = [ "matches", "percent-encoding", ] [[package]] name = "fuchsia-cprng" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" [[package]] name = "futures" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" dependencies = [ "futures-channel", "futures-core", "futures-executor", "futures-io", "futures-sink", "futures-task", "futures-util", ] [[package]] name = "futures-channel" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", "futures-sink", ] [[package]] name = "futures-core" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-executor" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9420b90cfa29e327d0429f19be13e7ddb68fa1cccb09d65e5706b8c7a749b8a6" dependencies = [ "futures-core", "futures-task", "futures-util", ] [[package]] name = "futures-io" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-macro" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "futures-sink" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-channel", "futures-core", "futures-io", "futures-macro", "futures-sink", "futures-task", "memchr", "pin-project-lite", "pin-utils", "slab", ] [[package]] name = "generic-array" version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" dependencies = [ "typenum", ] [[package]] name = "generic-array" version = "0.14.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a" dependencies = [ "serde", "typenum", "version_check", ] [[package]] name = "getrandom" version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" dependencies = [ "cfg-if", "js-sys", "libc", "wasi 0.9.0+wasi-snapshot-preview1", "wasm-bindgen", ] [[package]] name = "getrandom" version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4136b2a15dd319360be1c07d9933517ccf0be8f16bf62a3bee4f0d618df427" dependencies = [ "cfg-if", "js-sys", "libc", "wasi 0.11.0+wasi-snapshot-preview1", "wasm-bindgen", ] [[package]] name = "gloo-net" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06f627b1a58ca3d42b45d6104bf1e1a03799df472df00988b6ba21accc10580" dependencies = [ "futures-channel", "futures-core", "futures-sink", "gloo-utils", "http", "js-sys", "pin-project", "serde", "serde_json", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", "web-sys", ] [[package]] name = "gloo-timers" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbb143cf96099802033e0d4f4963b19fd2e0b728bcf076cd9cf7f6634f092994" dependencies = [ "futures-channel", "futures-core", "js-sys", "wasm-bindgen", ] [[package]] name = "gloo-utils" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b5555354113b18c547c1d3a98fbf7fb32a9ff4f6fa112ce823a21641a0ba3aa" dependencies = [ "js-sys", "serde", "serde_json", "wasm-bindgen", "web-sys", ] [[package]] name = "hashbrown" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" dependencies = [ "ahash 0.7.6", ] [[package]] name = "hashbrown" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db0d4cf898abf0081f964436dc980e96670a0f36863e4b83aaacdb65c9d7ccc3" [[package]] name = "hashbrown" version = "0.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43a3c133739dddd0d2990f9a4bdf8eb4b21ef50e4851ca85ab661199821d510e" dependencies = [ "ahash 0.8.3", ] [[package]] name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" [[package]] name = "heck" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" dependencies = [ "unicode-segmentation", ] [[package]] name = "heck" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" [[package]] name = "hermit-abi" version = "0.1.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" dependencies = [ "libc", ] [[package]] name = "hex" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" [[package]] name = "hmac" version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" dependencies = [ "crypto-mac", "digest 0.9.0", ] [[package]] name = "hmac" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e" dependencies = [ "digest 0.10.7", ] [[package]] name = "hmac-drbg" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17ea0a1394df5b6574da6e0c1ade9e78868c9fb0a4e5ef4428e32da4676b85b1" dependencies = [ "digest 0.9.0", "generic-array 0.14.7", "hmac 0.8.1", ] [[package]] name = "home" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2456aef2e6b6a9784192ae780c0f15bc57df0e918585282325e8c8ac27737654" dependencies = [ "winapi", ] [[package]] name = "http" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" dependencies = [ "bytes", "fnv", "itoa", ] [[package]] name = "humantime" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "iana-time-zone" version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fad5b825842d2b38bd206f3e81d6957625fd7f0a361e345c30e01a0ae2dd613" dependencies = [ "android_system_properties", "core-foundation-sys", "iana-time-zone-haiku", "js-sys", "wasm-bindgen", "windows", ] [[package]] name = "iana-time-zone-haiku" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" dependencies = [ "cc", ] [[package]] name = "ident_case" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" [[package]] name = "idna" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" dependencies = [ "matches", "unicode-bidi", "unicode-normalization", ] [[package]] name = "im" version = "15.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0acd33ff0285af998aaf9b57342af478078f53492322fafc47450e09397e0e9" dependencies = [ "bitmaps", "rand_core 0.6.4", "rand_xoshiro", "rayon", "serde", "sized-chunks", "typenum", "version_check", ] [[package]] name = "indexmap" version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg 1.1.0", "hashbrown 0.12.1", "serde", ] [[package]] name = "indexmap" version = "2.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0b929d511467233429c45a44ac1dcaa21ba0f5ba11e4879e6ed28ddb4f9df4" dependencies = [ "equivalent", "hashbrown 0.14.3", "serde", ] [[package]] name = "instant" version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" dependencies = [ "cfg-if", "js-sys", "wasm-bindgen", "web-sys", ] [[package]] name = "itertools" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" dependencies = [ "either", ] [[package]] name = "itertools" version = "0.10.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" dependencies = [ "either", ] [[package]] name = "itoa" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "jobserver" version = "0.1.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "068b1ee6743e4d11fb9c6a1e6064b3693a1b600e7f5f5988047d98b3dc9fb90b" dependencies = [ "libc", ] [[package]] name = "js-sys" version = "0.3.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" dependencies = [ "wasm-bindgen", ] [[package]] name = "keccak" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f9b7d56ba4a8344d6be9729995e6b06f928af29998cdf79fe390cbf6b1fee838" [[package]] name = "lalrpop" version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "64dc3698e75d452867d9bd86f4a723f452ce9d01fe1d55990b79f0c790aa67db" dependencies = [ "ascii-canvas", "atty", "bit-set", "diff", "docopt", "ena", "itertools 0.8.2", "lalrpop-util", "petgraph", "regex", "regex-syntax", "serde", "serde_derive", "sha2 0.8.2", "string_cache", "term", "unicode-xid 0.1.0", ] [[package]] name = "lalrpop-util" version = "0.17.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c277d18683b36349ab5cd030158b54856fca6bb2d5dc5263b06288f486958b7c" [[package]] name = "lazy_static" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "libsecp256k1" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c9d220bc1feda2ac231cb78c3d26f27676b8cf82c96971f7aeef3d0cf2797c73" dependencies = [ "arrayref", "base64 0.12.3", "digest 0.9.0", "hmac-drbg", "libsecp256k1-core", "libsecp256k1-gen-ecmult", "libsecp256k1-gen-genmult", "rand 0.7.3", "serde", "sha2 0.9.9", "typenum", ] [[package]] name = "libsecp256k1-core" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f6ab710cec28cef759c5f18671a27dae2a5f952cdaaee1d8e2908cb2478a80" dependencies = [ "crunchy", "digest 0.9.0", "subtle", ] [[package]] name = "libsecp256k1-gen-ecmult" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ccab96b584d38fac86a83f07e659f0deafd0253dc096dab5a36d53efe653c5c3" dependencies = [ "libsecp256k1-core", ] [[package]] name = "libsecp256k1-gen-genmult" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67abfe149395e3aa1c48a2beb32b068e2334402df8181f818d3aee2b304c4f5d" dependencies = [ "libsecp256k1-core", ] [[package]] name = "light-poseidon" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c9a85a9752c549ceb7578064b4ed891179d20acd85f27318573b64d2d7ee7ee" dependencies = [ "ark-bn254", "ark-ff", "num-bigint 0.4.4", "thiserror", ] [[package]] name = "linked-hash-map" version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "lock_api" version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "327fa5b6a6940e4699ec49a9beae1ea4845c6bab9314e4f84ac68742139d8c53" dependencies = [ "autocfg 1.1.0", "scopeguard", ] [[package]] name = "log" version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" [[package]] name = "maplit" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" [[package]] name = "matches" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "memmap2" version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83faa42c0a078c393f6b29d5db232d8be22776a891f8f56e5284faee4a20b327" dependencies = [ "libc", ] [[package]] name = "memoffset" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" dependencies = [ "autocfg 1.1.0", ] [[package]] name = "memoffset" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5a634b1c61a95585bd15607c6ab0c4e5b226e695ff2800ba0cdccddf208c406c" dependencies = [ "autocfg 1.1.0", ] [[package]] name = "miniz_oxide" version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" dependencies = [ "adler", ] [[package]] name = "new_debug_unreachable" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" [[package]] name = "num-bigint" version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "090c7f9998ee0ff65aa5b723e4009f7b217707f1fb5ea551329cc4d6231fb304" dependencies = [ "autocfg 1.1.0", "num-integer", "num-traits", ] [[package]] name = "num-bigint" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "608e7659b5c3d7cba262d894801b9ec9d00de989e8a82bd4bef91d08da45cdc0" dependencies = [ "autocfg 1.1.0", "num-integer", "num-traits", ] [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" [[package]] name = "num-derive" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "876a53fff98e03a936a674b29568b0e605f06b29372c2489ff4de23f1949743d" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "num-derive" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "num-integer" version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" dependencies = [ "autocfg 1.1.0", "num-traits", ] [[package]] name = "num-traits" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" dependencies = [ "autocfg 1.1.0", ] [[package]] name = "num_cpus" version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ "hermit-abi", "libc", ] [[package]] name = "num_enum" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cf5395665662ef45796a4ff5486c5d41d29e0c09640af4c5f17fd94ee2c119c9" dependencies = [ "num_enum_derive 0.5.7", ] [[package]] name = "num_enum" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02339744ee7253741199f897151b38e72257d13802d4ee837285cc2990a90845" dependencies = [ "num_enum_derive 0.7.2", ] [[package]] name = "num_enum_derive" version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b0498641e53dd6ac1a4f22547548caa6864cc4933784319cd1775271c5a46ce" dependencies = [ "proc-macro-crate 1.1.3", "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "num_enum_derive" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "681030a937600a36906c185595136d26abfebb4aa9c65701cefcaf8578bb982b" dependencies = [ "proc-macro-crate 3.1.0", "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "once_cell" version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "opaque-debug" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2839e79665f131bdb5782e51f2c6c9599c133c6098982a54c794358bf432529c" [[package]] name = "opaque-debug" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "ordermap" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a86ed3f5f244b372d6b1a00b72ef7f8876d0bc6a78a4c9985c53614041512063" [[package]] name = "os_str_bytes" version = "6.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "21326818e99cfe6ce1e524c2a805c189a99b5ae555a35d19f9a284b427d86afa" [[package]] name = "owo-colors" version = "3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b" [[package]] name = "parking_lot" version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" dependencies = [ "instant", "lock_api", "parking_lot_core 0.8.5", ] [[package]] name = "parking_lot" version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f" dependencies = [ "lock_api", "parking_lot_core 0.9.3", ] [[package]] name = "parking_lot_core" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" dependencies = [ "cfg-if", "instant", "libc", "redox_syscall 0.2.13", "smallvec", "winapi", ] [[package]] name = "parking_lot_core" version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09a279cbf25cb0757810394fbc1e359949b59e348145c643a939a525692e6929" dependencies = [ "cfg-if", "libc", "redox_syscall 0.2.13", "smallvec", "windows-sys 0.36.1", ] [[package]] name = "paste" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" [[package]] name = "pbkdf2" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "216eaa586a190f0a738f2f918511eecfa90f13295abec0e457cdebcceda80cbd" dependencies = [ "crypto-mac", ] [[package]] name = "pbkdf2" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "83a0692ec44e4cf1ef28ca317f14f8f07da2d95ec3fa01f86e4467b725e60917" dependencies = [ "digest 0.10.7", ] [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pest" version = "2.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69486e2b8c2d2aeb9762db7b4e00b0331156393555cff467f4163ff06821eef8" dependencies = [ "thiserror", "ucd-trie", ] [[package]] name = "petgraph" version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c3659d1ee90221741f65dd128d9998311b0e40c5d3c23a62445938214abce4f" dependencies = [ "fixedbitset", "ordermap", ] [[package]] name = "phf_generator" version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09364cc93c159b8b06b1f4dd8a4398984503483891b0c26b867cf431fb132662" dependencies = [ "phf_shared", "rand 0.6.5", ] [[package]] name = "phf_shared" version = "0.7.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "234f71a15de2288bcb7e3b6515828d22af7ec8598ee6d24c3b526fa0a80b67a0" dependencies = [ "siphasher 0.2.3", ] [[package]] name = "pin-project" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "pin-project-lite" version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "powerfmt" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "ppv-lite86" version = "0.2.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" [[package]] name = "precomputed-hash" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" [[package]] name = "pretty-hex" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa0831dd7cc608c38a5e323422a0077678fa5744aa2be4ad91c4ece8eec8d5" [[package]] name = "proc-macro-crate" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" dependencies = [ "toml", ] [[package]] name = "proc-macro-crate" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e17d47ce914bf4de440332250b0edd23ce48c005f59fab39d3335866b114f11a" dependencies = [ "thiserror", "toml", ] [[package]] name = "proc-macro-crate" version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" dependencies = [ "toml_edit 0.21.1", ] [[package]] name = "proc-macro-error" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", "proc-macro2", "quote", "syn 1.0.107", "version_check", ] [[package]] name = "proc-macro-error-attr" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ "proc-macro2", "quote", "version_check", ] [[package]] name = "proc-macro2" version = "1.0.78" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2422ad645d89c99f8f3e6b88a9fdeca7fabeac836b1002371c4367c8f984aae" dependencies = [ "unicode-ident", ] [[package]] name = "qstring" version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d464fae65fff2680baf48019211ce37aaec0c78e9264c84a3e484717f965104e" dependencies = [ "percent-encoding", ] [[package]] name = "qualifier_attr" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e2e25ee72f5b24d773cae88422baddefff7714f97aab68d96fe2b6fc4a28fb2" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "quote" version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef" dependencies = [ "proc-macro2", ] [[package]] name = "rand" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d71dacdc3c88c1fde3885a3be3fbab9f35724e6ce99467f7d9c5026132184ca" dependencies = [ "autocfg 0.1.8", "libc", "rand_chacha 0.1.1", "rand_core 0.4.2", "rand_hc 0.1.0", "rand_isaac", "rand_jitter", "rand_os", "rand_pcg", "rand_xorshift", "winapi", ] [[package]] name = "rand" version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" dependencies = [ "getrandom 0.1.16", "libc", "rand_chacha 0.2.2", "rand_core 0.5.1", "rand_hc 0.2.0", ] [[package]] name = "rand" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" dependencies = [ "libc", "rand_chacha 0.3.1", "rand_core 0.6.4", ] [[package]] name = "rand_chacha" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "556d3a1ca6600bfcbab7c7c91ccb085ac7fbbcd70e008a98742e7847f4f7bcef" dependencies = [ "autocfg 0.1.8", "rand_core 0.3.1", ] [[package]] name = "rand_chacha" version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" dependencies = [ "ppv-lite86", "rand_core 0.5.1", ] [[package]] name = "rand_chacha" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", "rand_core 0.6.4", ] [[package]] name = "rand_core" version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" dependencies = [ "rand_core 0.4.2", ] [[package]] name = "rand_core" version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" [[package]] name = "rand_core" version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" dependencies = [ "getrandom 0.1.16", ] [[package]] name = "rand_core" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" dependencies = [ "getrandom 0.2.10", ] [[package]] name = "rand_hc" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4" dependencies = [ "rand_core 0.3.1", ] [[package]] name = "rand_hc" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" dependencies = [ "rand_core 0.5.1", ] [[package]] name = "rand_isaac" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08" dependencies = [ "rand_core 0.3.1", ] [[package]] name = "rand_jitter" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1166d5c91dc97b88d1decc3285bb0a99ed84b05cfd0bc2341bdf2d43fc41e39b" dependencies = [ "libc", "rand_core 0.4.2", "winapi", ] [[package]] name = "rand_os" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b75f676a1e053fc562eafbb47838d67c84801e38fc1ba459e8f180deabd5071" dependencies = [ "cloudabi", "fuchsia-cprng", "libc", "rand_core 0.4.2", "rdrand", "winapi", ] [[package]] name = "rand_pcg" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abf9b09b01790cfe0364f52bf32995ea3c39f4d2dd011eac241d2914146d0b44" dependencies = [ "autocfg 0.1.8", "rand_core 0.4.2", ] [[package]] name = "rand_xorshift" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cbf7e9e623549b0e21f6e97cf8ecf247c1a8fd2e8a992ae265314300b2455d5c" dependencies = [ "rand_core 0.3.1", ] [[package]] name = "rand_xoshiro" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f97cdb2a36ed4183de61b2f824cc45c9f1037f28afe0a322e9fff4c108b5aaa" dependencies = [ "rand_core 0.6.4", ] [[package]] name = "rayon" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd99e5772ead8baa5215278c9b15bf92087709e9c1b2d1f97cdb5a183c933a7d" dependencies = [ "autocfg 1.1.0", "crossbeam-deque", "either", "rayon-core", ] [[package]] name = "rayon-core" version = "1.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "258bcdb5ac6dad48491bb2992db6b7cf74878b0384908af124823d118c99683f" dependencies = [ "crossbeam-channel", "crossbeam-deque", "crossbeam-utils", "num_cpus", ] [[package]] name = "rdrand" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" dependencies = [ "rand_core 0.3.1", ] [[package]] name = "redox_syscall" version = "0.1.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" [[package]] name = "redox_syscall" version = "0.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "62f25bc4c7e55e0b0b7a1d43fb893f4fa1361d0abe38b9ce4f323c2adfe6ef42" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "redox_users" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "de0737333e7a9502c789a36d7c7fa6092a49895d4faa31ca5df163857ded2e9d" dependencies = [ "getrandom 0.1.16", "redox_syscall 0.1.57", "rust-argon2", ] [[package]] name = "redox_users" version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom 0.2.10", "redox_syscall 0.2.13", "thiserror", ] [[package]] name = "regex" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ "winapi", ] [[package]] name = "rpassword" version = "6.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bf099a1888612545b683d2661a1940089f6c2e5a8e38979b2159da876bfd956" dependencies = [ "libc", "serde", "serde_json", "winapi", ] [[package]] name = "rust-argon2" version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4b18820d944b33caa75a71378964ac46f58517c92b6ae5f762636247c09e78fb" dependencies = [ "base64 0.13.0", "blake2b_simd", "constant_time_eq 0.1.5", "crossbeam-utils", ] [[package]] name = "rustc-hash" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ "semver 1.0.22", ] [[package]] name = "rustfmt-wrapper" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed729e3bee08ec2befd593c27e90ca9fdd25efdc83c94c3b82eaef16e4f7406e" dependencies = [ "serde", "tempfile", "thiserror", "toml", "toolchain_find", ] [[package]] name = "rustpython-parser" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d85b1038ecd8791bdae455ae784b48f522ebeca1b3323d0af2b251c5c8ff1c68" dependencies = [ "lalrpop", "lalrpop-util", "log", "num-bigint 0.2.6", "num-traits", "unic-emoji-char", "unic-ucd-ident", "unicode_names2", ] [[package]] name = "rustversion" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryu" version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "same-file" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" dependencies = [ "winapi-util", ] [[package]] name = "scoped-tls" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "seahorse-compile-wasm" version = "0.2.0" dependencies = [ "console_error_panic_hook", "seahorse-dev", "solana-playground-utils-wasm", "wasm-bindgen", ] [[package]] name = "seahorse-dev" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d3af486d9927b4e2b6cc7abb53d796c61a11255b70fdf07c6c144311904411a4" dependencies = [ "base58", "clap", "heck 0.4.0", "owo-colors", "proc-macro2", "quote", "regex", "rustfmt-wrapper", "rustpython-parser", "spinners", "toml_edit 0.14.4", ] [[package]] name = "semver" version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" dependencies = [ "semver-parser", ] [[package]] name = "semver" version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "92d43fe69e652f3df9bdc2b85b2854a0825b86e4fb76bc44d945137d053639ca" [[package]] name = "semver-parser" version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" dependencies = [ "pest", ] [[package]] name = "serde" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" dependencies = [ "serde_derive", ] [[package]] name = "serde_bytes" version = "0.11.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b8497c313fd43ab992087548117643f6fcd935cbf36f176ffda0aacf9591734" dependencies = [ "serde", ] [[package]] name = "serde_derive" version = "1.0.197" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "serde_json" version = "1.0.114" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c5f09b1bd632ef549eaa9f60a1f8de742bdbc698e6cee2095fc84dde5f549ae0" dependencies = [ "itoa", "ryu", "serde", ] [[package]] name = "serde_tuple" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f025b91216f15a2a32aa39669329a475733590a015835d1783549a56d09427" dependencies = [ "serde", "serde_tuple_macros", ] [[package]] name = "serde_tuple_macros" version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4076151d1a2b688e25aaf236997933c66e18b870d0369f8b248b8ab2be630d7e" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", ] [[package]] name = "serde_with" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07ff71d2c147a7b57362cead5e22f772cd52f6ab31cfcd9edcd7f6aeb2a0afbe" dependencies = [ "serde", "serde_with_macros 2.3.3", ] [[package]] name = "serde_with" version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "69cecfa94848272156ea67b2b1a53f20fc7bc638c4a46d2f8abde08f05f4b857" dependencies = [ "base64 0.22.1", "chrono", "hex", "indexmap 1.9.1", "indexmap 2.2.5", "serde", "serde_derive", "serde_json", "serde_with_macros 3.9.0", "time", ] [[package]] name = "serde_with_macros" version = "2.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "881b6f881b17d13214e5d494c939ebab463d01264ce1811e9d4ac3a882e7695f" dependencies = [ "darling", "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "serde_with_macros" version = "3.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8fee4991ef4f274617a51ad4af30519438dacb2f56ac773b08a1922ff743350" dependencies = [ "darling", "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "serde_yaml" version = "0.8.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707d15895415db6628332b737c838b88c598522e4dc70647e59b72312924aebc" dependencies = [ "indexmap 1.9.1", "ryu", "serde", "yaml-rust", ] [[package]] name = "sha2" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a256f46ea78a0c0d9ff00077504903ac881a1dafdc20da66545699e7776b3e69" dependencies = [ "block-buffer 0.7.3", "digest 0.8.1", "fake-simd", "opaque-debug 0.2.3", ] [[package]] name = "sha2" version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4d58a1e1bf39749807d89cf2d98ac2dfa0ff1cb3faa38fbb64dd88ac8013d800" dependencies = [ "block-buffer 0.9.0", "cfg-if", "cpufeatures", "digest 0.9.0", "opaque-debug 0.3.0", ] [[package]] name = "sha2" version = "0.10.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" dependencies = [ "cfg-if", "cpufeatures", "digest 0.10.7", ] [[package]] name = "sha3" version = "0.10.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bdf0c33fae925bdc080598b84bc15c55e7b9a4a43b3c704da051f977469691c9" dependencies = [ "digest 0.10.7", "keccak", ] [[package]] name = "shell-words" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" [[package]] name = "signature" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f054c6c1a6e95179d6f23ed974060dcefb2d9388bb7256900badad682c499de4" [[package]] name = "siphasher" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b8de496cf83d4ed58b6be86c3a275b8602f6ffe98d3024a869e124147a9a3ac" [[package]] name = "siphasher" version = "0.3.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d" [[package]] name = "sized-chunks" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16d69225bde7a69b235da73377861095455d298f2b970996eec25ddbb42b3d1e" dependencies = [ "bitmaps", "typenum", ] [[package]] name = "slab" version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eb703cfe953bccee95685111adeedb76fabe4e97549a58d16f03ea7b9367bb32" [[package]] name = "smallvec" version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2fd0db749597d91ff862fd1d55ea87f7855a744a8425a64695b6fca237d1dad1" [[package]] name = "solana-clap-v3-utils-wasm" version = "1.11.0" dependencies = [ "chrono", "clap", "rpassword", "solana-remote-wallet", "solana-sdk", "thiserror", "tiny-bip39", "uriparse", "url", ] [[package]] name = "solana-cli-config-wasm" version = "1.11.0" dependencies = [ "dirs-next", "lazy_static", "serde", "serde_derive", "serde_yaml", "solana-clap-v3-utils-wasm", "solana-sdk", "url", ] [[package]] name = "solana-cli-output-wasm" version = "1.11.0" dependencies = [ "base64 0.13.0", "chrono", "clap", "console", "humantime", "pretty-hex", "semver 1.0.22", "serde", "serde_derive", "serde_json", "solana-clap-v3-utils-wasm", "solana-cli-config-wasm", "solana-client-wasm", "solana-extra-wasm", "solana-sdk", ] [[package]] name = "solana-cli-wasm" version = "1.11.0" dependencies = [ "bs58 0.4.0", "clap", "console", "console_error_panic_hook", "const_format", "num-traits", "semver 1.0.22", "serde", "serde_derive", "serde_json", "solana-clap-v3-utils-wasm", "solana-cli-config-wasm", "solana-cli-output-wasm", "solana-client-wasm", "solana-extra-wasm", "solana-playground-utils-wasm", "solana-remote-wallet", "solana-sdk", "solana-version", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "solana-client-wasm" version = "1.18.0" dependencies = [ "base64 0.13.0", "bincode", "bs58 0.4.0", "futures", "gloo-net", "gloo-timers", "http", "serde", "serde_derive", "serde_json", "serde_tuple", "serde_with 3.9.0", "solana-extra-wasm", "solana-sdk", "thiserror", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test", "web-sys", ] [[package]] name = "solana-extra-wasm" version = "1.18.0" dependencies = [ "arrayref", "assert_matches", "base64 0.13.0", "bincode", "borsh 0.10.3", "bs58 0.4.0", "bytemuck", "fluvio-wasm-timer", "log", "num-derive 0.3.3", "num-traits", "num_enum 0.5.7", "rustc_version", "serde", "serde_derive", "serde_json", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-sdk", "thiserror", ] [[package]] name = "solana-frozen-abi" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0e608aeeb42922e803589258af0028e2c9e70fbfb04e1f1ff6c5f07019c2af95" dependencies = [ "block-buffer 0.10.4", "bs58 0.4.0", "bv", "either", "generic-array 0.14.7", "im", "lazy_static", "log", "memmap2", "rustc_version", "serde", "serde_bytes", "serde_derive", "sha2 0.10.8", "solana-frozen-abi-macro", "subtle", "thiserror", ] [[package]] name = "solana-frozen-abi-macro" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1cc7a55ad8a177287f3abb1be371b2a252d4c474d71c2e3983a7dff7db15d3f2" dependencies = [ "proc-macro2", "quote", "rustc_version", "syn 2.0.52", ] [[package]] name = "solana-logger" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2f507f00c12d7309475fde8bfc58502ed87bd4024769760223cc9c03dd5aa53" dependencies = [ "env_logger", "lazy_static", "log", ] [[package]] name = "solana-playground-utils-wasm" version = "0.1.0" dependencies = [ "wasm-bindgen", ] [[package]] name = "solana-program" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91fad730d66a6f33ef5bb180def74a3d84e7487b829a8f67ff58570332481f6c" dependencies = [ "ark-bn254", "ark-ec", "ark-ff", "ark-serialize", "base64 0.21.7", "bincode", "bitflags 2.4.2", "blake3", "borsh 0.10.3", "borsh 0.9.3", "borsh 1.3.1", "bs58 0.4.0", "bv", "bytemuck", "cc", "console_error_panic_hook", "console_log", "curve25519-dalek", "getrandom 0.2.10", "itertools 0.10.5", "js-sys", "lazy_static", "libc", "libsecp256k1", "light-poseidon", "log", "memoffset 0.9.0", "num-bigint 0.4.4", "num-derive 0.4.2", "num-traits", "parking_lot 0.12.1", "rand 0.8.5", "rustc_version", "rustversion", "serde", "serde_bytes", "serde_derive", "serde_json", "sha2 0.10.8", "sha3", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-sdk-macro", "thiserror", "tiny-bip39", "wasm-bindgen", "zeroize", ] [[package]] name = "solana-remote-wallet" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed53b5cf416c93a9f233ee95c6c2242941de8a606230262a16ca650b2bc519d5" dependencies = [ "console", "dialoguer", "log", "num-derive 0.4.2", "num-traits", "parking_lot 0.12.1", "qstring", "semver 1.0.22", "solana-sdk", "thiserror", "uriparse", ] [[package]] name = "solana-sdk" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d3612d0b4c2120c2a4cef6bac8af469908575319249e1a5c0de5a487fb7610f" dependencies = [ "assert_matches", "base64 0.21.7", "bincode", "bitflags 2.4.2", "borsh 1.3.1", "bs58 0.4.0", "bytemuck", "byteorder", "chrono", "derivation-path", "digest 0.10.7", "ed25519-dalek", "ed25519-dalek-bip32", "generic-array 0.14.7", "hmac 0.12.1", "itertools 0.10.5", "js-sys", "lazy_static", "libsecp256k1", "log", "memmap2", "num-derive 0.4.2", "num-traits", "num_enum 0.7.2", "pbkdf2 0.11.0", "qstring", "qualifier_attr", "rand 0.7.3", "rand 0.8.5", "rustc_version", "rustversion", "serde", "serde_bytes", "serde_derive", "serde_json", "serde_with 2.3.3", "sha2 0.10.8", "sha3", "siphasher 0.3.11", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-logger", "solana-program", "solana-sdk-macro", "thiserror", "uriparse", "wasm-bindgen", ] [[package]] name = "solana-sdk-macro" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df952c230e35ba179882cef765655b171b8f99f512f04fc4a84800fa43cfe592" dependencies = [ "bs58 0.4.0", "proc-macro2", "quote", "rustversion", "syn 2.0.52", ] [[package]] name = "solana-version" version = "1.18.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "30194d1b6a9311f9d92e68fd4355e075169fbc19794e3cef19b45829fa83c0bd" dependencies = [ "log", "rustc_version", "semver 1.0.22", "serde", "serde_derive", "solana-frozen-abi", "solana-frozen-abi-macro", "solana-sdk", ] [[package]] name = "spinners" version = "4.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08615eea740067d9899969bc2891c68a19c315cb1f66640af9a9ecb91b13bcab" dependencies = [ "lazy_static", "maplit", "strum", ] [[package]] name = "spl-token-cli-wasm" version = "2.0.15" dependencies = [ "clap", "console", "console_error_panic_hook", "serde", "serde_derive", "serde_json", "solana-clap-v3-utils-wasm", "solana-cli-config-wasm", "solana-cli-output-wasm", "solana-client-wasm", "solana-extra-wasm", "solana-playground-utils-wasm", "solana-remote-wallet", "solana-sdk", "strum", "strum_macros", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "string_cache" version = "0.7.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89c058a82f9fd69b1becf8c274f412281038877c553182f1d02eb027045a2d67" dependencies = [ "lazy_static", "new_debug_unreachable", "phf_shared", "precomputed-hash", "serde", "string_cache_codegen", "string_cache_shared", ] [[package]] name = "string_cache_codegen" version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f45ed1b65bf9a4bf2f7b7dc59212d1926e9eaf00fa998988e420fd124467c6" dependencies = [ "phf_generator", "phf_shared", "proc-macro2", "quote", "string_cache_shared", ] [[package]] name = "string_cache_shared" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1884d1bc09741d466d9b14e6d37ac89d6909cbcac41dd9ae982d4d063bbedfc" [[package]] name = "strsim" version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "strum" version = "0.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" dependencies = [ "strum_macros", ] [[package]] name = "strum_macros" version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4faebde00e8ff94316c01800f9054fd2ba77d30d9e922541913051d1d978918b" dependencies = [ "heck 0.4.0", "proc-macro2", "quote", "rustversion", "syn 1.0.107", ] [[package]] name = "subtle" version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" [[package]] name = "sugar-cli-wasm" version = "1.1.0-alpha+CMv3" dependencies = [ "clap", "js-sys", "solana-playground-utils-wasm", "wasm-bindgen", "wasm-bindgen-futures", ] [[package]] name = "syn" version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn" version = "2.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b699d15b36d1f02c3e7c69f8ffef53de37aefae075d8488d4ba1a7788d574a07" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] [[package]] name = "syn_derive" version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1329189c02ff984e9736652b1631330da25eaa6bc639089ed4915d25446cbe7b" dependencies = [ "proc-macro-error", "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "synstructure" version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f36bdaa60a83aca3921b5259d5400cbf5e90fc51931376a9bd4a0eb79aa7210f" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", "unicode-xid 0.2.3", ] [[package]] name = "tempfile" version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", "fastrand", "libc", "redox_syscall 0.2.13", "remove_dir_all", "winapi", ] [[package]] name = "term" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edd106a334b7657c10b7c540a0106114feadeb4dc314513e97df481d5d966f42" dependencies = [ "byteorder", "dirs", "winapi", ] [[package]] name = "termcolor" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] [[package]] name = "textwrap" version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" [[package]] name = "thiserror" version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1e45bcbe8ed29775f228095caf2cd67af7a4ccf756ebff23a306bf3e8b47b24b" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" version = "1.0.57" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a953cb265bef375dae3de6663da4d3804eee9682ea80d8e2542529b73c531c81" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "time" version = "0.3.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5dfd88e563464686c916c7e46e623e520ddc6d79fa6641390f2e3fa86e83e885" dependencies = [ "deranged", "itoa", "num-conv", "powerfmt", "serde", "time-core", "time-macros", ] [[package]] name = "time-core" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" [[package]] name = "time-macros" version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f252a68540fde3a3877aeea552b832b40ab9a69e318efd078774a01ddee1ccf" dependencies = [ "num-conv", "time-core", ] [[package]] name = "tiny-bip39" version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ffc59cb9dfc85bb312c3a78fd6aa8a8582e310b0fa885d5bb877f6dcc601839d" dependencies = [ "anyhow", "hmac 0.8.1", "once_cell", "pbkdf2 0.4.0", "rand 0.7.3", "rustc-hash", "sha2 0.9.9", "thiserror", "unicode-normalization", "wasm-bindgen", "zeroize", ] [[package]] name = "tinyvec" version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] [[package]] name = "tinyvec_macros" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "toml" version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] [[package]] name = "toml_datetime" version = "0.6.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" [[package]] name = "toml_edit" version = "0.14.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5376256e44f2443f8896ac012507c19a012df0fe8758b55246ae51a2279db51f" dependencies = [ "combine", "indexmap 1.9.1", "itertools 0.10.5", ] [[package]] name = "toml_edit" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" dependencies = [ "indexmap 2.2.5", "toml_datetime", "winnow", ] [[package]] name = "toolchain_find" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e85654a10e7a07a47c6f19d93818f3f343e22927f2fa280c84f7c8042743413" dependencies = [ "home", "lazy_static", "regex", "semver 0.11.0", "walkdir", ] [[package]] name = "typenum" version = "1.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" [[package]] name = "ucd-trie" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "89570599c4fe5585de2b388aab47e99f7fa4e9238a1399f707a02e356058141c" [[package]] name = "unic-char-property" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a8c57a407d9b6fa02b4795eb81c5b6652060a15a7903ea981f3d723e6c0be221" dependencies = [ "unic-char-range", ] [[package]] name = "unic-char-range" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0398022d5f700414f6b899e10b8348231abf9173fa93144cbc1a43b9793c1fbc" [[package]] name = "unic-common" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "80d7ff825a6a654ee85a63e80f92f054f904f21e7d12da4e22f9834a4aaa35bc" [[package]] name = "unic-emoji-char" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b07221e68897210270a38bde4babb655869637af0f69407f96053a34f76494d" dependencies = [ "unic-char-property", "unic-char-range", "unic-ucd-version", ] [[package]] name = "unic-ucd-ident" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e230a37c0381caa9219d67cf063aa3a375ffed5bf541a452db16e744bdab6987" dependencies = [ "unic-char-property", "unic-char-range", "unic-ucd-version", ] [[package]] name = "unic-ucd-version" version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96bd2f2237fe450fcd0a1d2f5f4e91711124f7857ba2e964247776ebeeb7b0c4" dependencies = [ "unic-common", ] [[package]] name = "unicode-bidi" version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" [[package]] name = "unicode-ident" version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c" [[package]] name = "unicode-normalization" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" dependencies = [ "tinyvec", ] [[package]] name = "unicode-segmentation" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" [[package]] name = "unicode-width" version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" [[package]] name = "unicode-xid" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" [[package]] name = "unicode-xid" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04" [[package]] name = "unicode_names2" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87d6678d7916394abad0d4b19df4d3802e1fd84abd7d701f39b75ee71b9e8cf1" [[package]] name = "uriparse" version = "0.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0200d0fc04d809396c2ad43f3c95da3582a2556eba8d453c1087f4120ee352ff" dependencies = [ "fnv", "lazy_static", ] [[package]] name = "url" version = "2.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" dependencies = [ "form_urlencoded", "idna", "matches", "percent-encoding", ] [[package]] name = "version_check" version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" [[package]] name = "walkdir" version = "2.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", "winapi", "winapi-util", ] [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" dependencies = [ "cfg-if", "wasm-bindgen-macro", ] [[package]] name = "wasm-bindgen-backend" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", "syn 2.0.52", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9afec9963e3d0994cac82455b2b3502b81a7f40f9a0d32181f7528d9f4b43e02" dependencies = [ "cfg-if", "js-sys", "wasm-bindgen", "web-sys", ] [[package]] name = "wasm-bindgen-macro" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" dependencies = [ "quote", "wasm-bindgen-macro-support", ] [[package]] name = "wasm-bindgen-macro-support" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" [[package]] name = "wasm-bindgen-test" version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6433b7c56db97397842c46b67e11873eda263170afeb3a2dc74a7cb370fee0d" dependencies = [ "console_error_panic_hook", "js-sys", "scoped-tls", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-test-macro", ] [[package]] name = "wasm-bindgen-test-macro" version = "0.3.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "493fcbab756bb764fa37e6bee8cec2dd709eb4273d06d0c282a5e74275ded735" dependencies = [ "proc-macro2", "quote", "syn 2.0.52", ] [[package]] name = "web-sys" version = "0.3.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5db499c5f66323272151db0e666cd34f78617522fb0c1604d31a27c50c206a85" dependencies = [ "js-sys", "wasm-bindgen", ] [[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ "winapi-i686-pc-windows-gnu", "winapi-x86_64-pc-windows-gnu", ] [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi", ] [[package]] name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e686886bc078bc1b0b600cac0147aadb815089b6e4da64016cbd754b6342700f" dependencies = [ "windows-targets 0.48.1", ] [[package]] name = "windows-sys" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" dependencies = [ "windows_aarch64_msvc 0.36.1", "windows_i686_gnu 0.36.1", "windows_i686_msvc 0.36.1", "windows_x86_64_gnu 0.36.1", "windows_x86_64_msvc 0.36.1", ] [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ "windows-targets 0.52.4", ] [[package]] name = "windows-targets" version = "0.48.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "05d4b17490f70499f20b9e791dcf6a299785ce8af4d709018206dc5b4953e95f" dependencies = [ "windows_aarch64_gnullvm 0.48.0", "windows_aarch64_msvc 0.48.0", "windows_i686_gnu 0.48.0", "windows_i686_msvc 0.48.0", "windows_x86_64_gnu 0.48.0", "windows_x86_64_gnullvm 0.48.0", "windows_x86_64_msvc 0.48.0", ] [[package]] name = "windows-targets" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd37b7e5ab9018759f893a1952c9420d060016fc19a472b4bb20d1bdd694d1b" dependencies = [ "windows_aarch64_gnullvm 0.52.4", "windows_aarch64_msvc 0.52.4", "windows_i686_gnu 0.52.4", "windows_i686_msvc 0.52.4", "windows_x86_64_gnu 0.52.4", "windows_x86_64_gnullvm 0.52.4", "windows_x86_64_msvc 0.52.4", ] [[package]] name = "windows_aarch64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bcf46cf4c365c6f2d1cc93ce535f2c8b244591df96ceee75d8e83deb70a9cac9" [[package]] name = "windows_aarch64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" [[package]] name = "windows_aarch64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da9f259dd3bcf6990b55bffd094c4f7235817ba4ceebde8e6d11cd0c5633b675" [[package]] name = "windows_i686_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" [[package]] name = "windows_i686_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b474d8268f99e0995f25b9f095bc7434632601028cf86590aea5c8a5cb7801d3" [[package]] name = "windows_i686_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" [[package]] name = "windows_i686_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1515e9a29e5bed743cb4415a9ecf5dfca648ce85ee42e15873c3cd8610ff8e02" [[package]] name = "windows_x86_64_gnu" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" [[package]] name = "windows_x86_64_gnu" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5eee091590e89cc02ad514ffe3ead9eb6b660aedca2183455434b93546371a03" [[package]] name = "windows_x86_64_gnullvm" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77ca79f2451b49fa9e2af39f0747fe999fcda4f5e241b2898624dca97a1f2177" [[package]] name = "windows_x86_64_msvc" version = "0.36.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" [[package]] name = "windows_x86_64_msvc" version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" version = "0.52.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32b752e52a2da0ddfbdbcc6fceadfeede4c939ed16d13e648833a61dfb611ed8" [[package]] name = "winnow" version = "0.5.40" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f593a95398737aeed53e489c785df13f3618e41dbcd6718c6addbf1395aa6876" dependencies = [ "memchr", ] [[package]] name = "yaml-rust" version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" dependencies = [ "linked-hash-map", ] [[package]] name = "zeroize" version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4756f7db3f7b5574938c3eb1c117038b8e07f95ee6718c0efad4ac21508f1efd" dependencies = [ "zeroize_derive", ] [[package]] name = "zeroize_derive" version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f8f187641dad4f680d25c4bfc4225b418165984179f26ca76ec4fb6441d3a17" dependencies = [ "proc-macro2", "quote", "syn 1.0.107", "synstructure", ]
0
solana_public_repos/solana-playground/solana-playground
solana_public_repos/solana-playground/solana-playground/wasm/build.sh
#!/usr/bin/env bash # Build package(s) # Exit on any failure set -e help() { echo "Usage: build.sh [OPTIONS] <PACKAGE> <PACKAGE>: Optional WASM package name. Builds all packages if not specified. OPTIONS: -h, --help: Print help information -u, --update: Update client dependency " exit 0 } if [ "$1" = "--help" ]; then help fi args=() while [[ $# -gt 0 ]]; do case $1 in -u | --update) update=true shift ;; -*) echo "Unknown option '$1'" exit 1 ;; *) args+=("$1") shift ;; esac done # All package names all_packages=( "anchor-cli" "rust-analyzer" "seahorse-compile" "solana-cli" "spl-token-cli" "sugar-cli" ) vscode_packages=(${all_packages[2]}) # Get script directory (which is wasm/), and root directory (which is one level higher). # This allows the script to be run from any directory. wasm_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) root_dir=$(dirname "$wasm_dir") build() { local package="$1" echo "Building '$package'..." package_dir="$wasm_dir/$package" # Check whether the package directory exists if [ ! -d "$package_dir" ]; then echo "Error: no package named '$package' found in wasm/" echo "Valid packages: ${packages[@]}" exit 1 fi pushd $package_dir # Set the toolchain based on the `rust-toolchain.toml` file if [ -f "rust-toolchain.toml" ]; then echo "Installing rust toolchain" toolchain=$(awk '/"[stable|nightly]/{gsub(/"/, ""); print $3 }' rust-toolchain.toml) rustup toolchain install $toolchain --component rust-src fi # Rust Analyzer requires `--target web` if [ "$package" = "rust-analyzer" ]; then wasm-pack build --target web else wasm-pack build # Handle a WASM bug from `solana_sdk::instruction::SystemInstruction` package_name=$( awk "/^name/" Cargo.toml | cut -d "\"" -f 2 | sed "s/-/_/g" ) # Comment out the following line line="wasm.__wbg_systeminstruction_free(ptr);" if [[ "$(uname)" == "Darwin" ]]; then sed -i '' "s/$line/\/\/$line/" "pkg/${package_name}_bg.js" else sed -i "s/$line/\/\/$line/" "pkg/${package_name}_bg.js" fi fi popd } if [ ${#args[@]} -ne 0 ]; then packages="${args[@]}" else packages="${all_packages[@]}" fi # Build and update client packages client_package_names="" for package in $packages; do build $package client_package_names="${client_package_names}@solana-playground/$package " done # Exit early if `--update` is not specified if [ "$update" != true ]; then exit 0 fi # Update client packages echo "Updating client packages: $client_package_names" cd $root_dir/client && yarn install --frozen-lockfile && yarn upgrade $client_package_names # Update vscode packages vscode_package_names="" for package in "${vscode_packages[@]}"; do vscode_package_names="${vscode_package_names}@solana-playground/$package " done echo "Updating VSCode packages: $vscode_package_names" cd $root_dir/vscode && yarn install --frozen-lockfile && yarn upgrade $vscode_package_names
0
solana_public_repos/solana-playground/solana-playground
solana_public_repos/solana-playground/solana-playground/wasm/rust-toolchain.toml
[toolchain] channel = "1.75.0" targets = ["wasm32-unknown-unknown"] components = ["rustfmt"]
0
solana_public_repos/solana-playground/solana-playground/wasm
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/Cargo.toml
[package] name = "spl-token-cli-wasm" version = "2.0.15" description = "SPL-Token CLI for Solana Playground with WASM." authors = ["Acheron <acheroncrypto@gmail.com>"] repository = "https://github.com/solana-playground/solana-playground" license = "GPL-3.0" homepage = "https://beta.solpg.io" edition = "2021" keywords = ["spl", "token", "solana", "cli", "wasm"] [lib] crate-type = ["cdylib", "rlib"] [dependencies] clap = "*" console = "*" console_error_panic_hook = "*" serde = "*" serde_derive = "*" serde_json = "*" solana-clap-v3-utils-wasm = { path = "../utils/solana-clap-v3-utils" } solana-cli-config-wasm = { path = "../utils/solana-cli-config" } solana-cli-output-wasm = { path = "../utils/solana-cli-output" } solana-client-wasm = { path = "../solana-client" } solana-extra-wasm = { path = "../utils/solana-extra" } solana-playground-utils-wasm = { path = "../utils/solana-playground-utils" } solana-remote-wallet = { version = "*", default-features = false } solana-sdk = "*" strum = "0.24" strum_macros = "0.24" wasm-bindgen = "*" wasm-bindgen-futures = "*"
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/sort.rs
use std::{ collections::{btree_map::Entry, BTreeMap}, str::FromStr, }; use serde::{Deserialize, Serialize}; use solana_client_wasm::utils::rpc_config::RpcKeyedAccount; use solana_extra_wasm::{ account_decoder::{parse_token::TokenAccountType, UiAccountData}, program::spl_associated_token_account, }; use solana_sdk::pubkey::Pubkey; use crate::output::CliTokenAccount; pub(crate) type MintAccounts = BTreeMap<String, Vec<CliTokenAccount>>; #[derive(Serialize, Deserialize)] pub(crate) struct UnsupportedAccount { pub address: String, pub err: String, } pub(crate) fn sort_and_parse_token_accounts( owner: &Pubkey, accounts: Vec<RpcKeyedAccount>, program_id: &Pubkey, ) -> (MintAccounts, Vec<UnsupportedAccount>, usize, bool) { let mut mint_accounts: MintAccounts = BTreeMap::new(); let mut unsupported_accounts = vec![]; let mut max_len_balance = 0; let mut includes_aux = false; for keyed_account in accounts { let address = keyed_account.pubkey; if let UiAccountData::Json(parsed_account) = keyed_account.account.data { if parsed_account.program != "spl-token" { unsupported_accounts.push(UnsupportedAccount { address, err: format!("Unsupported account program: {}", parsed_account.program), }); } else { match serde_json::from_value(parsed_account.parsed) { Ok(TokenAccountType::Account(ui_token_account)) => { let mint = ui_token_account.mint.clone(); let is_associated = if let Ok(mint) = Pubkey::from_str(&mint) { spl_associated_token_account::get_associated_token_address_with_program_id(owner, &mint, program_id).to_string() == address } else { includes_aux = true; false }; let len_balance = ui_token_account .token_amount .real_number_string_trimmed() .len(); max_len_balance = max_len_balance.max(len_balance); let parsed_account = CliTokenAccount { address, account: ui_token_account, is_associated, }; let entry = mint_accounts.entry(mint); match entry { Entry::Occupied(_) => { entry.and_modify(|e| e.push(parsed_account)); } Entry::Vacant(_) => { entry.or_insert_with(|| vec![parsed_account]); } } } Ok(_) => unsupported_accounts.push(UnsupportedAccount { address, err: "Not a token account".to_string(), }), Err(err) => unsupported_accounts.push(UnsupportedAccount { address, err: format!("Account parse failure: {}", err), }), } } } else { unsupported_accounts.push(UnsupportedAccount { address, err: "Unsupported account data format".to_string(), }); } } for (_, array) in mint_accounts.iter_mut() { array.sort_by(|a, b| b.is_associated.cmp(&a.is_associated)); } ( mint_accounts, unsupported_accounts, max_len_balance, includes_aux, ) }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/constants.rs
pub const COMMAND_NAME: &str = "spl-token-cli-wasm"; pub const COMMAND_DESC: &str = "SPL-Token Command-line Utility"; pub const COMMAND_VERSION: &str = "2.0.15";
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/config.rs
use std::{rc::Rc, sync::Arc}; use clap::ArgMatches; use solana_clap_v3_utils_wasm::{ input_parsers::{pubkey_of, pubkey_of_signer}, input_validators::normalize_to_url_if_moniker, keypair::signer_from_path, offline::SIGN_ONLY_ARG, }; use solana_cli_config_wasm::{Config as CliConfig, ConfigInput}; use solana_cli_output_wasm::cli_output::OutputFormat; use solana_client_wasm::{utils::rpc_config::BlockhashQuery, WasmClient}; use solana_extra_wasm::program::spl_associated_token_account::get_associated_token_address_with_program_id; use solana_remote_wallet::remote_wallet::RemoteWalletManager; use solana_sdk::{ pubkey::Pubkey, signature::{Keypair, Signer}, }; use crate::utils::blockhash_query_from_matches; pub struct Config<'a> { pub(crate) rpc_client: Arc<WasmClient>, // pub(crate) websocket_url: String, pub(crate) output_format: OutputFormat, pub(crate) keypair_bytes: &'a [u8], pub(crate) fee_payer: Pubkey, pub(crate) nonce_account: Option<Pubkey>, pub(crate) nonce_authority: Option<Pubkey>, pub(crate) blockhash_query: BlockhashQuery, pub(crate) sign_only: bool, pub(crate) dump_transaction_message: bool, pub(crate) multisigner_pubkeys: Vec<&'a Pubkey>, pub(crate) program_id: Pubkey, } impl<'a> Config<'a> { // Check if an explicit token account address was provided, otherwise // return the associated token address for the default address. pub(crate) fn associated_token_address_or_override( &self, arg_matches: &ArgMatches, override_name: &str, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Pubkey { let token = pubkey_of_signer(arg_matches, "token", wallet_manager).unwrap(); self.associated_token_address_for_token_or_override( arg_matches, override_name, wallet_manager, token, ) } // Check if an explicit token account address was provided, otherwise // return the associated token address for the default address. pub(crate) fn associated_token_address_for_token_or_override( &self, arg_matches: &ArgMatches, override_name: &str, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, token: Option<Pubkey>, ) -> Pubkey { if let Some(address) = pubkey_of_signer(arg_matches, override_name, wallet_manager).unwrap() { return address; } let token = token.unwrap(); let owner = self .default_address(arg_matches, wallet_manager) .unwrap_or_else(|e| { eprintln!("error: {}", e); panic!(); }); get_associated_token_address_with_program_id(&owner, &token, &self.program_id) } // Checks if an explicit address was provided, otherwise return the default address. pub(crate) fn pubkey_or_default( &self, arg_matches: &ArgMatches, address_name: &str, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Pubkey { if address_name != "owner" { if let Some(address) = pubkey_of_signer(arg_matches, address_name, wallet_manager).unwrap() { return address; } } self.default_address(arg_matches, wallet_manager) .unwrap_or_else(|e| { eprintln!("error: {}", e); panic!(); }) } // TODO: Implement specifying --owner keypair // Checks if an explicit signer was provided, otherwise return the default signer. pub(crate) fn signer_or_default( &self, _arg_matches: &ArgMatches, _authority_name: &str, _wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> (Box<dyn Signer>, Pubkey) { // If there are `--multisig-signers` on the command line, allow `NullSigner`s to // be returned for multisig account addresses // let config = SignerFromPathConfig { // allow_null_signer: !self.multisigner_pubkeys.is_empty(), // }; // TODO: // let mut load_authority = move || { // // fallback handled in default_signer() for backward compatibility // // if authority_name != "owner" { // // if let Some(keypair_path) = arg_matches.value_of(authority_name) { // // return signer_from_path_with_config( // // arg_matches, // // keypair_path, // // authority_name, // // wallet_manager, // // &config, // // ); // // } // // } // self.default_signer(arg_matches, wallet_manager, &config) // }; let authority = self.get_default_signer(); let authority_address = authority.pubkey(); (authority, authority_address) } fn default_address( &self, matches: &ArgMatches, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Result<Pubkey, Box<dyn std::error::Error>> { // for backwards compatibility, check owner before cli config default if let Some(address) = pubkey_of_signer(matches, "owner", wallet_manager).unwrap() { return Ok(address); } Ok(self.get_default_signer().pubkey()) // match &self.default_keypair { // #[cfg(test)] // KeypairOrPath::Keypair(keypair) => Ok(keypair.pubkey()), // KeypairOrPath::Path(path) => pubkey_from_path(matches, path, "default", wallet_manager), // } } // fn default_signer( // &self, // matches: &ArgMatches, // wallet_manager: &mut Option<Arc<RemoteWalletManager>>, // config: &SignerFromPathConfig, // ) -> Result<Box<dyn Signer>, Box<dyn std::error::Error>> { // // for backwards compatibility, check owner before cli config default // if let Some(owner_path) = matches.value_of("owner") { // return signer_from_path_with_config( // matches, // owner_path, // "owner", // wallet_manager, // config, // ); // } // Ok(&self.default_signer) // // match &self.default_keypair { // // #[cfg(test)] // // KeypairOrPath::Keypair(keypair) => { // // let cloned = Keypair::from_bytes(&keypair.to_bytes()).unwrap(); // // Ok(Box::new(cloned)) // // } // // KeypairOrPath::Path(path) => { // // signer_from_path_with_config(matches, path, "default", wallet_manager, config) // // } // // } // } pub(crate) fn get_default_signer(&self) -> Box<dyn Signer> { Box::new(Keypair::from_bytes(self.keypair_bytes).unwrap()) } } pub fn get_signer( matches: &ArgMatches, keypair_name: &str, wallet_manager: &mut Option<Rc<RemoteWalletManager>>, ) -> Option<(Box<dyn Signer>, Pubkey)> { matches.value_of(keypair_name).map(|path| { let signer = signer_from_path(matches, path, keypair_name, wallet_manager).unwrap_or_else(|e| { eprintln!("error: {}", e); panic!(); }); let signer_pubkey = signer.pubkey(); (signer, signer_pubkey) }) } pub fn get_config<'a>( matches: &'a ArgMatches, endpoint: &str, commitment: &str, keypair_bytes: &'a [u8], ) -> Config<'a> { // TODO: // let cli_config = if let Some(&config_file) = matches.value_of("config_file") { // solana_cli_config_wasm::Config::load(&config_file).unwrap_or_else(|_| { // eprintln!("error: Could not find config file `{}`", config_file); // panic!(); // }) // } else { // solana_cli_config_wasm::Config::default() // }; let cli_config = CliConfig::new(endpoint, commitment); let json_rpc_url = normalize_to_url_if_moniker( matches .value_of("json_rpc_url") .unwrap_or(&cli_config.json_rpc_url), ); // let websocket_url = CliConfig::compute_websocket_url(&json_rpc_url); // TODO: // Fee payer is always the client // let (signer, fee_payer) = signer_from_path( // matches, // matches // .value_of("fee_payer") // .unwrap_or(&cli_config.keypair_path), // "fee_payer", // &mut wallet_manager, // ) // .map(|s| { // let p = s.pubkey(); // (s, p) // }) // .unwrap_or_else(|e| { // eprintln!("error: {}", e); // panic!(); // }); // bulk_signers.push(signer); let default_signer = Keypair::from_bytes(keypair_bytes).unwrap(); let fee_payer = default_signer.pubkey(); let verbose = matches.is_present("verbose"); let output_format = matches .value_of("output_format") .map(|value| match value { "json" => OutputFormat::Json, "json-compact" => OutputFormat::JsonCompact, _ => unreachable!(), }) .unwrap_or(if verbose { OutputFormat::DisplayVerbose } else { OutputFormat::Display }); // TODO: // let nonce_account = pubkey_of_signer(matches, NONCE_ARG.name, &mut wallet_manager) // .unwrap_or_else(|e| { // eprintln!("error: {}", e); // panic!() // }); // let nonce_authority = if nonce_account.is_some() { // let (signer, nonce_authority) = signer_from_path( // matches, // matches // .value_of(NONCE_AUTHORITY_ARG.name) // .unwrap_or(&cli_config.keypair_path), // NONCE_AUTHORITY_ARG.name, // &mut wallet_manager, // ) // .map(|s| { // let p = s.pubkey(); // (s, p) // }) // .unwrap_or_else(|e| { // eprintln!("error: {}", e); // panic!(); // }); // bulk_signers.push(signer); // Some(nonce_authority) // } else { // None // }; let nonce_account = None; let nonce_authority = None; let blockhash_query = blockhash_query_from_matches(matches); let sign_only = matches.is_present(SIGN_ONLY_ARG.name); // TODO: // let dump_transaction_message = matches.is_present(DUMP_TRANSACTION_MESSAGE.name); let dump_transaction_message = false; let program_id = pubkey_of(matches, "program_id").unwrap(); // TODO: // let multisig_signers = signers_of(matches, MULTISIG_SIGNER_ARG.name, &mut wallet_manager) // .unwrap_or_else(|e| { // eprintln!("error: {}", e); // panic!(); // }); // if let Some(mut multisig_signers) = multisig_signers { // multisig_signers.sort_by(|(_, lp), (_, rp)| lp.cmp(rp)); // let (signers, pubkeys): (Vec<_>, Vec<_>) = multisig_signers.into_iter().unzip(); // bulk_signers.extend(signers); // multisigner_ids = pubkeys; // } // let multisigner_pubkeys = multisigner_ids.iter().collect::<Vec<_>>(); let multisigner_pubkeys = vec![]; let (_, commitment_config) = ConfigInput::compute_commitment_config( matches.value_of("commitment").unwrap_or(""), &cli_config.commitment, ); Config { rpc_client: Arc::new(WasmClient::new_with_commitment( &json_rpc_url, commitment_config, )), // websocket_url, output_format, keypair_bytes, fee_payer, nonce_account, nonce_authority, blockhash_query, sign_only, dump_transaction_message, multisigner_pubkeys, program_id, } }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/lib.rs
#![allow(clippy::arithmetic_side_effects)] #![allow(dead_code)] mod clap; mod cli; mod config; mod constants; mod output; mod sort; mod utils; mod wasm;
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/clap.rs
use std::str::FromStr; use clap::{Arg, Command}; use solana_clap_v3_utils_wasm::{ input_validators::{ is_amount, is_amount_or_all, is_parsable, is_url_or_moniker, is_valid_pubkey, is_valid_signer, }, memo::memo_arg, nonce::NonceArgs, offline, offline::{OfflineArgs, BLOCKHASH_ARG, SIGN_ONLY_ARG}, ArgConstant, }; use solana_extra_wasm::program::spl_token::instruction::{MAX_SIGNERS, MIN_SIGNERS}; use crate::cli::CommandName; pub const OWNER_ADDRESS_ARG: ArgConstant<'static> = ArgConstant { name: "owner", long: "owner", help: "Address of the token's owner. Defaults to the client keypair address.", }; pub const OWNER_KEYPAIR_ARG: ArgConstant<'static> = ArgConstant { name: "owner", long: "owner", help: "Keypair of the token's owner. Defaults to the client keypair.", }; pub const MINT_ADDRESS_ARG: ArgConstant<'static> = ArgConstant { name: "mint_address", long: "mint-address", help: "Address of mint that token account is associated with. Required by --sign-only", }; pub const MINT_DECIMALS_ARG: ArgConstant<'static> = ArgConstant { name: "mint_decimals", long: "mint-decimals", help: "Decimals of mint that token account is associated with. Required by --sign-only", }; pub const DELEGATE_ADDRESS_ARG: ArgConstant<'static> = ArgConstant { name: "delegate_address", long: "delegate-address", help: "Address of delegate currently assigned to token account. Required by --sign-only", }; pub const MULTISIG_SIGNER_ARG: ArgConstant<'static> = ArgConstant { name: "multisig_signer", long: "multisig-signer", help: "Member signer of a multisig account", }; struct SignOnlyNeedsFullMintSpec {} impl offline::ArgsConfig for SignOnlyNeedsFullMintSpec { fn sign_only_arg<'a>(&self, arg: Arg<'a>) -> Arg<'a> { arg.requires_all(&[MINT_ADDRESS_ARG.name, MINT_DECIMALS_ARG.name]) } } pub fn owner_address_arg<'a>() -> Arg<'a> { Arg::new(OWNER_ADDRESS_ARG.name) .long(OWNER_ADDRESS_ARG.long) .takes_value(true) .value_name("OWNER_ADDRESS") .validator(is_valid_pubkey) .help(OWNER_ADDRESS_ARG.help) } pub fn owner_keypair_arg_with_value_name<'a>(value_name: &'static str) -> Arg<'a> { Arg::new(OWNER_KEYPAIR_ARG.name) .long(OWNER_KEYPAIR_ARG.long) .takes_value(true) .value_name(value_name) .validator(is_valid_signer) .help(OWNER_KEYPAIR_ARG.help) } pub fn owner_keypair_arg<'a>() -> Arg<'a> { owner_keypair_arg_with_value_name("OWNER_KEYPAIR") } pub fn mint_address_arg<'a>() -> Arg<'a> { Arg::new(MINT_ADDRESS_ARG.name) .long(MINT_ADDRESS_ARG.long) .takes_value(true) .value_name("MINT_ADDRESS") .validator(is_valid_pubkey) .requires(SIGN_ONLY_ARG.name) .requires(BLOCKHASH_ARG.name) .help(MINT_ADDRESS_ARG.help) } fn is_mint_decimals(str: &str) -> Result<(), String> { is_parsable::<u8>(str) } pub fn mint_decimals_arg<'a>() -> Arg<'a> { Arg::new(MINT_DECIMALS_ARG.name) .long(MINT_DECIMALS_ARG.long) .takes_value(true) .value_name("MINT_DECIMALS") .validator(is_mint_decimals) .requires(SIGN_ONLY_ARG.name) .requires(BLOCKHASH_ARG.name) .help(MINT_DECIMALS_ARG.help) } pub trait MintArgs { fn mint_args(self) -> Self; } impl MintArgs for Command<'_> { fn mint_args(self) -> Self { self.arg(mint_address_arg().requires(MINT_DECIMALS_ARG.name)) .arg(mint_decimals_arg().requires(MINT_ADDRESS_ARG.name)) } } pub fn delegate_address_arg<'a>() -> Arg<'a> { Arg::new(DELEGATE_ADDRESS_ARG.name) .long(DELEGATE_ADDRESS_ARG.long) .takes_value(true) .value_name("DELEGATE_ADDRESS") .validator(is_valid_pubkey) .requires(SIGN_ONLY_ARG.name) .requires(BLOCKHASH_ARG.name) .help(DELEGATE_ADDRESS_ARG.help) } pub fn multisig_signer_arg<'a>() -> Arg<'a> { Arg::new(MULTISIG_SIGNER_ARG.name) .long(MULTISIG_SIGNER_ARG.long) .validator(is_valid_signer) .value_name("MULTISIG_SIGNER") .takes_value(true) .multiple_occurrences(true) .min_values(0) .max_values(MAX_SIGNERS) .help(MULTISIG_SIGNER_ARG.help) } fn is_multisig_minimum_signers(string: &str) -> Result<(), String> { let v = u8::from_str(string).map_err(|e| e.to_string())? as usize; if v < MIN_SIGNERS { Err(format!("must be at least {}", MIN_SIGNERS)) } else if v > MAX_SIGNERS { Err(format!("must be at most {}", MAX_SIGNERS)) } else { Ok(()) } } struct SignOnlyNeedsMintDecimals {} impl offline::ArgsConfig for SignOnlyNeedsMintDecimals { fn sign_only_arg<'a>(&self, arg: Arg<'a>) -> Arg<'a> { arg.requires_all(&[MINT_DECIMALS_ARG.name]) } } struct SignOnlyNeedsMintAddress {} impl offline::ArgsConfig for SignOnlyNeedsMintAddress { fn sign_only_arg<'a>(&self, arg: Arg<'a>) -> Arg<'a> { arg.requires_all(&[MINT_ADDRESS_ARG.name]) } } struct SignOnlyNeedsDelegateAddress {} impl offline::ArgsConfig for SignOnlyNeedsDelegateAddress { fn sign_only_arg<'a>(&self, arg: Arg<'a>) -> Arg<'a> { arg.requires_all(&[DELEGATE_ADDRESS_ARG.name]) } } pub fn get_clap<'a>( name: &str, about: &'a str, version: &'a str, default_decimals: &'a str, default_program_id: &'a str, ) -> Command<'a> { Command::new(name) .about(about) .version(version) .subcommand_required(true) .arg_required_else_help(true) // .arg({ // let arg = Arg::new("config_file") // .short('C') // .long("config") // .value_name("PATH") // .takes_value(true) // .global(true) // .help("Configuration file to use"); // if let Some(ref config_file) = *solana_cli_config_wasm::CONFIG_FILE { // arg.default_value(config_file) // } else { // arg // } // }) .arg( Arg::new("verbose") .short('v') .long("verbose") .takes_value(false) .global(true) .help("Show additional information"), ) .arg( Arg::new("output_format") .long("output") .value_name("FORMAT") .global(true) .takes_value(true) .possible_values(["json", "json-compact"]) .help("Return information in specified output format"), ) .arg( Arg::new("program_id") .short('p') .long("program-id") .value_name("ADDRESS") .takes_value(true) .global(true) .default_value(default_program_id) .validator(is_valid_pubkey) .help("SPL Token program id"), ) .arg( Arg::new("json_rpc_url") .short('u') .long("url") .value_name("URL_OR_MONIKER") .takes_value(true) .global(true) .validator(is_url_or_moniker) .help( "URL for Solana's JSON RPC or moniker (or their first letter): \ [mainnet-beta, testnet, devnet, localhost] \ Default from the configuration file." ), ) // TODO: // .arg(fee_payer_arg().global(true)) .arg( Arg::new("use_unchecked_instruction") .long("use-unchecked-instruction") .takes_value(false) .global(true) .hide(true) .help("Use unchecked instruction if appropriate. Supports transfer, burn, mint, and approve."), ) // .bench_subcommand() .subcommand(Command::new(CommandName::CreateToken.to_string()).about("Create a new token") .arg( Arg::new("token_keypair") .value_name("TOKEN_KEYPAIR") .validator(is_valid_signer) .takes_value(true) .index(1) .help( "Specify the token keypair. \ This may be a keypair file or the ASK keyword. \ [default: randomly generated keypair]" ), ) .arg( Arg::new("mint_authority") .long("mint-authority") .alias("owner") .value_name("ADDRESS") .validator(is_valid_pubkey) .takes_value(true) .help( "Specify the mint authority address. \ Defaults to the client keypair address." ), ) .arg( Arg::new("decimals") .long("decimals") .validator(is_mint_decimals) .value_name("DECIMALS") .takes_value(true) .default_value(default_decimals) .help("Number of base 10 digits to the right of the decimal place"), ) .arg( Arg::new("enable_freeze") .long("enable-freeze") .takes_value(false) .help( "Enable the mint authority to freeze associated token accounts." ), ) .nonce_args(true) .arg(memo_arg()) .offline_args(), ) .subcommand( Command::new(CommandName::CreateAccount.to_string()) .about("Create a new token account") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The token that the account will hold"), ) .arg( Arg::new("account_keypair") .value_name("ACCOUNT_KEYPAIR") .validator(is_valid_signer) .takes_value(true) .index(2) .help( "Specify the account keypair. \ This may be a keypair file or the ASK keyword. \ [default: associated token account for --owner]" ), ) .arg(owner_address_arg()) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::CreateMultisig.to_string()) .about("Create a new account describing an M:N multisignature") .arg( Arg::new("minimum_signers") .value_name("MINIMUM_SIGNERS") .validator(is_multisig_minimum_signers) .takes_value(true) .index(1) .required(true) .help( "The minimum number of signers required to allow the operation. [1 <= M <= N]", ), ) .arg( Arg::new("multisig_member") .value_name("MULTISIG_MEMBER_PUBKEY") .validator(is_valid_pubkey) .takes_value(true) .index(2) .required(true) .min_values(MIN_SIGNERS) .max_values(MAX_SIGNERS) .help( "The public keys for each of the N signing members of this account. [1 <= N <= 1]", ), ) .arg( Arg::new("address_keypair") .long("address-keypair") .value_name("ADDRESS_KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the address keypair. \ This may be a keypair file or the ASK keyword. \ [default: randomly generated keypair]" ), ) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::Authorize.to_string()) .about("Authorize a new signing keypair to a token or token account") .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the token account"), ) .arg( Arg::new("authority_type") .value_name("AUTHORITY_TYPE") .takes_value(true) .possible_values(["mint", "freeze", "owner", "close"]) .index(2) .required(true) .help("The new authority type. \ Token mints support `mint` and `freeze` authorities;\ Token accounts support `owner` and `close` authorities."), ) .arg( Arg::new("new_authority") .validator(is_valid_pubkey) .value_name("AUTHORITY_ADDRESS") .takes_value(true) .index(3) .required_unless_present("disable") .help("The address of the new authority"), ) .arg( Arg::new("authority") .long("authority") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the current authority keypair. \ Defaults to the client keypair." ), ) .arg( Arg::new("disable") .long("disable") .takes_value(false) .conflicts_with("new_authority") .help("Disable mint, freeze, or close functionality by setting authority to None.") ) .arg( Arg::new("force") .long("force") .hide(true) .help("Force re-authorize the wallet's associate token account. Don't use this flag"), ) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::Transfer.to_string()) .about("Transfer tokens between accounts") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required(true) .help("Token to transfer"), ) .arg( Arg::new("amount") .validator(is_amount_or_all) .value_name("TOKEN_AMOUNT") .takes_value(true) .index(2) .required(true) .help("Amount to send, in tokens; accepts keyword ALL"), ) .arg( Arg::new("recipient") .validator(is_valid_pubkey) .value_name("RECIPIENT_ADDRESS or RECIPIENT_TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(3) .required(true) .help("If a token account address is provided, use it as the recipient. \ Otherwise assume the recipient address is a user wallet and transfer to \ the associated token account") ) .arg( Arg::new("from") .validator(is_valid_pubkey) .value_name("SENDER_TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .long("from") .help("Specify the sending token account \ [default: owner's associated token account]") ) .arg(owner_keypair_arg_with_value_name("SENDER_TOKEN_OWNER_KEYPAIR") .help( "Specify the owner of the sending token account. \ This may be a keypair file, the ASK keyword. \ Defaults to the client keypair.", ), ) .arg( Arg::new("allow_unfunded_recipient") .long("allow-unfunded-recipient") .takes_value(false) .help("Complete the transfer even if the recipient address is not funded") ) .arg( Arg::new("allow_empty_recipient") .long("allow-empty-recipient") .takes_value(false) .hide(true) // Deprecated, use --allow-unfunded-recipient instead ) .arg( Arg::new("fund_recipient") .long("fund-recipient") .takes_value(false) .help("Create the associated token account for the recipient if doesn't already exist") ) .arg( Arg::new("no_wait") .long("no-wait") .takes_value(false) .help("Return signature immediately after submitting the transaction, instead of waiting for confirmations"), ) .arg( Arg::new("allow_non_system_account_recipient") .long("allow-non-system-account-recipient") .takes_value(false) .help("Send tokens to the recipient even if the recipient is not a wallet owned by System Program."), ) .arg( Arg::new("recipient_is_ata_owner") .long("recipient-is-ata-owner") .takes_value(false) .requires("sign_only") .help("In sign-only mode, specifies that the recipient is the owner of the associated token account rather than an actual token account"), ) .arg(multisig_signer_arg()) .arg(mint_decimals_arg()) .nonce_args(true) .arg(memo_arg()) .offline_args_config(&SignOnlyNeedsMintDecimals{}), ) .subcommand( Command::new(CommandName::Burn.to_string()) .about("Burn tokens from an account") .arg( Arg::new("source") .validator(is_valid_pubkey) .value_name("SOURCE_TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The token account address to burn from"), ) .arg( Arg::new("amount") .validator(is_amount) .value_name("TOKEN_AMOUNT") .takes_value(true) .index(2) .required(true) .help("Amount to burn, in tokens"), ) // .arg(owner_keypair_arg_with_value_name("SOURCE_TOKEN_OWNER_KEYPAIR") // .help( // "Specify the source token owner account. \ // This may be a keypair file, the ASK keyword. \ // Defaults to the client keypair.", // ), // ) .arg(multisig_signer_arg()) .mint_args() .nonce_args(true) .arg(memo_arg()) .offline_args_config(&SignOnlyNeedsFullMintSpec{}), ) .subcommand( Command::new(CommandName::Mint.to_string()) .about("Mint new tokens") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The token to mint"), ) .arg( Arg::new("amount") .validator(is_amount) .value_name("TOKEN_AMOUNT") .takes_value(true) .index(2) .required(true) .help("Amount to mint, in tokens"), ) .arg( Arg::new("recipient") .validator(is_valid_pubkey) .value_name("RECIPIENT_TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(3) .help("The token account address of recipient [default: associated token account for --owner]"), ) .arg( Arg::new("mint_authority") .long("mint-authority") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the mint authority keypair. \ This may be a keypair file or the ASK keyword. \ Defaults to the client keypair." ), ) .arg(mint_decimals_arg()) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args_config(&SignOnlyNeedsMintDecimals{}), ) .subcommand( Command::new(CommandName::Freeze.to_string()) .about("Freeze a token account") .arg( Arg::new("account") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the token account to freeze"), ) .arg( Arg::new("freeze_authority") .long("freeze-authority") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the freeze authority keypair. \ This may be a keypair file or the ASK keyword. \ Defaults to the client keypair." ), ) .arg(mint_address_arg()) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args_config(&SignOnlyNeedsMintAddress{}), ) .subcommand( Command::new(CommandName::Thaw.to_string()) .about("Thaw a token account") .arg( Arg::new("account") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the token account to thaw"), ) .arg( Arg::new("freeze_authority") .long("freeze-authority") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the freeze authority keypair. \ This may be a keypair file or the ASK keyword. \ Defaults to the client keypair." ), ) .arg(mint_address_arg()) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args_config(&SignOnlyNeedsMintAddress{}), ) .subcommand( Command::new(CommandName::Wrap.to_string()) .about("Wrap native SOL in a SOL token account") .arg( Arg::new("amount") .validator(is_amount) .value_name("AMOUNT") .takes_value(true) .index(1) .required(true) .help("Amount of SOL to wrap"), ) .arg( Arg::new("wallet_keypair") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the keypair for the wallet which will have its native SOL wrapped. \ This wallet will be assigned as the owner of the wrapped SOL token account. \ This may be a keypair file or the ASK keyword. \ Defaults to the client keypair." ), ) .arg( Arg::new("create_aux_account") .takes_value(false) .long("create-aux-account") .help("Wrap SOL in an auxiliary account instead of associated token account"), ) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::Unwrap.to_string()) .about("Unwrap a SOL token account") .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .help("The address of the auxiliary token account to unwrap \ [default: associated token account for --owner]"), ) .arg( Arg::new("wallet_keypair") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the keypair for the wallet which owns the wrapped SOL. \ This wallet will receive the unwrapped SOL. \ This may be a keypair file or the ASK keyword. \ Defaults to the client keypair." ), ) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::Approve.to_string()) .about("Approve a delegate for a token account") .arg( Arg::new("account") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the token account to delegate"), ) .arg( Arg::new("amount") .validator(is_amount) .value_name("TOKEN_AMOUNT") .takes_value(true) .index(2) .required(true) .help("Amount to approve, in tokens"), ) .arg( Arg::new("delegate") .validator(is_valid_pubkey) .value_name("DELEGATE_TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(3) .required(true) .help("The token account address of delegate"), ) .arg( owner_keypair_arg() ) .arg(multisig_signer_arg()) .mint_args() .nonce_args(true) .offline_args_config(&SignOnlyNeedsFullMintSpec{}), ) .subcommand( Command::new(CommandName::Revoke.to_string()) .about("Revoke a delegate's authority") .arg( Arg::new("account") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the token account"), ) .arg(owner_keypair_arg() ) .arg(delegate_address_arg()) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args_config(&SignOnlyNeedsDelegateAddress{}), ) .subcommand( Command::new(CommandName::Close.to_string()) .about("Close a token account") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required_unless_present("address") .help("Token to close. To close a specific account, use the `--address` parameter instead"), ) .arg(owner_address_arg()) .arg( Arg::new("recipient") .long("recipient") .validator(is_valid_pubkey) .value_name("REFUND_ACCOUNT_ADDRESS") .takes_value(true) .help("The address of the account to receive remaining SOL [default: --owner]"), ) .arg( Arg::new("close_authority") .long("close-authority") .alias("owner") .value_name("KEYPAIR") .validator(is_valid_signer) .takes_value(true) .help( "Specify the token's close authority if it has one, \ otherwise specify the token's owner keypair. \ This may be a keypair file, the ASK keyword. \ Defaults to the client keypair.", ), ) .arg( Arg::new("address") .long("address") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .conflicts_with("token") .help("Specify the token account to close \ [default: owner's associated token account]"), ) .arg(multisig_signer_arg()) .nonce_args(true) .offline_args(), ) .subcommand( Command::new(CommandName::Balance.to_string()) .about("Get token account balance") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required_unless_present("address") .help("Token of associated account. To query a specific account, use the `--address` parameter instead"), ) .arg(owner_address_arg().conflicts_with("address")) .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .long("address") .conflicts_with("token") .help("Specify the token account to query \ [default: owner's associated token account]"), ), ) .subcommand( Command::new(CommandName::Supply.to_string()) .about("Get token supply") .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The token address"), ), ) .subcommand( Command::new(CommandName::Accounts.to_string()) .about("List all token accounts by owner") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .help("Limit results to the given token. [Default: list accounts for all tokens]"), ) .arg(owner_address_arg()) ) .subcommand( Command::new(CommandName::Address.to_string()) .about("Get wallet address") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .long("token") .requires("verbose") .help("Return the associated token address for the given token. \ [Default: return the client keypair address]") ) .arg( owner_address_arg() .requires("token") .help("Return the associated token address for the given owner. \ [Default: return the associated token address for the client keypair]"), ), ) .subcommand( Command::new(CommandName::AccountInfo.to_string()) .about("Query details of an SPL Token account by address") .arg( Arg::new("token") .validator(is_valid_pubkey) .value_name("TOKEN_ADDRESS") .takes_value(true) .index(1) .conflicts_with("address") .required_unless_present("address") .help("Token of associated account. \ To query a specific account, use the `--address` parameter instead"), ) .arg( owner_address_arg() .index(2) .conflicts_with("address") .help("Owner of the associated account for the specified token. \ To query a specific account, use the `--address` parameter instead. \ Defaults to the client keypair."), ) .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .long("address") .conflicts_with("token") .help("Specify the token account to query"), ), ) .subcommand( Command::new(CommandName::MultisigInfo.to_string()) .about("Query details about and SPL Token multisig account by address") .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("MULTISIG_ACCOUNT_ADDRESS") .takes_value(true) .index(1) .required(true) .help("The address of the SPL Token multisig account to query"), ), ) .subcommand( Command::new(CommandName::Gc.to_string()) .about("Cleanup unnecessary token accounts") .arg(owner_keypair_arg()) .arg( Arg::new("close_empty_associated_accounts") .long("close-empty-associated-accounts") .takes_value(false) .help("close all empty associated token accounts (to get SOL back)") ) ) .subcommand( Command::new(CommandName::SyncNative.to_string()) .about("Sync a native SOL token account to its underlying lamports") .arg( owner_address_arg() .index(1) .conflicts_with("address") .help("Owner of the associated account for the native token. \ To query a specific account, use the `--address` parameter instead. \ Defaults to the client keypair."), ) .arg( Arg::new("address") .validator(is_valid_pubkey) .value_name("TOKEN_ACCOUNT_ADDRESS") .takes_value(true) .long("address") .conflicts_with("owner") .help("Specify the specific token account address to sync"), ), ) }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/output.rs
use std::fmt::{self, Display}; use console::Emoji; use serde::{Deserialize, Serialize, Serializer}; use solana_cli_output_wasm::cli_output::{ writeln_name_value, OutputFormat, QuietDisplay, VerboseDisplay, }; use solana_extra_wasm::account_decoder::parse_token::{ UiAccountState, UiTokenAccount, UiTokenAmount, }; use solana_playground_utils_wasm::js::PgTerminal; use crate::{cli::CommandName, config::Config, sort::UnsupportedAccount}; pub(crate) trait Output: Serialize + fmt::Display + QuietDisplay + VerboseDisplay {} static WARNING: Emoji = Emoji("⚠️", "!"); #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CommandOutput<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { pub(crate) command_name: String, pub(crate) command_output: T, } impl<T> Display for CommandOutput<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { Display::fmt(&self.command_output, f) } } impl<T> QuietDisplay for CommandOutput<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result { QuietDisplay::write_str(&self.command_output, w) } } impl<T> VerboseDisplay for CommandOutput<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result { writeln_name_value(w, "Command: ", &self.command_name)?; VerboseDisplay::write_str(&self.command_output, w) } } pub(crate) fn println_display(config: &Config, message: String) { match config.output_format { OutputFormat::Display | OutputFormat::DisplayVerbose => PgTerminal::log_wasm(&message), _ => {} } } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliMint<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { pub(crate) address: String, pub(crate) decimals: u8, pub(crate) transaction_data: T, } impl<T> Display for CliMint<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { writeln!(f)?; writeln_name_value(f, "Address: ", &self.address)?; writeln_name_value(f, "Decimals: ", &format!("{}", self.decimals))?; Display::fmt(&self.transaction_data, f) } } impl<T> QuietDisplay for CliMint<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result { writeln!(w)?; writeln_name_value(w, "Address: ", &self.address)?; writeln_name_value(w, "Decimals: ", &format!("{}", self.decimals))?; QuietDisplay::write_str(&self.transaction_data, w) } } impl<T> VerboseDisplay for CliMint<T> where T: Serialize + Display + QuietDisplay + VerboseDisplay, { fn write_str(&self, w: &mut dyn std::fmt::Write) -> std::fmt::Result { writeln!(w)?; writeln_name_value(w, "Address: ", &self.address)?; writeln_name_value(w, "Decimals: ", &format!("{}", self.decimals))?; VerboseDisplay::write_str(&self.transaction_data, w) } } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliTokenAmount { #[serde(flatten)] pub(crate) amount: UiTokenAmount, } impl QuietDisplay for CliTokenAmount {} impl VerboseDisplay for CliTokenAmount { fn write_str(&self, w: &mut dyn fmt::Write) -> fmt::Result { writeln!(w, "ui amount: {}", self.amount.real_number_string_trimmed())?; writeln!(w, "decimals: {}", self.amount.decimals)?; writeln!(w, "amount: {}", self.amount.amount) } } impl fmt::Display for CliTokenAmount { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "{}", self.amount.real_number_string_trimmed()) } } #[derive(Default, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliWalletAddress { pub(crate) wallet_address: String, #[serde(skip_serializing_if = "Option::is_none")] pub(crate) associated_token_address: Option<String>, } impl QuietDisplay for CliWalletAddress {} impl VerboseDisplay for CliWalletAddress {} impl fmt::Display for CliWalletAddress { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f, "Wallet address: {}", self.wallet_address)?; if let Some(associated_token_address) = &self.associated_token_address { writeln!(f, "Associated token address: {}", associated_token_address)?; } Ok(()) } } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliMultisig { pub(crate) address: String, pub(crate) m: u8, pub(crate) n: u8, pub(crate) signers: Vec<String>, } impl QuietDisplay for CliMultisig {} impl VerboseDisplay for CliMultisig {} impl fmt::Display for CliMultisig { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f)?; writeln_name_value(f, "Address:", &self.address)?; writeln_name_value(f, "M/N:", &format!("{}/{}", self.m, self.n))?; writeln_name_value(f, "Signers:", " ")?; let width = if self.n >= 9 { 4 } else { 3 }; for i in 0..self.n as usize { let title = format!("{1:>0$}:", width, i + 1); let pubkey = &self.signers[i]; writeln_name_value(f, &title, pubkey)?; } Ok(()) } } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliTokenAccount { pub(crate) address: String, pub(crate) is_associated: bool, #[serde(flatten)] pub(crate) account: UiTokenAccount, } impl QuietDisplay for CliTokenAccount {} impl VerboseDisplay for CliTokenAccount {} impl fmt::Display for CliTokenAccount { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { writeln!(f)?; if self.is_associated { writeln_name_value(f, "Address:", &self.address)?; } else { writeln_name_value(f, "Address:", &format!("{} (Aux*)", self.address))?; } writeln_name_value( f, "Balance:", &self.account.token_amount.real_number_string_trimmed(), )?; let mint = format!( "{}{}", self.account.mint, if self.account.is_native { " (native)" } else { "" } ); writeln_name_value(f, "Mint:", &mint)?; writeln_name_value(f, "Owner:", &self.account.owner)?; writeln_name_value(f, "State:", &format!("{:?}", self.account.state))?; if let Some(delegate) = &self.account.delegate { writeln!(f, "Delegation:")?; writeln_name_value(f, " Delegate:", delegate)?; let allowance = self.account.delegated_amount.as_ref().unwrap(); writeln_name_value(f, " Allowance:", &allowance.real_number_string_trimmed())?; } else { writeln_name_value(f, "Delegation:", "")?; } writeln_name_value( f, "Close authority:", self.account .close_authority .as_ref() .unwrap_or(&String::new()), )?; if !self.is_associated { writeln!(f)?; writeln!(f, "* Please run `spl-token gc` to clean up Aux accounts")?; } Ok(()) } } #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub(crate) struct CliTokenAccounts { #[serde(serialize_with = "flattened")] pub(crate) accounts: Vec<Vec<CliTokenAccount>>, #[serde(skip_serializing_if = "Vec::is_empty")] pub(crate) unsupported_accounts: Vec<UnsupportedAccount>, #[serde(skip_serializing)] pub(crate) max_len_balance: usize, #[serde(skip_serializing)] pub(crate) aux_len: usize, #[serde(skip_serializing)] pub(crate) token_is_some: bool, } impl QuietDisplay for CliTokenAccounts {} impl VerboseDisplay for CliTokenAccounts { fn write_str(&self, w: &mut dyn fmt::Write) -> fmt::Result { let mut gc_alert = false; if self.token_is_some { writeln!( w, "{:<44} {:<2$}", "Account", "Balance", self.max_len_balance )?; writeln!( w, "-------------------------------------------------------------" )?; } else { writeln!( w, "{:<44} {:<44} {:<3$}", "Token", "Account", "Balance", self.max_len_balance )?; writeln!(w, "----------------------------------------------------------------------------------------------------------")?; } for accounts_list in self.accounts.iter() { let mut aux_counter = 1; for account in accounts_list { let maybe_aux = if !account.is_associated { gc_alert = true; let message = format!(" (Aux-{}*)", aux_counter); aux_counter += 1; message } else { "".to_string() }; let maybe_frozen = if let UiAccountState::Frozen = account.account.state { format!(" {} Frozen", WARNING) } else { "".to_string() }; if self.token_is_some { writeln!( w, "{:<44} {:<4$}{:<5$}{}", account.address, account.account.token_amount.real_number_string_trimmed(), maybe_aux, maybe_frozen, self.max_len_balance, self.aux_len, )?; } else { writeln!( w, "{:<44} {:<44} {:<5$}{:<6$}{}", account.account.mint, account.address, account.account.token_amount.real_number_string_trimmed(), maybe_aux, maybe_frozen, self.max_len_balance, self.aux_len, )?; } } } for unsupported_account in &self.unsupported_accounts { writeln!( w, "{:<44} {}", unsupported_account.address, unsupported_account.err )?; } if gc_alert { writeln!(w)?; writeln!(w, "* Please run `spl-token gc` to clean up Aux accounts")?; } Ok(()) } } impl fmt::Display for CliTokenAccounts { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut gc_alert = false; if self.token_is_some { writeln!(f, "{:<1$}", "Balance", self.max_len_balance)?; writeln!(f, "-------------")?; } else { writeln!( f, "{:<44} {:<2$}", "Token", "Balance", self.max_len_balance )?; writeln!( f, "---------------------------------------------------------------" )?; } for accounts_list in self.accounts.iter() { let mut aux_counter = 1; for account in accounts_list { let maybe_aux = if !account.is_associated { gc_alert = true; let message = format!(" (Aux-{}*)", aux_counter); aux_counter += 1; message } else { "".to_string() }; let maybe_frozen = if let UiAccountState::Frozen = account.account.state { format!(" {} Frozen", WARNING) } else { "".to_string() }; if self.token_is_some { writeln!( f, "{:<3$}{:<4$}{}", account.account.token_amount.real_number_string_trimmed(), maybe_aux, maybe_frozen, self.max_len_balance, self.aux_len, )?; } else { writeln!( f, "{:<44} {:<4$}{:<5$}{}", account.account.mint, account.account.token_amount.real_number_string_trimmed(), maybe_aux, maybe_frozen, self.max_len_balance, self.aux_len, )?; } } } for unsupported_account in &self.unsupported_accounts { writeln!( f, "{:<44} {}", unsupported_account.address, unsupported_account.err )?; } if gc_alert { writeln!(f)?; writeln!(f, "* Please run `spl-token gc` to clean up Aux accounts")?; } Ok(()) } } fn flattened<S: Serializer>( vec: &[Vec<CliTokenAccount>], serializer: S, ) -> Result<S::Ok, S::Error> { let flattened: Vec<_> = vec.iter().flatten().collect(); flattened.serialize(serializer) } pub fn format_output<T>(command_output: T, command_name: &CommandName, config: &Config) -> String where T: Serialize + Display + QuietDisplay + VerboseDisplay, { config.output_format.formatted_string(&CommandOutput { command_name: command_name.to_string(), command_output, }) }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/wasm.rs
use std::{panic, str::FromStr}; use solana_extra_wasm::program::spl_token; use solana_playground_utils_wasm::js::{PgSettings, PgTerminal, PgWallet}; use wasm_bindgen::prelude::*; use crate::{ clap::get_clap, cli::{process_command, BulkSigners, CommandName}, config::get_config, constants::*, }; #[wasm_bindgen(js_name = "runSplToken")] pub async fn run_spl_token(cmd: String) { panic::set_hook(Box::new(console_error_panic_hook::hook)); let default_decimals = format!("{}", spl_token::native_mint::DECIMALS); let default_program_id = spl_token::id().to_string(); let args = cmd.split_ascii_whitespace().collect::<Vec<&str>>(); let match_result = get_clap( COMMAND_NAME, COMMAND_DESC, COMMAND_VERSION, &default_decimals, &default_program_id, ) .try_get_matches_from(args); match match_result { Ok(matches) => { let maybe_matches_subcommand = matches.subcommand(); let (sub_command, sub_matches) = maybe_matches_subcommand.unwrap(); let sub_command = CommandName::from_str(sub_command).unwrap(); let wallet_manager = None; let bulk_signers: BulkSigners = Vec::new(); let connection_settings = PgSettings::connection(); let endpoint = connection_settings.endpoint(); let commitment = connection_settings.commitment(); let keypair_bytes = PgWallet::keypair_bytes(); let config = get_config(sub_matches, &endpoint, &commitment, &keypair_bytes); let output = process_command( sub_command, sub_matches, config, wallet_manager, bulk_signers, ) .await .unwrap_or_else(|e| format!("Process error: {e}")); // Log output PgTerminal::log_wasm(&output); } Err(e) => { // Help or error PgTerminal::log_wasm(&e.to_string()); } }; }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/utils.rs
use clap::ArgMatches; use solana_clap_v3_utils_wasm::{ input_parsers::{pubkey_of, value_of}, nonce::NONCE_ARG, offline::{BLOCKHASH_ARG, SIGN_ONLY_ARG}, }; use solana_client_wasm::utils::rpc_config::BlockhashQuery; pub fn blockhash_query_from_matches(matches: &ArgMatches) -> BlockhashQuery { let blockhash = value_of(matches, BLOCKHASH_ARG.name); let sign_only = matches.is_present(SIGN_ONLY_ARG.name); let nonce_account = pubkey_of(matches, NONCE_ARG.name); BlockhashQuery::new(blockhash, sign_only, nonce_account) }
0
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli
solana_public_repos/solana-playground/solana-playground/wasm/spl-token-cli/src/cli.rs
use std::{collections::HashMap, rc::Rc, str::FromStr, string::ToString}; use clap::ArgMatches; use solana_clap_v3_utils_wasm::{ input_parsers::{pubkey_of_signer, pubkeys_of_multiple_signers, value_of}, keypair::CliSignerInfo, }; use solana_cli_output_wasm::cli_output::{ return_signers_data, CliSignOnlyData, CliSignature, OutputFormat, ReturnSignersConfig, }; use solana_client_wasm::utils::rpc_filter::RpcTokenAccountsFilter; use solana_extra_wasm::{ account_decoder::{ parse_token::{TokenAccountType, UiAccountState}, UiAccountData, }, program::{ spl_associated_token_account::{ get_associated_token_address_with_program_id, instruction::create_associated_token_account, }, spl_memo, spl_token::{ self, instruction::*, native_mint, state::{Account, Mint, Multisig}, }, }, }; use solana_playground_utils_wasm::js::PgTerminal; use solana_remote_wallet::remote_wallet::RemoteWalletManager; use solana_sdk::{ instruction::Instruction, message::Message, native_token::*, program_option::COption, program_pack::Pack, pubkey::Pubkey, signature::{Keypair, Signer}, system_instruction, system_program, transaction::Transaction, }; use strum_macros::{Display, EnumString, IntoStaticStr}; use crate::{ clap::{DELEGATE_ADDRESS_ARG, MINT_ADDRESS_ARG, MINT_DECIMALS_ARG}, config::{get_signer, Config}, output::{ format_output, println_display, CliMint, CliMultisig, CliTokenAccount, CliTokenAccounts, CliTokenAmount, CliWalletAddress, }, sort::sort_and_parse_token_accounts, }; #[derive(Debug, Clone, Copy, PartialEq, EnumString, IntoStaticStr, Display)] #[strum(serialize_all = "kebab-case")] pub enum CommandName { CreateToken, Close, // Bench, CreateAccount, CreateMultisig, Authorize, Transfer, Burn, Mint, Freeze, Thaw, Wrap, Unwrap, Approve, Revoke, Balance, Supply, Accounts, Address, AccountInfo, MultisigInfo, Gc, SyncNative, } pub(crate) type CliError = Box<dyn std::error::Error>; pub(crate) type BulkSigners = Vec<Box<dyn Signer>>; pub(crate) type CommandResult = Result<String, CliError>; fn new_throwaway_signer() -> (Box<dyn Signer>, Pubkey) { let keypair = Keypair::new(); let pubkey = keypair.pubkey(); (Box::new(keypair) as Box<dyn Signer>, pubkey) } pub(crate) async fn check_fee_payer_balance( config: &Config<'_>, required_balance: u64, ) -> Result<(), CliError> { let balance = config.rpc_client.get_balance(&config.fee_payer).await?; if balance < required_balance { Err(format!( "Fee payer, {}, has insufficient balance: {} required, {} available", config.fee_payer, lamports_to_sol(required_balance), lamports_to_sol(balance) ) .into()) } else { Ok(()) } } async fn check_wallet_balance( config: &Config<'_>, wallet: &Pubkey, required_balance: u64, ) -> Result<(), CliError> { let balance = config.rpc_client.get_balance(wallet).await?; if balance < required_balance { Err(format!( "Wallet {}, has insufficient balance: {} required, {} available", wallet, lamports_to_sol(required_balance), lamports_to_sol(balance) ) .into()) } else { Ok(()) } } // type SignersOf = Vec<(Box<dyn Signer>, Pubkey)>; // pub fn signers_of( // matches: &ArgMatches<'_>, // name: &str, // wallet_manager: &mut Option<Arc<RemoteWalletManager>>, // ) -> Result<Option<SignersOf>, Box<dyn std::error::Error>> { // if let Some(values) = matches.values_of(name) { // let mut results = Vec::new(); // for (i, value) in values.enumerate() { // let name = format!("{}-{}", name, i + 1); // let signer = signer_from_path(matches, value, &name, wallet_manager)?; // let signer_pubkey = signer.pubkey(); // results.push((signer, signer_pubkey)); // } // Ok(Some(results)) // } else { // Ok(None) // } // } pub async fn process_command<'a>( sub_command: CommandName, sub_matches: &'a ArgMatches, config: Config<'a>, mut wallet_manager: Option<Rc<RemoteWalletManager>>, mut bulk_signers: BulkSigners, ) -> CommandResult { // NOTE: Client signs by default, could change in the future bulk_signers.push(config.get_default_signer()); match (sub_command, sub_matches) { // (CommandName::Bench, arg_matches) => bench_process_command( // arg_matches, // config, // std::mem::take(&mut bulk_signers), // &mut wallet_manager, // ), (CommandName::CreateToken, arg_matches) => { let decimals = arg_matches.value_of_t_or_exit::<u8>("decimals"); let mint_authority = config.pubkey_or_default(arg_matches, "mint_authority", &mut wallet_manager); let memo = arg_matches.value_of_t::<String>("memo").ok(); let (token_signer, token) = get_signer(arg_matches, "token_keypair", &mut wallet_manager) .unwrap_or_else(new_throwaway_signer); // Token needs to sign bulk_signers.push(token_signer); command_create_token( &config, decimals, token, mint_authority, arg_matches.is_present("enable_freeze"), memo, bulk_signers, ) .await } (CommandName::CreateAccount, arg_matches) => { let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) .unwrap() .unwrap(); // No need to add a signer when creating an associated token account let account = get_signer(arg_matches, "account_keypair", &mut wallet_manager).map( |(signer, account)| { bulk_signers.push(signer); account }, ); let owner = config.pubkey_or_default(arg_matches, "owner", &mut wallet_manager); command_create_account(&config, token, owner, account, bulk_signers).await } (CommandName::CreateMultisig, arg_matches) => { let minimum_signers = value_of::<u8>(arg_matches, "minimum_signers").unwrap(); let multisig_members = pubkeys_of_multiple_signers(arg_matches, "multisig_member", &mut wallet_manager) .unwrap_or_else(|e| { eprintln!("error: {}", e); panic!(); }) .unwrap(); if minimum_signers as usize > multisig_members.len() { eprintln!( "error: MINIMUM_SIGNERS cannot be greater than the number \ of MULTISIG_MEMBERs passed" ); panic!(); } let (signer, account) = get_signer(arg_matches, "address_keypair", &mut wallet_manager) .unwrap_or_else(new_throwaway_signer); bulk_signers.push(signer); command_create_multisig( &config, account, minimum_signers, multisig_members, bulk_signers, ) .await } (CommandName::Authorize, arg_matches) => { let address = pubkey_of_signer(arg_matches, "address", &mut wallet_manager) .unwrap() .unwrap(); let authority_type = arg_matches.value_of("authority_type").unwrap(); let authority_type = match authority_type { "mint" => AuthorityType::MintTokens, "freeze" => AuthorityType::FreezeAccount, "owner" => AuthorityType::AccountOwner, "close" => AuthorityType::CloseAccount, _ => unreachable!(), }; let (authority_signer, authority) = config.signer_or_default(arg_matches, "authority", &mut wallet_manager); bulk_signers.push(authority_signer); let new_authority = pubkey_of_signer(arg_matches, "new_authority", &mut wallet_manager).unwrap(); let force_authorize = arg_matches.is_present("force"); command_authorize( &config, address, authority_type, authority, new_authority, force_authorize, bulk_signers, ) .await } (CommandName::Transfer, arg_matches) => { let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) .unwrap() .unwrap(); let amount = match arg_matches.value_of("amount").unwrap() { "ALL" => None, amount => Some(amount.parse::<f64>().unwrap()), }; let recipient = pubkey_of_signer(arg_matches, "recipient", &mut wallet_manager) .unwrap() .unwrap(); let sender = pubkey_of_signer(arg_matches, "from", &mut wallet_manager).unwrap(); let (owner_signer, owner) = config.signer_or_default(arg_matches, "owner", &mut wallet_manager); bulk_signers.push(owner_signer); let mint_decimals = value_of::<u8>(arg_matches, MINT_DECIMALS_ARG.name); let fund_recipient = arg_matches.is_present("fund_recipient"); let allow_unfunded_recipient = arg_matches.is_present("allow_empty_recipient") || arg_matches.is_present("allow_unfunded_recipient"); let recipient_is_ata_owner = arg_matches.is_present("recipient_is_ata_owner"); let use_unchecked_instruction = arg_matches.is_present("use_unchecked_instruction"); let memo = arg_matches.value_of_t::<String>("memo").ok(); command_transfer( &config, token, amount, recipient, sender, owner, allow_unfunded_recipient, fund_recipient, mint_decimals, recipient_is_ata_owner, use_unchecked_instruction, memo, bulk_signers, arg_matches.is_present("no_wait"), arg_matches.is_present("allow_non_system_account_recipient"), ) .await } (CommandName::Burn, arg_matches) => { let source = pubkey_of_signer(arg_matches, "source", &mut wallet_manager) .unwrap() .unwrap(); let (owner_signer, owner) = config.signer_or_default(arg_matches, "owner", &mut wallet_manager); bulk_signers.push(owner_signer); let amount = arg_matches.value_of_t_or_exit::<f64>("amount"); let mint_address = pubkey_of_signer(arg_matches, MINT_ADDRESS_ARG.name, &mut wallet_manager).unwrap(); let mint_decimals = value_of::<u8>(arg_matches, MINT_DECIMALS_ARG.name); let use_unchecked_instruction = arg_matches.is_present("use_unchecked_instruction"); let memo = arg_matches.value_of_t::<String>("memo").ok(); command_burn( &config, source, owner, amount, mint_address, mint_decimals, use_unchecked_instruction, memo, bulk_signers, ) .await } (CommandName::Mint, arg_matches) => { let (mint_authority_signer, mint_authority) = config.signer_or_default(arg_matches, "mint_authority", &mut wallet_manager); bulk_signers.push(mint_authority_signer); let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager) .unwrap() .unwrap(); let amount = arg_matches.value_of_t_or_exit::<f64>("amount"); let recipient = config.associated_token_address_or_override( arg_matches, "recipient", &mut wallet_manager, ); let mint_decimals = value_of::<u8>(arg_matches, MINT_DECIMALS_ARG.name); let use_unchecked_instruction = arg_matches.is_present("use_unchecked_instruction"); command_mint( &config, token, amount, recipient, mint_decimals, mint_authority, use_unchecked_instruction, bulk_signers, ) .await } (CommandName::Freeze, arg_matches) => { let (freeze_authority_signer, freeze_authority) = config.signer_or_default(arg_matches, "freeze_authority", &mut wallet_manager); bulk_signers.push(freeze_authority_signer); let account = pubkey_of_signer(arg_matches, "account", &mut wallet_manager) .unwrap() .unwrap(); let mint_address = pubkey_of_signer(arg_matches, MINT_ADDRESS_ARG.name, &mut wallet_manager).unwrap(); command_freeze( &config, account, mint_address, freeze_authority, bulk_signers, ) .await } (CommandName::Thaw, arg_matches) => { let (freeze_authority_signer, freeze_authority) = config.signer_or_default(arg_matches, "freeze_authority", &mut wallet_manager); bulk_signers.push(freeze_authority_signer); let account = pubkey_of_signer(arg_matches, "account", &mut wallet_manager) .unwrap() .unwrap(); let mint_address = pubkey_of_signer(arg_matches, MINT_ADDRESS_ARG.name, &mut wallet_manager).unwrap(); command_thaw( &config, account, mint_address, freeze_authority, bulk_signers, ) .await } (CommandName::Wrap, arg_matches) => { let amount = arg_matches.value_of_t_or_exit::<f64>("amount"); let account = if arg_matches.is_present("create_aux_account") { let (signer, account) = new_throwaway_signer(); bulk_signers.push(signer); Some(account) } else { // No need to add a signer when creating an associated token account None }; let (wallet_signer, wallet_address) = config.signer_or_default(arg_matches, "wallet_keypair", &mut wallet_manager); bulk_signers.push(wallet_signer); command_wrap(&config, amount, wallet_address, account, bulk_signers).await } (CommandName::Unwrap, arg_matches) => { let (wallet_signer, wallet_address) = config.signer_or_default(arg_matches, "wallet_keypair", &mut wallet_manager); bulk_signers.push(wallet_signer); let address = pubkey_of_signer(arg_matches, "address", &mut wallet_manager).unwrap(); command_unwrap(&config, wallet_address, address, bulk_signers).await } (CommandName::Approve, arg_matches) => { let (owner_signer, owner_address) = config.signer_or_default(arg_matches, "owner", &mut wallet_manager); bulk_signers.push(owner_signer); let account = pubkey_of_signer(arg_matches, "account", &mut wallet_manager) .unwrap() .unwrap(); let amount = arg_matches.value_of_t_or_exit::<f64>("amount"); let delegate = pubkey_of_signer(arg_matches, "delegate", &mut wallet_manager) .unwrap() .unwrap(); let mint_address = pubkey_of_signer(arg_matches, MINT_ADDRESS_ARG.name, &mut wallet_manager).unwrap(); let mint_decimals = value_of::<u8>(arg_matches, MINT_DECIMALS_ARG.name); let use_unchecked_instruction = arg_matches.is_present("use_unchecked_instruction"); command_approve( &config, account, owner_address, amount, delegate, mint_address, mint_decimals, use_unchecked_instruction, bulk_signers, ) .await } (CommandName::Revoke, arg_matches) => { let (owner_signer, owner_address) = config.signer_or_default(arg_matches, "owner", &mut wallet_manager); bulk_signers.push(owner_signer); let account = pubkey_of_signer(arg_matches, "account", &mut wallet_manager) .unwrap() .unwrap(); let delegate_address = pubkey_of_signer(arg_matches, DELEGATE_ADDRESS_ARG.name, &mut wallet_manager) .unwrap(); command_revoke( &config, account, owner_address, delegate_address, bulk_signers, ) .await } (CommandName::Close, arg_matches) => { let (close_authority_signer, close_authority) = config.signer_or_default(arg_matches, "close_authority", &mut wallet_manager); bulk_signers.push(close_authority_signer); let address = config.associated_token_address_or_override( arg_matches, "address", &mut wallet_manager, ); let recipient = config.pubkey_or_default(arg_matches, "recipient", &mut wallet_manager); command_close(&config, address, close_authority, recipient, bulk_signers).await } (CommandName::Balance, arg_matches) => { let address = config.associated_token_address_or_override( arg_matches, "address", &mut wallet_manager, ); command_balance(&config, address).await } (CommandName::Supply, arg_matches) => { let address = pubkey_of_signer(arg_matches, "address", &mut wallet_manager) .unwrap() .unwrap(); command_supply(&config, address).await } (CommandName::Accounts, arg_matches) => { let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager).unwrap(); let owner = config.pubkey_or_default(arg_matches, "owner", &mut wallet_manager); command_accounts(&config, token, owner).await } (CommandName::Address, arg_matches) => { let token = pubkey_of_signer(arg_matches, "token", &mut wallet_manager).unwrap(); let owner = config.pubkey_or_default(arg_matches, "owner", &mut wallet_manager); command_address(&config, token, owner).await } (CommandName::AccountInfo, arg_matches) => { let address = config.associated_token_address_or_override( arg_matches, "address", &mut wallet_manager, ); command_account_info(&config, address).await } (CommandName::MultisigInfo, arg_matches) => { let address = pubkey_of_signer(arg_matches, "address", &mut wallet_manager) .unwrap() .unwrap(); command_multisig(&config, address).await } (CommandName::Gc, arg_matches) => { match config.output_format { OutputFormat::Json | OutputFormat::JsonCompact => { eprintln!( "`spl-token gc` does not support the `--ouput` parameter at this time" ); panic!(); } _ => {} } let close_empty_associated_accounts = arg_matches.is_present("close_empty_associated_accounts"); let (owner_signer, owner_address) = config.signer_or_default(arg_matches, "owner", &mut wallet_manager); bulk_signers.push(owner_signer); command_gc( &config, owner_address, close_empty_associated_accounts, bulk_signers, ) .await } (CommandName::SyncNative, arg_matches) => { let address = config.associated_token_address_for_token_or_override( arg_matches, "address", &mut wallet_manager, Some(native_mint::id()), ); command_sync_native(&config, address, bulk_signers).await } } } #[allow(clippy::too_many_arguments)] async fn command_create_token( config: &Config<'_>, decimals: u8, token: Pubkey, authority: Pubkey, enable_freeze: bool, memo: Option<String>, bulk_signers: BulkSigners, ) -> CommandResult { println_display(config, format!("Creating token {}", token)); let minimum_balance_for_rent_exemption = if !config.sign_only { config .rpc_client .get_minimum_balance_for_rent_exemption(Mint::LEN) .await? } else { 0 }; let freeze_authority_pubkey = if enable_freeze { Some(authority) } else { None }; let mut instructions = vec![ system_instruction::create_account( &config.fee_payer, &token, minimum_balance_for_rent_exemption, Mint::LEN as u64, &config.program_id, ), initialize_mint( &config.program_id, &token, &authority, freeze_authority_pubkey.as_ref(), decimals, )?, ]; if let Some(text) = memo { instructions.push(spl_memo::build_memo(text.as_bytes(), &[&config.fee_payer])); } let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, minimum_balance_for_rent_exemption, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(cli_signature) => format_output( CliMint { address: token.to_string(), decimals, transaction_data: cli_signature, }, &CommandName::CreateToken, config, ), TransactionReturnData::CliSignOnlyData(cli_sign_only_data) => { format_output(cli_sign_only_data, &CommandName::CreateToken, config) } }) } async fn command_create_account( config: &Config<'_>, token: Pubkey, owner: Pubkey, maybe_account: Option<Pubkey>, bulk_signers: BulkSigners, ) -> CommandResult { let minimum_balance_for_rent_exemption = if !config.sign_only { config .rpc_client .get_minimum_balance_for_rent_exemption(Account::LEN) .await? } else { 0 }; let (account, system_account_ok, instructions) = if let Some(account) = maybe_account { println_display(config, format!("Creating account {}", account)); ( account, false, vec![ system_instruction::create_account( &config.fee_payer, &account, minimum_balance_for_rent_exemption, Account::LEN as u64, &config.program_id, ), initialize_account(&config.program_id, &account, &token, &owner)?, ], ) } else { let account = get_associated_token_address_with_program_id(&owner, &token, &config.program_id); println_display(config, format!("Creating account {}", account)); ( account, true, vec![create_associated_token_account( &config.fee_payer, &owner, &token, &config.program_id, )], ) }; if !config.sign_only { if let Some(account_data) = config .rpc_client .get_account_with_commitment(&account, config.rpc_client.commitment_config()) .await? { if !(account_data.owner == system_program::id() && system_account_ok) { return Err(format!("Error: Account already exists: {}", account).into()); } } } let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, minimum_balance_for_rent_exemption, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_create_multisig( config: &Config<'_>, multisig: Pubkey, minimum_signers: u8, multisig_members: Vec<Pubkey>, bulk_signers: BulkSigners, ) -> CommandResult { println_display( config, format!( "Creating {}/{} multisig {}", minimum_signers, multisig_members.len(), multisig ), ); let minimum_balance_for_rent_exemption = if !config.sign_only { config .rpc_client .get_minimum_balance_for_rent_exemption(Multisig::LEN) .await? } else { 0 }; let instructions = vec![ system_instruction::create_account( &config.fee_payer, &multisig, minimum_balance_for_rent_exemption, Multisig::LEN as u64, &config.program_id, ), initialize_multisig( &config.program_id, &multisig, multisig_members.iter().collect::<Vec<_>>().as_slice(), minimum_signers, )?, ]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, minimum_balance_for_rent_exemption, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } #[allow(clippy::too_many_arguments)] async fn command_authorize( config: &Config<'_>, account: Pubkey, authority_type: AuthorityType, authority: Pubkey, new_authority: Option<Pubkey>, force_authorize: bool, bulk_signers: BulkSigners, ) -> CommandResult { let auth_str = match authority_type { AuthorityType::MintTokens => "mint authority", AuthorityType::FreezeAccount => "freeze authority", AuthorityType::AccountOwner => "owner", AuthorityType::CloseAccount => "close authority", }; let previous_authority = if !config.sign_only { let target_account = config.rpc_client.get_account(&account).await?; if let Ok(mint) = Mint::unpack(&target_account.data) { match authority_type { AuthorityType::AccountOwner | AuthorityType::CloseAccount => Err(format!( "Authority type `{}` not supported for SPL Token mints", auth_str )), AuthorityType::MintTokens => Ok(mint.mint_authority), AuthorityType::FreezeAccount => Ok(mint.freeze_authority), } } else if let Ok(token_account) = Account::unpack(&target_account.data) { let check_associated_token_account = || -> Result<(), CliError> { let maybe_associated_token_account = get_associated_token_address_with_program_id( &token_account.owner, &token_account.mint, &config.program_id, ); if account == maybe_associated_token_account && !force_authorize && Some(authority) != new_authority { Err(format!( "Error: attempting to change the `{}` of an associated token account", auth_str ) .into()) } else { Ok(()) } }; match authority_type { AuthorityType::MintTokens | AuthorityType::FreezeAccount => Err(format!( "Authority type `{}` not supported for SPL Token accounts", auth_str )), AuthorityType::AccountOwner => { check_associated_token_account()?; Ok(COption::Some(token_account.owner)) } AuthorityType::CloseAccount => { check_associated_token_account()?; Ok(COption::Some( token_account.close_authority.unwrap_or(token_account.owner), )) } } } else { Err("Unsupported account data format".to_string()) }? } else { COption::None }; println_display( config, format!( "Updating {}\n Current {}: {}\n New {}: {}", account, auth_str, previous_authority .map(|pubkey| pubkey.to_string()) .unwrap_or_else(|| "disabled".to_string()), auth_str, new_authority .map(|pubkey| pubkey.to_string()) .unwrap_or_else(|| "disabled".to_string()) ), ); let instructions = vec![set_authority( &config.program_id, &account, new_authority.as_ref(), authority_type, &authority, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } pub(crate) async fn resolve_mint_info( config: &Config<'_>, token_account: &Pubkey, mint_address: Option<Pubkey>, mint_decimals: Option<u8>, ) -> Result<(Pubkey, u8), CliError> { if !config.sign_only { let source_account = config .rpc_client .get_token_account(token_account) .await? .ok_or_else(|| format!("Could not find token account {}", token_account))?; let source_mint = Pubkey::from_str(&source_account.mint)?; if let Some(mint) = mint_address { if source_mint != mint { return Err(format!( "Source {:?} does not contain {:?} tokens", token_account, mint ) .into()); } } Ok((source_mint, source_account.token_amount.decimals)) } else { Ok(( mint_address.unwrap_or_default(), mint_decimals.unwrap_or_default(), )) } } async fn validate_mint(config: &Config<'_>, token: Pubkey) -> Result<(), CliError> { let mint = config.rpc_client.get_account(&token).await; if mint.is_err() || Mint::unpack(&mint.unwrap().data).is_err() { return Err(format!("Invalid mint account {:?}", token).into()); } Ok(()) } #[allow(clippy::too_many_arguments)] async fn command_transfer( config: &Config<'_>, token: Pubkey, ui_amount: Option<f64>, recipient: Pubkey, sender: Option<Pubkey>, sender_owner: Pubkey, allow_unfunded_recipient: bool, fund_recipient: bool, mint_decimals: Option<u8>, recipient_is_ata_owner: bool, use_unchecked_instruction: bool, memo: Option<String>, bulk_signers: BulkSigners, no_wait: bool, allow_non_system_account_recipient: bool, ) -> CommandResult { let sender = if let Some(sender) = sender { sender } else { get_associated_token_address_with_program_id(&sender_owner, &token, &config.program_id) }; let (mint_pubkey, decimals) = resolve_mint_info(config, &sender, Some(token), mint_decimals).await?; let maybe_transfer_balance = ui_amount.map(|ui_amount| spl_token::ui_amount_to_amount(ui_amount, decimals)); let transfer_balance = if !config.sign_only { let sender_token_amount = config .rpc_client .get_token_account_balance(&sender) .await .map_err(|err| { format!( "Error: Failed to get token balance of sender address {}: {}", sender, err ) })?; let sender_balance = sender_token_amount.amount.parse::<u64>().map_err(|err| { format!( "Token account {} balance could not be parsed: {}", sender, err ) })?; let transfer_balance = maybe_transfer_balance.unwrap_or(sender_balance); println_display( config, format!( "Transfer {} tokens\n Sender: {}\n Recipient: {}", spl_token::amount_to_ui_amount(transfer_balance, decimals), sender, recipient ), ); if transfer_balance > sender_balance { return Err(format!( "Error: Sender has insufficient funds, current balance is {}", sender_token_amount.real_number_string_trimmed() ) .into()); } transfer_balance } else { maybe_transfer_balance.unwrap() }; let mut instructions = vec![]; let mut recipient_token_account = recipient; let mut minimum_balance_for_rent_exemption = 0; let recipient_is_token_account = if !config.sign_only { let recipient_account_info = config .rpc_client .get_account_with_commitment(&recipient, config.rpc_client.commitment_config()) .await? .map(|account| { ( account.owner == config.program_id && account.data.len() == Account::LEN, account.owner == system_program::id(), ) }); if let Some((recipient_is_token_account, recipient_is_system_account)) = recipient_account_info { if !recipient_is_token_account && !recipient_is_system_account && !allow_non_system_account_recipient { return Err("Error: The recipient address is not owned by the System Program. \ Add `--allow-non-system-account-recipient` to complete the transfer. \ ".into()); } } else if recipient_account_info.is_none() && !allow_unfunded_recipient { return Err("Error: The recipient address is not funded. \ Add `--allow-unfunded-recipient` to complete the transfer. \ " .into()); } recipient_account_info .map(|(recipient_is_token_account, _)| recipient_is_token_account) .unwrap_or(false) } else { !recipient_is_ata_owner }; if !recipient_is_token_account { recipient_token_account = get_associated_token_address_with_program_id( &recipient, &mint_pubkey, &config.program_id, ); println_display( config, format!( " Recipient associated token account: {}", recipient_token_account ), ); let needs_funding = if !config.sign_only { if let Some(recipient_token_account_data) = config .rpc_client .get_account_with_commitment( &recipient_token_account, config.rpc_client.commitment_config(), ) .await? { if recipient_token_account_data.owner == system_program::id() { true } else if recipient_token_account_data.owner == config.program_id { false } else { return Err( format!("Error: Unsupported recipient address: {}", recipient).into(), ); } } else { true } } else { fund_recipient }; if needs_funding { if fund_recipient { if !config.sign_only { minimum_balance_for_rent_exemption += config .rpc_client .get_minimum_balance_for_rent_exemption(Account::LEN) .await?; println_display( config, format!( " Funding recipient: {} ({} SOL)", recipient_token_account, lamports_to_sol(minimum_balance_for_rent_exemption) ), ); } instructions.push(create_associated_token_account( &config.fee_payer, &recipient, &mint_pubkey, &config.program_id, )); } else { return Err( "Error: Recipient's associated token account does not exist. \ Add `--fund-recipient` to fund their account" .into(), ); } } } if use_unchecked_instruction { instructions.push(transfer( &config.program_id, &sender, &recipient_token_account, &sender_owner, &config.multisigner_pubkeys, transfer_balance, )?); } else { instructions.push(transfer_checked( &config.program_id, &sender, &mint_pubkey, &recipient_token_account, &sender_owner, &config.multisigner_pubkeys, transfer_balance, decimals, )?); } if let Some(text) = memo { instructions.push(spl_memo::build_memo(text.as_bytes(), &[&config.fee_payer])); } let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, no_wait, minimum_balance_for_rent_exemption, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } #[allow(clippy::too_many_arguments)] async fn command_burn( config: &Config<'_>, source: Pubkey, source_owner: Pubkey, ui_amount: f64, mint_address: Option<Pubkey>, mint_decimals: Option<u8>, use_unchecked_instruction: bool, memo: Option<String>, bulk_signers: BulkSigners, ) -> CommandResult { println_display( config, format!("Burn {} tokens\n Source: {}", ui_amount, source), ); let (mint_pubkey, decimals) = resolve_mint_info(config, &source, mint_address, mint_decimals).await?; let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); let mut instructions = if use_unchecked_instruction { vec![burn( &config.program_id, &source, &mint_pubkey, &source_owner, &config.multisigner_pubkeys, amount, )?] } else { vec![burn_checked( &config.program_id, &source, &mint_pubkey, &source_owner, &config.multisigner_pubkeys, amount, decimals, )?] }; if let Some(text) = memo { instructions.push(spl_memo::build_memo(text.as_bytes(), &[&config.fee_payer])); } let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } #[allow(clippy::too_many_arguments)] async fn command_mint( config: &Config<'_>, token: Pubkey, ui_amount: f64, recipient: Pubkey, mint_decimals: Option<u8>, mint_authority: Pubkey, use_unchecked_instruction: bool, bulk_signers: BulkSigners, ) -> CommandResult { println_display( config, format!( "Minting {} tokens\n Token: {}\n Recipient: {}", ui_amount, token, recipient ), ); let (_, decimals) = resolve_mint_info(config, &recipient, None, mint_decimals).await?; let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); let instructions = if use_unchecked_instruction { vec![mint_to( &config.program_id, &token, &recipient, &mint_authority, &config.multisigner_pubkeys, amount, )?] } else { vec![mint_to_checked( &config.program_id, &token, &recipient, &mint_authority, &config.multisigner_pubkeys, amount, decimals, )?] }; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_freeze( config: &Config<'_>, account: Pubkey, mint_address: Option<Pubkey>, freeze_authority: Pubkey, bulk_signers: BulkSigners, ) -> CommandResult { let (token, _) = resolve_mint_info(config, &account, mint_address, None).await?; println_display( config, format!("Freezing account: {}\n Token: {}", account, token), ); let instructions = vec![freeze_account( &config.program_id, &account, &token, &freeze_authority, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_thaw( config: &Config<'_>, account: Pubkey, mint_address: Option<Pubkey>, freeze_authority: Pubkey, bulk_signers: BulkSigners, ) -> CommandResult { let (token, _) = resolve_mint_info(config, &account, mint_address, None).await?; println_display( config, format!("Thawing account: {}\n Token: {}", account, token), ); let instructions = vec![thaw_account( &config.program_id, &account, &token, &freeze_authority, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_wrap( config: &Config<'_>, sol: f64, wallet_address: Pubkey, wrapped_sol_account: Option<Pubkey>, bulk_signers: BulkSigners, ) -> CommandResult { let lamports = sol_to_lamports(sol); let instructions = if let Some(wrapped_sol_account) = wrapped_sol_account { println_display( config, format!("Wrapping {} SOL into {}", sol, wrapped_sol_account), ); vec![ system_instruction::create_account( &wallet_address, &wrapped_sol_account, lamports, Account::LEN as u64, &config.program_id, ), initialize_account( &config.program_id, &wrapped_sol_account, &native_mint::id(), &wallet_address, )?, ] } else { let account = get_associated_token_address_with_program_id( &wallet_address, &native_mint::id(), &config.program_id, ); if !config.sign_only { if let Some(account_data) = config .rpc_client .get_account_with_commitment(&account, config.rpc_client.commitment_config()) .await? { if account_data.owner != system_program::id() { return Err(format!("Error: Account already exists: {}", account).into()); } } } println_display(config, format!("Wrapping {} SOL into {}", sol, account)); vec![ system_instruction::transfer(&wallet_address, &account, lamports), create_associated_token_account( &config.fee_payer, &wallet_address, &native_mint::id(), &config.program_id, ), ] }; if !config.sign_only { check_wallet_balance(config, &wallet_address, lamports).await?; } let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_unwrap( config: &Config<'_>, wallet_address: Pubkey, address: Option<Pubkey>, bulk_signers: BulkSigners, ) -> CommandResult { let use_associated_account = address.is_none(); let address = address.unwrap_or_else(|| { get_associated_token_address_with_program_id( &wallet_address, &native_mint::id(), &config.program_id, ) }); println_display(config, format!("Unwrapping {}", address)); if !config.sign_only { let lamports = config.rpc_client.get_balance(&address).await?; if lamports == 0 { if use_associated_account { return Err("No wrapped SOL in associated account; did you mean to specify an auxiliary address?".to_string().into()); } else { return Err(format!("No wrapped SOL in {}", address).into()); } } println_display( config, format!(" Amount: {} SOL", lamports_to_sol(lamports)), ); } println_display(config, format!(" Recipient: {}", &wallet_address)); let instructions = vec![close_account( &config.program_id, &address, &wallet_address, &wallet_address, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } #[allow(clippy::too_many_arguments)] async fn command_approve( config: &Config<'_>, account: Pubkey, owner: Pubkey, ui_amount: f64, delegate: Pubkey, mint_address: Option<Pubkey>, mint_decimals: Option<u8>, use_unchecked_instruction: bool, bulk_signers: BulkSigners, ) -> CommandResult { println_display( config, format!( "Approve {} tokens\n Account: {}\n Delegate: {}", ui_amount, account, delegate ), ); let (mint_pubkey, decimals) = resolve_mint_info(config, &account, mint_address, mint_decimals).await?; let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); let instructions = if use_unchecked_instruction { vec![approve( &config.program_id, &account, &delegate, &owner, &config.multisigner_pubkeys, amount, )?] } else { vec![approve_checked( &config.program_id, &account, &mint_pubkey, &delegate, &owner, &config.multisigner_pubkeys, amount, decimals, )?] }; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_revoke( config: &Config<'_>, account: Pubkey, owner: Pubkey, delegate: Option<Pubkey>, bulk_signers: BulkSigners, ) -> CommandResult { let delegate = if !config.sign_only { let source_account = config .rpc_client .get_token_account(&account) .await? .ok_or_else(|| format!("Could not find token account {}", account))?; if let Some(string) = source_account.delegate { Some(Pubkey::from_str(&string)?) } else { None } } else { delegate }; if let Some(delegate) = delegate { println_display( config, format!( "Revoking approval\n Account: {}\n Delegate: {}", account, delegate ), ); } else { return Err(format!("No delegate on account {}", account).into()); } let instructions = vec![revoke( &config.program_id, &account, &owner, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_close( config: &Config<'_>, account: Pubkey, close_authority: Pubkey, recipient: Pubkey, bulk_signers: BulkSigners, ) -> CommandResult { if !config.sign_only { let source_account = config .rpc_client .get_token_account(&account) .await? .ok_or_else(|| format!("Could not find token account {}", account))?; let source_amount = source_account .token_amount .amount .parse::<u64>() .map_err(|err| { format!( "Token account {} balance could not be parsed: {}", account, err ) })?; if !source_account.is_native && source_amount > 0 { return Err(format!( "Account {} still has {} tokens; empty the account in order to close it.", account, source_account.token_amount.real_number_string_trimmed() ) .into()); } } let instructions = vec![close_account( &config.program_id, &account, &recipient, &close_authority, &config.multisigner_pubkeys, )?]; let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, instructions, ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } async fn command_balance(config: &Config<'_>, address: Pubkey) -> CommandResult { let balance = config .rpc_client .get_token_account_balance(&address) .await .map_err(|_| format!("Could not find token account {}", address))?; let cli_token_amount = CliTokenAmount { amount: balance }; Ok(config.output_format.formatted_string(&cli_token_amount)) } async fn command_supply(config: &Config<'_>, address: Pubkey) -> CommandResult { let supply = config.rpc_client.get_token_supply(&address).await?; let cli_token_amount = CliTokenAmount { amount: supply }; Ok(config.output_format.formatted_string(&cli_token_amount)) } async fn command_accounts( config: &Config<'_>, token: Option<Pubkey>, owner: Pubkey, ) -> CommandResult { if let Some(token) = token { validate_mint(config, token).await?; } let accounts = config .rpc_client .get_token_accounts_by_owner( &owner, match token { Some(token) => RpcTokenAccountsFilter::Mint(token), None => RpcTokenAccountsFilter::ProgramId(config.program_id), }, ) .await?; if accounts.is_empty() { PgTerminal::log_wasm("None"); return Ok("".to_string()); } let (mint_accounts, unsupported_accounts, max_len_balance, includes_aux) = sort_and_parse_token_accounts(&owner, accounts, &config.program_id); let aux_len = if includes_aux { 10 } else { 0 }; let cli_token_accounts = CliTokenAccounts { accounts: mint_accounts.into_values().collect(), unsupported_accounts, max_len_balance, aux_len, token_is_some: token.is_some(), }; Ok(config.output_format.formatted_string(&cli_token_accounts)) } async fn command_address( config: &Config<'_>, token: Option<Pubkey>, owner: Pubkey, ) -> CommandResult { let mut cli_address = CliWalletAddress { wallet_address: owner.to_string(), ..CliWalletAddress::default() }; if let Some(token) = token { validate_mint(config, token).await?; let associated_token_address = get_associated_token_address_with_program_id(&owner, &token, &config.program_id); cli_address.associated_token_address = Some(associated_token_address.to_string()); } Ok(config.output_format.formatted_string(&cli_address)) } async fn command_account_info(config: &Config<'_>, address: Pubkey) -> CommandResult { let account = config .rpc_client .get_token_account(&address) .await .map_err(|_| format!("Could not find token account {}", address))? .unwrap(); let mint = Pubkey::from_str(&account.mint).unwrap(); let owner = Pubkey::from_str(&account.owner).unwrap(); let is_associated = get_associated_token_address_with_program_id(&owner, &mint, &config.program_id) == address; let cli_token_account = CliTokenAccount { address: address.to_string(), is_associated, account, }; Ok(config.output_format.formatted_string(&cli_token_account)) } async fn get_multisig(config: &Config<'_>, address: &Pubkey) -> Result<Multisig, CliError> { let account = config.rpc_client.get_account(address).await?; Multisig::unpack(&account.data).map_err(|e| e.into()) } async fn command_multisig(config: &Config<'_>, address: Pubkey) -> CommandResult { let multisig = get_multisig(config, &address).await?; let n = multisig.n as usize; assert!(n <= multisig.signers.len()); let cli_multisig = CliMultisig { address: address.to_string(), m: multisig.m, n: multisig.n, signers: multisig .signers .iter() .enumerate() .filter_map(|(i, signer)| { if i < n { Some(signer.to_string()) } else { None } }) .collect(), }; Ok(config.output_format.formatted_string(&cli_multisig)) } async fn command_gc( config: &Config<'_>, owner: Pubkey, close_empty_associated_accounts: bool, bulk_signers: BulkSigners, ) -> CommandResult { println_display(config, "Fetching token accounts".to_string()); let accounts = config .rpc_client .get_token_accounts_by_owner(&owner, RpcTokenAccountsFilter::ProgramId(config.program_id)) .await?; if accounts.is_empty() { println_display(config, "Nothing to do".to_string()); return Ok("".to_string()); } let minimum_balance_for_rent_exemption = if !config.sign_only { config .rpc_client .get_minimum_balance_for_rent_exemption(Account::LEN) .await? } else { 0 }; let mut accounts_by_token = HashMap::new(); for keyed_account in accounts { if let UiAccountData::Json(parsed_account) = keyed_account.account.data { if parsed_account.program == "spl-token" { if let Ok(TokenAccountType::Account(ui_token_account)) = serde_json::from_value(parsed_account.parsed) { let frozen = ui_token_account.state == UiAccountState::Frozen; let token = ui_token_account .mint .parse::<Pubkey>() .unwrap_or_else(|err| panic!("Invalid mint: {}", err)); let token_account = keyed_account .pubkey .parse::<Pubkey>() .unwrap_or_else(|err| panic!("Invalid token account: {}", err)); let token_amount = ui_token_account .token_amount .amount .parse::<u64>() .unwrap_or_else(|err| panic!("Invalid token amount: {}", err)); let close_authority = ui_token_account.close_authority.map_or(owner, |s| { s.parse::<Pubkey>() .unwrap_or_else(|err| panic!("Invalid close authority: {}", err)) }); let entry = accounts_by_token.entry(token).or_insert_with(HashMap::new); entry.insert( token_account, ( token_amount, ui_token_account.token_amount.decimals, frozen, close_authority, ), ); } } } } let mut instructions = vec![]; let mut lamports_needed = 0; for (token, accounts) in accounts_by_token.into_iter() { println_display(config, format!("Processing token: {}", token)); let associated_token_account = get_associated_token_address_with_program_id(&owner, &token, &config.program_id); let total_balance: u64 = accounts.values().map(|account| account.0).sum(); if total_balance > 0 && !accounts.contains_key(&associated_token_account) { // Create the associated token account instructions.push(vec![create_associated_token_account( &config.fee_payer, &owner, &token, &config.program_id, )]); lamports_needed += minimum_balance_for_rent_exemption; } for (address, (amount, decimals, frozen, close_authority)) in accounts { match ( address == associated_token_account, close_empty_associated_accounts, total_balance > 0, ) { (true, _, true) => continue, // don't ever close associated token account with amount (true, false, _) => continue, // don't close associated token account if close_empty_associated_accounts isn't set (true, true, false) => println_display( config, format!("Closing Account {}", associated_token_account), ), _ => {} } if frozen { // leave frozen accounts alone continue; } let mut account_instructions = vec![]; // Sanity check! // we shouldn't ever be here, but if we are here, abort! assert!(amount == 0 || address != associated_token_account); if amount > 0 { // Transfer the account balance into the associated token account account_instructions.push(transfer_checked( &config.program_id, &address, &token, &associated_token_account, &owner, &config.multisigner_pubkeys, amount, decimals, )?); } // Close the account if config.owner is able to if close_authority == owner { account_instructions.push(close_account( &config.program_id, &address, &owner, &owner, &config.multisigner_pubkeys, )?); } if !account_instructions.is_empty() { instructions.push(account_instructions); } } } let cli_signer_info = CliSignerInfo { signers: bulk_signers, }; let mut result = String::from(""); for tx_instructions in instructions { let tx_return = handle_tx( &cli_signer_info, config, false, lamports_needed, tx_instructions, ) .await?; result += &match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }; result += "\n"; } Ok(result) } async fn command_sync_native( config: &Config<'_>, native_account_address: Pubkey, bulk_signers: BulkSigners, ) -> CommandResult { let tx_return = handle_tx( &CliSignerInfo { signers: bulk_signers, }, config, false, 0, vec![sync_native(&config.program_id, &native_account_address)?], ) .await?; Ok(match tx_return { TransactionReturnData::CliSignature(signature) => { config.output_format.formatted_string(&signature) } TransactionReturnData::CliSignOnlyData(sign_only_data) => { config.output_format.formatted_string(&sign_only_data) } }) } enum TransactionReturnData { CliSignature(CliSignature), CliSignOnlyData(CliSignOnlyData), } async fn handle_tx( signer_info: &CliSignerInfo, config: &Config<'_>, no_wait: bool, minimum_balance_for_rent_exemption: u64, instructions: Vec<Instruction>, ) -> Result<TransactionReturnData, Box<dyn std::error::Error>> { let fee_payer = Some(&config.fee_payer); let message = if let Some(nonce_account) = config.nonce_account.as_ref() { Message::new_with_nonce( instructions, fee_payer, nonce_account, config.nonce_authority.as_ref().unwrap(), ) } else { Message::new(&instructions, fee_payer) }; let recent_blockhash = config .blockhash_query .get_blockhash(&config.rpc_client, config.rpc_client.commitment_config()) .await?; let fee = config.rpc_client.get_fee_for_message(&message).await?; if !config.sign_only { check_fee_payer_balance(config, minimum_balance_for_rent_exemption + fee).await?; } let signers = signer_info.signers_for_message(&message); let mut transaction = Transaction::new_unsigned(message); if config.sign_only { transaction.try_partial_sign(&signers, recent_blockhash)?; Ok(TransactionReturnData::CliSignOnlyData(return_signers_data( &transaction, &ReturnSignersConfig { dump_transaction_message: config.dump_transaction_message, }, ))) } else { transaction.try_sign(&signers, recent_blockhash)?; let signature = if no_wait { config.rpc_client.send_transaction(&transaction).await? } else { // TODO: config .rpc_client .send_and_confirm_transaction(&transaction) .await? }; Ok(TransactionReturnData::CliSignature(CliSignature { signature: signature.to_string(), })) } }
0
solana_public_repos/solana-playground/solana-playground/wasm
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/Cargo.toml
[package] name = "solana-client-wasm" version = "1.18.0" # mirror solana-sdk version description = "Solana non-blocking WASM RPC client." authors = ["Acheron <acheroncrypto@gmail.com>"] repository = "https://github.com/solana-playground/solana-playground" license = "Apache-2.0" homepage = "https://beta.solpg.io" edition = "2021" keywords = ["solana", "wasm", "client", "rpc", "playground"] readme = "README.md" [features] pubsub = ["web-sys/MessageEvent", "web-sys/WebSocket", "wasm-bindgen", "wasm-bindgen-futures"] [dependencies] base64 = "0.13" bincode = "1.3" bs58 = "0.4" futures = "0.3" gloo-net = "0.6" gloo-timers = { version = "0.3", features = ["futures"] } http = "1.0" serde = "1" serde_derive = "1" serde_json = "1" serde_tuple = "0.5" serde_with = "3.9" solana-extra-wasm = { path = "../utils/solana-extra", version = "=1.18.0" } solana-sdk = "~1.18" thiserror = "1" wasm-bindgen = { version = "0.2.88", optional = true } wasm-bindgen-futures = { version = "0.4.38", optional = true } web-sys = { version = "0.3.65", features = ["AbortController", "MessageEvent", "WebSocket"] } [dev-dependencies] wasm-bindgen-test = "0.3.38"
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/response.rs
use serde::Deserialize; #[derive(Debug, Deserialize)] pub struct ClientResponse<T> { pub id: u32, pub jsonrpc: String, pub result: T, }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/request.rs
use serde::Serialize; use serde_json::Value; use serde_with::serde_as; #[serde_as] #[derive(Debug, Serialize)] pub struct ClientRequest { id: u32, jsonrpc: &'static str, method: String, #[serde(skip_serializing_if = "is_null")] params: Value, } impl ClientRequest { pub fn new(method: impl ToString) -> Self { Self { id: 0, jsonrpc: "2.0", method: method.to_string(), params: Value::Null, } } pub fn id(mut self, id: u32) -> Self { self.id = id; self } pub fn jsonrpc(mut self, jsonrpc: &'static str) -> Self { self.jsonrpc = jsonrpc; self } pub fn params<T: Serialize>(mut self, params: T) -> Self { self.params = serde_json::to_value(params).unwrap_or_default(); self } } fn is_null(v: &Value) -> bool { match v { Value::Null => true, Value::Array(a) => a.iter().all(|el| el.is_null()), _ => false, } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/constants.rs
pub const MAX_RETRIES: usize = 5; pub const SLEEP_MS: u64 = 2000;
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/client.rs
use serde::de::DeserializeOwned; use solana_extra_wasm::{ account_decoder::{ parse_token::UiTokenAccount, parse_token::{TokenAccountType, UiTokenAmount}, UiAccountData, UiAccountEncoding, }, transaction_status::{ EncodedConfirmedTransactionWithStatusMeta, TransactionConfirmationStatus, UiConfirmedBlock, UiTransactionEncoding, }, utils::sleep, }; use solana_sdk::{ account::Account, clock::{Epoch, Slot, UnixTimestamp}, commitment_config::{CommitmentConfig, CommitmentLevel}, epoch_info::EpochInfo, epoch_schedule::EpochSchedule, hash::Hash, message::Message, pubkey::Pubkey, signature::Signature, transaction::Transaction, }; use crate::{ constants::{MAX_RETRIES, SLEEP_MS}, methods::*, provider::Provider, utils::{ rpc_config::{ GetConfirmedSignaturesForAddress2Config, RpcAccountInfoConfig, RpcBlockConfig, RpcBlockProductionConfig, RpcContextConfig, RpcEpochConfig, RpcGetVoteAccountsConfig, RpcKeyedAccount, RpcLargestAccountsConfig, RpcLeaderScheduleConfig, RpcProgramAccountsConfig, RpcSendTransactionConfig, RpcSignaturesForAddressConfig, RpcSimulateTransactionConfig, RpcSupplyConfig, RpcTransactionConfig, }, rpc_filter::RpcTokenAccountsFilter, rpc_response::{ RpcAccountBalance, RpcBlockProduction, RpcConfirmedTransactionStatusWithSignature, RpcInflationGovernor, RpcInflationRate, RpcInflationReward, RpcLeaderSchedule, RpcPerfSample, RpcSupply, RpcVersionInfo, RpcVoteAccountStatus, }, }, ClientError, ClientResponse, ClientResult, }; pub struct WasmClient { provider: Provider, commitment_config: CommitmentConfig, #[cfg(feature = "pubsub")] pub(crate) ws: crate::pubsub::WasmWebSocket, } impl WasmClient { /// Create a [`WasmClient`]. /// /// Default commitment is `confirmed` unlike default Solana Client. pub fn new(endpoint: &str) -> Self { Self { provider: Provider::new(endpoint), commitment_config: CommitmentConfig::confirmed(), #[cfg(feature = "pubsub")] ws: crate::pubsub::WasmWebSocket::new(endpoint), } } pub fn new_with_commitment(endpoint: &str, commitment_config: CommitmentConfig) -> Self { Self { provider: Provider::new(endpoint), commitment_config, #[cfg(feature = "pubsub")] ws: crate::pubsub::WasmWebSocket::new(endpoint), } } pub fn commitment(&self) -> CommitmentLevel { self.commitment_config.commitment } pub fn commitment_config(&self) -> CommitmentConfig { self.commitment_config } async fn send<T: Method, R: DeserializeOwned>(&self, request: T) -> ClientResult<R> { let Provider::Http(provider) = &self.provider; provider.send(&request).await?.result } pub async fn get_balance_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<u64> { let request = GetBalanceRequest::new_with_config(*pubkey, commitment_config); let response: GetBalanceResponse = self.send(request).await?; Ok(response.value) } pub async fn get_balance(&self, pubkey: &Pubkey) -> ClientResult<u64> { self.get_balance_with_commitment(pubkey, self.commitment_config()) .await } pub async fn request_airdrop(&self, pubkey: &Pubkey, lamports: u64) -> ClientResult<Signature> { let request = RequestAirdropRequest::new(*pubkey, lamports); let response: ClientResponse<RequestAirdropResponse> = self.send(request).await?; Ok(response.result.into()) } pub async fn get_signature_statuses( &self, signatures: &[Signature], ) -> ClientResult<Vec<Option<SignatureStatusesValue>>> { let request = GetSignatureStatusesRequest::new(signatures.into()); let response: GetSignatureStatusesResponse = self.send(request).await?; Ok(response.value) } pub async fn get_transaction_with_config( &self, signature: &Signature, config: RpcTransactionConfig, ) -> ClientResult<EncodedConfirmedTransactionWithStatusMeta> { let request = GetTransactionRequest::new_with_config(*signature, config); let response: GetTransactionResponse = self.send(request).await?; match response.into() { Some(result) => Ok(result), None => Err(ClientError::new(format!( "Signature {signature} not found." ))), } } pub async fn get_account_with_config( &self, pubkey: &Pubkey, config: RpcAccountInfoConfig, ) -> ClientResult<Option<Account>> { let request = GetAccountInfoRequest::new_with_config(*pubkey, config); let response: GetAccountInfoResponse = self.send(request).await?; match response.value { Some(ui_account) => Ok(ui_account.decode()), None => Ok(None), } } pub async fn get_account_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<Option<Account>> { self.get_account_with_config( pubkey, RpcAccountInfoConfig { commitment: Some(commitment_config), encoding: Some(UiAccountEncoding::Base64), ..Default::default() }, ) .await } pub async fn get_account(&self, pubkey: &Pubkey) -> ClientResult<Account> { self.get_account_with_commitment(pubkey, self.commitment_config()) .await? .ok_or_else(|| ClientError::new(format!("Account {} not found.", pubkey))) } pub async fn get_account_data(&self, pubkey: &Pubkey) -> ClientResult<Vec<u8>> { Ok(self.get_account(pubkey).await?.data) } pub async fn get_latest_blockhash_with_config( &self, commitment_config: CommitmentConfig, ) -> ClientResult<(Hash, u64)> { let request = GetLatestBlockhashRequest::new_with_config(commitment_config); let response: GetLatestBlockhashResponse = self.send(request).await?; let hash = response .value .blockhash .parse() .map_err(|_| ClientError::new("Hash not parsable."))?; Ok((hash, response.value.last_valid_block_height)) } pub async fn get_latest_blockhash_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<(Hash, u64)> { self.get_latest_blockhash_with_config(commitment_config) .await } pub async fn get_latest_blockhash(&self) -> ClientResult<Hash> { let result = self .get_latest_blockhash_with_commitment(self.commitment_config()) .await?; Ok(result.0) } pub async fn is_blockhash_valid( &self, blockhash: &Hash, commitment_config: CommitmentConfig, ) -> ClientResult<bool> { let request = IsBlockhashValidRequest::new_with_config( *blockhash, RpcContextConfig { commitment: Some(commitment_config), min_context_slot: None, }, ); let response: IsBlockhashValidResponse = self.send(request).await?; Ok(response.value) } pub async fn get_minimum_balance_for_rent_exemption( &self, data_len: usize, ) -> ClientResult<u64> { let request = GetMinimumBalanceForRentExemptionRequest::new(data_len); let response: GetMinimumBalanceForRentExemptionResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_fee_for_message(&self, message: &Message) -> ClientResult<u64> { let request = GetFeeForMessageRequest::new(message.to_owned()); let response: GetFeeForMessageResponse = self.send(request).await?; Ok(response.into()) } pub async fn send_transaction_with_config( &self, transaction: &Transaction, config: RpcSendTransactionConfig, ) -> ClientResult<Signature> { let request = SendTransactionRequest::new_with_config(transaction.to_owned(), config); let response: SendTransactionResponse = self.send(request).await?; let signature: Signature = response.into(); // A mismatching RPC response signature indicates an issue with the RPC node, and // should not be passed along to confirmation methods. The transaction may or may // not have been submitted to the cluster, so callers should verify the success of // the correct transaction signature independently. if signature != transaction.signatures[0] { Err(ClientError::new(format!( "RPC node returned mismatched signature {:?}, expected {:?}", signature, transaction.signatures[0] ))) } else { Ok(transaction.signatures[0]) } } pub async fn send_transaction(&self, transaction: &Transaction) -> ClientResult<Signature> { self.send_transaction_with_config( transaction, RpcSendTransactionConfig { preflight_commitment: Some(self.commitment()), encoding: Some(UiTransactionEncoding::Base64), ..Default::default() }, ) .await } pub async fn confirm_transaction_with_commitment( &self, signature: &Signature, commitment_config: CommitmentConfig, ) -> ClientResult<bool> { let mut is_success = false; for _ in 0..MAX_RETRIES { let signature_statuses = self.get_signature_statuses(&[*signature]).await?; if let Some(signature_status) = signature_statuses[0].as_ref() { if signature_status.confirmation_status.is_some() { let current_commitment = signature_status.confirmation_status.as_ref().unwrap(); let commitment_matches = match commitment_config.commitment { CommitmentLevel::Finalized => { matches!(current_commitment, TransactionConfirmationStatus::Finalized) } CommitmentLevel::Confirmed => matches!( current_commitment, TransactionConfirmationStatus::Finalized | TransactionConfirmationStatus::Confirmed ), _ => true, }; if commitment_matches { is_success = signature_status.err.is_none(); break; } } } sleep(SLEEP_MS).await; } Ok(is_success) } pub async fn confirm_transaction(&self, signature: &Signature) -> ClientResult<bool> { self.confirm_transaction_with_commitment(signature, self.commitment_config()) .await } pub async fn send_and_confirm_transaction_with_config( &self, transaction: &Transaction, commitment_config: CommitmentConfig, config: RpcSendTransactionConfig, ) -> ClientResult<Signature> { let tx_hash = self .send_transaction_with_config(transaction, config) .await?; self.confirm_transaction_with_commitment(&tx_hash, commitment_config) .await?; Ok(tx_hash) } pub async fn send_and_confirm_transaction_with_commitment( &self, transaction: &Transaction, commitment_config: CommitmentConfig, ) -> ClientResult<Signature> { self.send_and_confirm_transaction_with_config( transaction, commitment_config, RpcSendTransactionConfig { preflight_commitment: Some(commitment_config.commitment), encoding: Some(UiTransactionEncoding::Base64), ..Default::default() }, ) .await } pub async fn send_and_confirm_transaction( &self, transaction: &Transaction, ) -> ClientResult<Signature> { self.send_and_confirm_transaction_with_commitment(transaction, self.commitment_config()) .await } pub async fn get_program_accounts_with_config( &self, pubkey: &Pubkey, config: RpcProgramAccountsConfig, ) -> ClientResult<Vec<(Pubkey, Account)>> { let commitment = config .account_config .commitment .unwrap_or_else(|| self.commitment_config()); let account_config = RpcAccountInfoConfig { commitment: Some(commitment), ..config.account_config }; let config = RpcProgramAccountsConfig { account_config, ..config }; let request = GetProgramAccountsRequest::new_with_config(*pubkey, config); let response: GetProgramAccountsResponse = self.send(request).await?; // Parse keyed accounts let accounts = response .keyed_accounts() .ok_or_else(|| ClientError::new("Program account doesn't exist."))?; let mut pubkey_accounts: Vec<(Pubkey, Account)> = Vec::with_capacity(accounts.len()); for RpcKeyedAccount { pubkey, account } in accounts.iter() { let pubkey = pubkey .parse() .map_err(|_| ClientError::new(format!("{pubkey} is not a valid pubkey.")))?; pubkey_accounts.push(( pubkey, account .decode() .ok_or_else(|| ClientError::new(format!("Unable to decode {pubkey}")))?, )); } Ok(pubkey_accounts) } pub async fn get_program_accounts( &self, pubkey: &Pubkey, ) -> ClientResult<Vec<(Pubkey, Account)>> { self.get_program_accounts_with_config( pubkey, RpcProgramAccountsConfig { account_config: RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::Base64), ..RpcAccountInfoConfig::default() }, ..RpcProgramAccountsConfig::default() }, ) .await } pub async fn get_slot_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<Slot> { let request = GetSlotRequest::new_with_config(commitment_config); let response: GetSlotResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_slot(&self) -> ClientResult<Slot> { self.get_slot_with_commitment(self.commitment_config()) .await } pub async fn get_block_with_config( &self, slot: Slot, config: RpcBlockConfig, ) -> ClientResult<UiConfirmedBlock> { let request = GetBlockRequest::new_with_config(slot, config); let response: GetBlockResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_version(&self) -> ClientResult<RpcVersionInfo> { let request = GetVersionRequest; let response: GetVersionResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_first_available_block(&self) -> ClientResult<Slot> { let request = GetFirstAvailableBlockRequest; let response: GetFirstAvailableBlockResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_block_time(&self, slot: Slot) -> ClientResult<UnixTimestamp> { let request = GetBlockTimeRequest::new(slot); let response: GetBlockTimeResponse = self.send(request).await?; let maybe_ts: Option<UnixTimestamp> = response.into(); match maybe_ts { Some(ts) => Ok(ts), None => Err(ClientError::new(format!("Block Not Found: slot={}", slot))), } } pub async fn get_block_height_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<u64> { let request = GetBlockHeightRequest::new_with_config(commitment_config); let response: GetBlockHeightResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_block_height(&self) -> ClientResult<u64> { self.get_block_height_with_commitment(self.commitment_config()) .await } pub async fn get_genesis_hash(&self) -> ClientResult<Hash> { let request = GetGenesisHashRequest; let response: GetGenesisHashResponse = self.send(request).await?; let hash_string: String = response.into(); let hash = hash_string .parse() .map_err(|_| ClientError::new("Hash is not parseable."))?; Ok(hash) } pub async fn get_epoch_info_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<EpochInfo> { let request = GetEpochInfoRequest::new_with_config(commitment_config); let response: GetEpochInfoResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_epoch_info(&self) -> ClientResult<EpochInfo> { self.get_epoch_info_with_commitment(self.commitment_config()) .await } pub async fn get_recent_performance_samples( &self, limit: Option<usize>, ) -> ClientResult<Vec<RpcPerfSample>> { let request = GetRecentPerformanceSamplesRequest { limit }; let response: GetRecentPerformanceSamplesResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_blocks_with_limit_and_commitment( &self, start_slot: Slot, limit: usize, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>> { let request = GetBlocksWithLimitRequest::new_with_config(start_slot, limit, commitment_config); let response: GetBlocksWithLimitResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_blocks_with_limit( &self, start_slot: Slot, limit: usize, ) -> ClientResult<Vec<Slot>> { self.get_blocks_with_limit_and_commitment(start_slot, limit, self.commitment_config()) .await } pub async fn get_largest_accounts_with_config( &self, config: RpcLargestAccountsConfig, ) -> ClientResult<Vec<RpcAccountBalance>> { let config = RpcLargestAccountsConfig { commitment: config.commitment, ..config }; let request = GetLargestAccountsRequest::new_with_config(config); let response: GetLargestAccountsResponse = self.send(request).await?; Ok(response.value) } pub async fn get_supply_with_config(&self, config: RpcSupplyConfig) -> ClientResult<RpcSupply> { let request = GetSupplyRequest::new_with_config(config); let response: GetSupplyResponse = self.send(request).await?; Ok(response.value) } pub async fn get_supply_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<RpcSupply> { self.get_supply_with_config(RpcSupplyConfig { commitment: Some(commitment_config), exclude_non_circulating_accounts_list: false, }) .await } pub async fn get_supply(&self) -> ClientResult<RpcSupply> { self.get_supply_with_commitment(self.commitment_config()) .await } pub async fn get_transaction_count_with_config( &self, config: RpcContextConfig, ) -> ClientResult<u64> { let request = GetTransactionCountRequest::new_with_config(config); let response: GetTransactionCountResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_transaction_count_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<u64> { self.get_transaction_count_with_config(RpcContextConfig { commitment: Some(commitment_config), min_context_slot: None, }) .await } pub async fn get_transaction_count(&self) -> ClientResult<u64> { self.get_transaction_count_with_commitment(self.commitment_config()) .await } pub async fn get_multiple_accounts_with_config( &self, pubkeys: &[Pubkey], config: RpcAccountInfoConfig, ) -> ClientResult<Vec<Option<Account>>> { let config = RpcAccountInfoConfig { commitment: config.commitment, ..config }; let request = GetMultipleAccountsRequest::new_with_config(pubkeys.to_vec(), config); let response: GetMultipleAccountsResponse = self.send(request).await?; Ok(response .value .iter() .filter(|maybe_acc| maybe_acc.is_some()) .map(|acc| acc.clone().unwrap().decode()) .collect()) } pub async fn get_multiple_accounts_with_commitment( &self, pubkeys: &[Pubkey], commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Option<Account>>> { self.get_multiple_accounts_with_config( pubkeys, RpcAccountInfoConfig { commitment: Some(commitment_config), ..RpcAccountInfoConfig::default() }, ) .await } pub async fn get_multiple_accounts( &self, pubkeys: &[Pubkey], ) -> ClientResult<Vec<Option<Account>>> { self.get_multiple_accounts_with_commitment(pubkeys, self.commitment_config()) .await } pub async fn get_cluster_nodes(&self) -> ClientResult<Vec<RpcContactInfoWasm>> { let request = GetClusterNodesRequest; let response: GetClusterNodesResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_vote_accounts_with_config( &self, config: RpcGetVoteAccountsConfig, ) -> ClientResult<RpcVoteAccountStatus> { let request = GetVoteAccountsRequest::new_with_config(config); let response: GetVoteAccountsResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_vote_accounts_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<RpcVoteAccountStatus> { self.get_vote_accounts_with_config(RpcGetVoteAccountsConfig { commitment: Some(commitment_config), ..Default::default() }) .await } pub async fn get_vote_accounts(&self) -> ClientResult<RpcVoteAccountStatus> { self.get_vote_accounts_with_commitment(self.commitment_config()) .await } pub async fn get_epoch_schedule(&self) -> ClientResult<EpochSchedule> { let request = GetEpochScheduleRequest; let response: GetEpochScheduleResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_signatures_for_address_with_config( &self, address: &Pubkey, config: GetConfirmedSignaturesForAddress2Config, ) -> ClientResult<Vec<RpcConfirmedTransactionStatusWithSignature>> { let config = RpcSignaturesForAddressConfig { before: config.before.map(|signature| signature.to_string()), until: config.until.map(|signature| signature.to_string()), limit: config.limit, commitment: config.commitment, min_context_slot: None, }; let request = GetSignaturesForAddressRequest::new_with_config(*address, config); let response: GetSignaturesForAddressResponse = self.send(request).await?; Ok(response.into()) } pub async fn minimum_ledger_slot(&self) -> ClientResult<Slot> { let request = MinimumLedgerSlotRequest; let response: MinimumLedgerSlotResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_blocks_with_commitment( &self, start_slot: Slot, end_slot: Option<Slot>, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<Slot>> { let request = GetBlocksRequest::new_with_config(start_slot, end_slot, commitment_config); let response: GetBlocksResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_blocks( &self, start_slot: Slot, end_slot: Option<Slot>, ) -> ClientResult<Vec<Slot>> { self.get_blocks_with_commitment(start_slot, end_slot, self.commitment_config()) .await } pub async fn get_leader_schedule_with_config( &self, slot: Option<Slot>, config: RpcLeaderScheduleConfig, ) -> ClientResult<Option<RpcLeaderSchedule>> { let request = match slot { Some(s) => GetLeaderScheduleRequest::new_with_slot_and_config(s, config), None => GetLeaderScheduleRequest::new_with_config(config), }; let response: GetLeaderScheduleResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_leader_schedule_with_commitment( &self, slot: Option<Slot>, commitment_config: CommitmentConfig, ) -> ClientResult<Option<RpcLeaderSchedule>> { self.get_leader_schedule_with_config( slot, RpcLeaderScheduleConfig { commitment: Some(commitment_config), ..Default::default() }, ) .await } pub async fn get_block_production_with_config( &self, config: RpcBlockProductionConfig, ) -> ClientResult<RpcBlockProduction> { let request = GetBlockProductionRequest::new_with_config(config); let response: GetBlockProductionResponse = self.send(request).await?; Ok(response.value) } pub async fn get_block_production_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<RpcBlockProduction> { self.get_block_production_with_config(RpcBlockProductionConfig { commitment: Some(commitment_config), ..Default::default() }) .await } pub async fn get_block_production(&self) -> ClientResult<RpcBlockProduction> { self.get_block_production_with_commitment(self.commitment_config()) .await } pub async fn get_inflation_governor_with_commitment( &self, commitment_config: CommitmentConfig, ) -> ClientResult<RpcInflationGovernor> { let request = GetInflationGovernorRequest::new_with_config(commitment_config); let response: GetInflationGovernorResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_inflation_governor(&self) -> ClientResult<RpcInflationGovernor> { self.get_inflation_governor_with_commitment(self.commitment_config()) .await } pub async fn get_inflation_rate(&self) -> ClientResult<RpcInflationRate> { let request = GetInflationRateRequest; let response: GetInflationRateResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_inflation_reward_with_config( &self, addresses: &[Pubkey], epoch: Option<Epoch>, ) -> ClientResult<Vec<Option<RpcInflationReward>>> { let request = GetInflationRewardRequest::new_with_config( addresses.to_vec(), RpcEpochConfig { commitment: Some(self.commitment_config()), epoch, ..Default::default() }, ); let response: GetInflationRewardResponse = self.send(request).await?; Ok(response.into()) } pub async fn get_inflation_reward( &self, addresses: &[Pubkey], ) -> ClientResult<Vec<Option<RpcInflationReward>>> { self.get_inflation_reward_with_config(addresses, None).await } pub async fn get_token_account_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<Option<UiTokenAccount>> { let config = RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::JsonParsed), commitment: Some(commitment_config), data_slice: None, min_context_slot: None, }; let request = GetAccountInfoRequest::new_with_config(*pubkey, config); let response: GetAccountInfoResponse = self.send(request).await?; if let Some(acc) = response.value { if let UiAccountData::Json(account_data) = acc.data { let token_account_type: TokenAccountType = match serde_json::from_value(account_data.parsed) { Ok(t) => t, Err(e) => return Err(ClientError::new(e.to_string())), }; if let TokenAccountType::Account(token_account) = token_account_type { return Ok(Some(token_account)); } } } Err(ClientError::new(format!( "AccountNotFound: pubkey={}", pubkey ))) } pub async fn get_token_account(&self, pubkey: &Pubkey) -> ClientResult<Option<UiTokenAccount>> { self.get_token_account_with_commitment(pubkey, self.commitment_config()) .await } pub async fn get_token_accounts_by_owner_with_commitment( &self, owner: &Pubkey, token_account_filter: RpcTokenAccountsFilter, commitment_config: CommitmentConfig, ) -> ClientResult<Vec<RpcKeyedAccount>> { let config = RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::JsonParsed), commitment: Some(commitment_config), data_slice: None, min_context_slot: None, }; let request = GetTokenAccountsByOwnerRequest::new_with_config(*owner, token_account_filter, config); let response: GetTokenAccountsByOwnerResponse = self.send(request).await?; Ok(response.value) } pub async fn get_token_accounts_by_owner( &self, owner: &Pubkey, token_account_filter: RpcTokenAccountsFilter, ) -> ClientResult<Vec<RpcKeyedAccount>> { self.get_token_accounts_by_owner_with_commitment( owner, token_account_filter, self.commitment_config(), ) .await } pub async fn get_token_account_balance_with_commitment( &self, pubkey: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<UiTokenAmount> { let request = GetTokenAccountBalanceRequest::new_with_config(*pubkey, commitment_config); let response: GetTokenAccountBalanceResponse = self.send(request).await?; Ok(response.value) } pub async fn get_token_account_balance(&self, pubkey: &Pubkey) -> ClientResult<UiTokenAmount> { self.get_token_account_balance_with_commitment(pubkey, self.commitment_config()) .await } pub async fn get_token_supply_with_commitment( &self, mint: &Pubkey, commitment_config: CommitmentConfig, ) -> ClientResult<UiTokenAmount> { let request = GetTokenSupplyRequest::new_with_config(*mint, commitment_config); let response: GetTokenSupplyResponse = self.send(request).await?; Ok(response.value) } pub async fn get_token_supply(&self, mint: &Pubkey) -> ClientResult<UiTokenAmount> { self.get_token_supply_with_commitment(mint, self.commitment_config()) .await } pub async fn simulate_transaction_with_config( &self, transaction: &Transaction, config: RpcSimulateTransactionConfig, ) -> ClientResult<SimulateTransactionResponse> { let request = SimulateTransactionRequest::new_with_config(transaction.to_owned(), config); let response: SimulateTransactionResponse = self.send(request).await?; Ok(response) } pub async fn simulate_transaction( &self, transaction: &Transaction, ) -> ClientResult<SimulateTransactionResponse> { self.simulate_transaction_with_config( transaction, RpcSimulateTransactionConfig { encoding: Some(UiTransactionEncoding::Base64), replace_recent_blockhash: Some(true), ..Default::default() }, ) .await } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/error.rs
use http::StatusCode; use std::fmt; #[derive(Debug, Serialize, Deserialize)] struct Error { code: u16, message: String, } impl Default for Error { fn default() -> Self { Self { code: StatusCode::INTERNAL_SERVER_ERROR.as_u16(), message: StatusCode::INTERNAL_SERVER_ERROR.as_str().to_owned(), } } } #[derive(Debug, Serialize, Deserialize)] pub struct ClientError { id: u16, jsonrpc: String, error: Error, } impl std::error::Error for ClientError {} impl Default for ClientError { fn default() -> Self { Self { id: 0, jsonrpc: String::from("2.0"), error: Error::default(), } } } impl From<gloo_net::Error> for ClientError { fn from(error: gloo_net::Error) -> Self { ClientError { error: Error { code: StatusCode::INTERNAL_SERVER_ERROR.into(), message: error.to_string(), }, ..Default::default() } } } impl ClientError { pub fn new(error_msg: impl ToString) -> Self { ClientError { error: Error { code: StatusCode::SEE_OTHER.as_u16(), message: error_msg.to_string(), }, ..Default::default() } } pub fn new_with_status(code: u16, error_msg: impl ToString) -> Self { ClientError { error: Error { code, message: error_msg.to_string(), }, ..Default::default() } } } impl fmt::Display for ClientError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str(format!("Client error: {}", self.error.message).as_str()) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/lib.rs
#![allow(dead_code, deprecated)] #[macro_use] extern crate serde_derive; mod client; mod constants; mod error; mod methods; mod provider; mod request; mod response; #[cfg(feature = "pubsub")] mod pubsub; pub mod utils; // Export sdk for stand-alone use of wasm client without specifying sdk as dependency pub use solana_sdk; // For root level imports pub use { client::WasmClient, error::ClientError, request::ClientRequest, response::ClientResponse, }; pub type ClientResult<T> = std::result::Result<T, error::ClientError>;
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/provider.rs
use std::pin::pin; use futures::future::{select, Either}; use gloo_net::http::{Method as HttpMethod, RequestBuilder}; use gloo_timers::future::TimeoutFuture; use http::StatusCode; use serde::de::DeserializeOwned; use web_sys::{wasm_bindgen::UnwrapThrowExt, AbortController}; use crate::{methods::Method, ClientError, ClientRequest, ClientResponse, ClientResult}; #[derive(Clone)] pub struct HttpProvider { url: String, timeout: u32, } impl HttpProvider { pub fn new(url: impl ToString) -> Self { Self { url: url.to_string(), timeout: 60000, } } pub fn new_with_timeout(url: impl ToString, timeout: u32) -> Self { Self { url: url.to_string(), timeout, } } } impl HttpProvider { pub async fn send<T: Method, R: DeserializeOwned>( &self, request: &T, ) -> ClientResult<ClientResponse<R>> { let client_request = ClientRequest::new(T::NAME).id(0).params(request); let ctrl = AbortController::new().unwrap_throw(); let timeout_fut = TimeoutFuture::new(self.timeout); let req_fut = RequestBuilder::new(&self.url) .method(HttpMethod::POST) .abort_signal(Some(&ctrl.signal())) .json(&client_request)? .send(); let fut = match select(timeout_fut, pin!(req_fut)).await { Either::Left((_, fut)) => { ctrl.abort(); fut.await } Either::Right((val, fut)) => { drop(fut); val } }; let response = fut?; let status = StatusCode::from_u16(response.status()).unwrap_or(StatusCode::INTERNAL_SERVER_ERROR); if status.is_success() { if let Ok(response) = response.json::<ClientResponse<R>>().await { return Ok(response); } } match response.json::<ClientError>().await { Ok(error) => Err(error), Err(error) => Err(ClientError::new_with_status(status.as_u16(), error)), } } } #[derive(Clone)] pub enum Provider { Http(HttpProvider), } impl Provider { pub fn new(url: &str) -> Self { Self::Http(HttpProvider::new(url)) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/pubsub.rs
use std::{collections::HashMap, sync::Arc}; use futures::lock::Mutex; use serde::de; use serde_json::{json, Value}; use solana_extra_wasm::{transaction_status::UiTransactionEncoding, utils::sleep}; use solana_sdk::{pubkey::Pubkey, signature::Signature}; use wasm_bindgen::{prelude::Closure, JsCast}; use wasm_bindgen_futures::spawn_local; use web_sys::{MessageEvent, WebSocket}; use crate::{ methods::{GetAccountInfoResponse, GetProgramAccountsResponse}, utils::{ rpc_config::{ pubsub::{ RpcAccountSubscribeConfig, RpcBlockSubscribeConfig, RpcBlockSubscribeFilter, RpcSignatureSubscribeConfig, }, RpcProgramAccountsConfig, RpcTransactionLogsConfig, RpcTransactionLogsFilter, }, rpc_response::{ RpcBlockUpdate, RpcLogsResponse, RpcSignatureResult, RpcVote, SlotInfo, SlotUpdate, WithContext, }, }, ClientRequest, ClientResponse, WasmClient, }; /// WASM compatible WebSocket. /// /// Requires `pubsub` crate feature to be activated. /// /// ### Compatibility /// /// Current implementation depends on `web-sys` and `js-sys` crates and is intended to work only /// in browsers. pub struct WasmWebSocket { ws: WebSocket, listeners: Arc<Mutex<HashMap<SubscriptionId, Closure<dyn Fn(MessageEvent)>>>>, } impl WasmWebSocket { pub fn new<S: AsRef<str>>(url: S) -> Self { Self { ws: match url.as_ref() { url if url.starts_with("http") => { // Replace to wss let first_index = url.find(':').expect("Invalid URL"); let mut url = url.to_string(); url.replace_range( ..first_index, if url.starts_with("https") { "wss" } else { "ws" }, ); // Increase the port number by 1 if the port is specified let last_index = url.rfind(':').unwrap(); if last_index != first_index { if let Some(Ok(mut port)) = url .get(last_index + 1..) .map(|potential_port| potential_port.parse::<u16>()) { port += 1; url.replace_range(last_index + 1.., &port.to_string()) } } WebSocket::new(&url).expect("Could not create WebSocket") } _ => WebSocket::new(url.as_ref()).expect("Could not create WebSocket"), }, listeners: Arc::new(Mutex::new(HashMap::new())), } } async fn wait_until_ready(&self) { while self.ws.ready_state() != 1 { sleep(200).await; } } fn send(&self, method: &str, params: Option<Value>) { let mut req = ClientRequest::new(method); if let Some(params) = params { req = req.params(params); } self.ws .send_with_str(&serde_json::to_string(&req).unwrap()) .ok(); } async fn add_listener<'a, T: de::Deserialize<'a>, F>( &self, method: &str, params: Option<Value>, cb: F, ) -> SubscriptionId where F: Fn(T) + Send + 'static, { self.wait_until_ready().await; // Get the subscription id let id: Arc<Mutex<Option<SubscriptionId>>> = Arc::new(Mutex::new(None)); let id_ref = id.clone(); let subscription_id_listener = Closure::wrap(Box::new(move |event: MessageEvent| { if let Some(Ok(response)) = event .data() .as_string() .map(|data| serde_json::from_str::<ClientResponse<SubscriptionId>>(&data)) { let id_ref = id_ref.clone(); spawn_local(async move { let subscription_id: SubscriptionId = response.result; let mut id = id_ref.lock().await; *id = Some(subscription_id); }) } }) as Box<dyn Fn(MessageEvent)>); self.ws .add_event_listener_with_callback( "message", subscription_id_listener.as_ref().unchecked_ref(), ) .unwrap(); self.send(method, params); // Main event listener let listener = Closure::wrap(Box::new(move |event: MessageEvent| { if let Some(Ok(notification)) = event.data().as_string().map(|data| { // SAFETY: No segfault so far -_- // See https://github.com/serde-rs/serde/issues/964 let data = unsafe { std::mem::transmute::<&str, &'a str>(&data) }; serde_json::from_str::<SubscriptionNotification<T>>(data) }) { cb(notification.params.result); } }) as Box<dyn Fn(MessageEvent)>); self.ws .add_event_listener_with_callback("message", listener.as_ref().unchecked_ref()) .unwrap(); loop { let id = id.lock().await; if id.is_some() { self.ws .remove_event_listener_with_callback( "message", subscription_id_listener.as_ref().unchecked_ref(), ) .ok(); let id = id.unwrap(); let mut listeners = self.listeners.lock().await; listeners.insert(id, listener); return id; } drop(id); sleep(500).await; } } async fn remove_listener(&self, method: &str, id: SubscriptionId) { let mut listeners = self.listeners.lock().await; if let Some(listener) = listeners.get(&id) { self.ws .remove_event_listener_with_callback("message", listener.as_ref().unchecked_ref()) .ok(); listeners.remove(&id); self.send(method, Some(json!([id]))); } } } pub type SubscriptionId = u64; #[derive(Debug, Deserialize)] pub struct SubscriptionNotification<T> { jsonrpc: String, method: String, params: SubscriptionParams<T>, } #[derive(Debug, Deserialize)] pub struct SubscriptionParams<T> { result: T, subscription: SubscriptionId, } impl WasmClient { /// Subscribe to account events. /// /// Receives messages of type [`GetAccountInfoResponse`] when an account's lamports or data changes. /// /// # RPC Reference /// /// This method corresponds directly to the [`accountSubscribe`] RPC method. /// /// [`accountSubscribe`]: https://docs.solana.com/api/websocket#accountsubscribe pub async fn account_subscribe<F>(&self, pubkey: Pubkey, cb: F) -> SubscriptionId where F: Fn(GetAccountInfoResponse) + Send + 'static, { self.account_subscribe_with_config( pubkey, Some(RpcAccountSubscribeConfig { commitment: Some(self.commitment_config()), encoding: Some(UiTransactionEncoding::Base64), }), cb, ) .await } /// Subscribe to account events with config. /// /// Receives messages of type [`GetAccountInfoResponse`] when an account's lamports or data changes. /// /// # RPC Reference /// /// This method corresponds directly to the [`accountSubscribe`] RPC method. /// /// [`accountSubscribe`]: https://docs.solana.com/api/websocket#accountsubscribe pub async fn account_subscribe_with_config<F>( &self, pubkey: Pubkey, config: Option<RpcAccountSubscribeConfig>, cb: F, ) -> SubscriptionId where F: Fn(GetAccountInfoResponse) + Send + 'static, { self.ws .add_listener( "accountSubscribe", Some(json!([pubkey.to_string(), config])), cb, ) .await } /// Subscribe to block events. /// /// Receives messages of type [`RpcBlockUpdate`] when a block is confirmed or finalized. /// /// This method is disabled by default. It can be enabled by passing /// `--rpc-pubsub-enable-block-subscription` to `solana-validator`. /// /// # RPC Reference /// /// This method corresponds directly to the [`blockSubscribe`] RPC method. /// /// [`blockSubscribe`]: https://docs.solana.com/api/websocket#blocksubscribe pub async fn block_subscribe<F>( &self, filter: RpcBlockSubscribeFilter, config: Option<RpcBlockSubscribeConfig>, cb: F, ) -> SubscriptionId where F: Fn(WithContext<RpcBlockUpdate>) + Send + 'static, { self.ws .add_listener("blockSubscribe", Some(json!([filter, config])), cb) .await } /// Subscribe to transaction log events. /// /// Receives messages of type [`RpcLogsResponse`] when a transaction is committed. /// /// # RPC Reference /// /// This method corresponds directly to the [`logsSubscribe`] RPC method. /// /// [`logsSubscribe`]: https://docs.solana.com/api/websocket#logssubscribe pub async fn logs_subscribe<F>( &self, filter: RpcTransactionLogsFilter, config: RpcTransactionLogsConfig, cb: F, ) -> SubscriptionId where F: Fn(WithContext<RpcLogsResponse>) + Send + 'static, { self.ws .add_listener("logsSubscribe", Some(json!([filter, config])), cb) .await } /// Subscribe to program account events. /// /// Receives messages of type [`GetProgramAccountsResponse`] when an account owned /// by the given program changes. /// /// # RPC Reference /// /// This method corresponds directly to the [`programSubscribe`] RPC method. /// /// [`programSubscribe`]: https://docs.solana.com/api/websocket#programsubscribe pub async fn program_subscribe<F>( &self, pubkey: &Pubkey, config: Option<RpcProgramAccountsConfig>, cb: F, ) -> SubscriptionId where F: Fn(GetProgramAccountsResponse) + Send + 'static, { self.ws .add_listener( "programSubscribe", Some(json!([pubkey.to_string(), config])), cb, ) .await } /// Subscribe to vote events. /// /// Receives messages of type [`RpcVote`] when a new vote is observed. These /// votes are observed prior to confirmation and may never be confirmed. /// /// This method is disabled by default. It can be enabled by passing /// `--rpc-pubsub-enable-vote-subscription` to `solana-validator`. /// /// # RPC Reference /// /// This method corresponds directly to the [`voteSubscribe`] RPC method. /// /// [`voteSubscribe`]: https://docs.solana.com/api/websocket#votesubscribe pub async fn vote_subscribe<F>(&self, cb: F) -> SubscriptionId where F: Fn(RpcVote) + Send + 'static, { self.ws.add_listener("voteSubscribe", None, cb).await } // Subscribe to transaction confirmation events. /// /// Receives messages of type [`RpcSignatureResult`] when a transaction /// with the given signature is committed. /// /// This is a subscription to a single notification. It is automatically /// cancelled by the server once the notification is sent. /// /// # RPC Reference /// /// This method corresponds directly to the [`signatureSubscribe`] RPC method. /// /// [`signatureSubscribe`]: https://docs.solana.com/api/websocket#signaturesubscribe pub async fn signature_subscribe<F>( &self, signature: &Signature, config: Option<RpcSignatureSubscribeConfig>, cb: F, ) -> SubscriptionId where F: Fn(WithContext<RpcSignatureResult>) + Send + 'static, { self.ws .add_listener( "signatureSubscribe", Some(json!([signature.to_string(), config])), cb, ) .await } /// Subscribe to slot events. /// /// Receives messages of type [`SlotInfo`] when a slot is processed. /// /// # RPC Reference /// /// This method corresponds directly to the [`slotSubscribe`] RPC method. /// /// [`slotSubscribe`]: https://docs.solana.com/api/websocket#slotsubscribe pub async fn slot_subscribe<F>(&self, cb: F) -> SubscriptionId where F: Fn(SlotInfo) + Send + 'static, { self.ws.add_listener("slotSubscribe", None, cb).await } /// Subscribe to slot update events. /// /// Receives messages of type [`SlotUpdate`] when various updates to a slot occur. /// /// Note that this method operates differently than other subscriptions: /// instead of sending the message to a reciever on a channel, it accepts a /// `handler` callback that processes the message directly. This processing /// occurs on another thread. /// /// # RPC Reference /// /// This method corresponds directly to the [`slotUpdatesSubscribe`] RPC method. /// /// [`slotUpdatesSubscribe`]: https://docs.solana.com/api/websocket#slotsubscribe pub async fn slot_updates_subscribe<F>(&self, cb: F) -> SubscriptionId where F: Fn(SlotUpdate) + Send + 'static, { self.ws .add_listener("slotsUpdatesSubscribe", None, cb) .await } /// Unsubscribe from account update events. pub async fn account_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("accountUnsubscribe", id).await; } /// Unsubscribe from block update events. pub async fn block_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("blockUnsubscribe", id).await; } /// Unsubscribe from logs update events. pub async fn logs_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("logsUnsubscribe", id).await; } /// Unsubscribe from program update events. pub async fn program_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("programUnsubscribe", id).await; } /// Unsubscribe from signature update events. pub async fn signature_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("signatureUnsubscribe", id).await; } /// Unsubscribe from slot update events. pub async fn slot_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("slotUnsubscribe", id).await; } /// Unsubscribe from vote update events. pub async fn vote_unsubscribe(&self, id: SubscriptionId) { self.ws.remove_listener("voteUnsubscribe", id).await; } } #[cfg(test)] wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser); #[cfg(test)] pub mod test { use solana_sdk::{native_token::LAMPORTS_PER_SOL, signature::Keypair, signer::Signer}; use wasm_bindgen_test::*; use super::*; #[wasm_bindgen_test] async fn account() { // Create a client let client = WasmClient::new("http://localhost:8899"); let random_pubkey = Keypair::new().pubkey(); client .request_airdrop(&random_pubkey, 1 * LAMPORTS_PER_SOL) .await .expect("Airdrop failed"); // Subscribe to changes let id = client .account_subscribe(random_pubkey, |response| { if let Some(account) = response.value { console_log!("Account: {:#?}", account); } }) .await; sleep(5000).await; // Must unsubscribe to not leak memory client.account_unsubscribe(id).await; } #[wasm_bindgen_test] async fn slot() { // Create a client let client = WasmClient::new("https://api.devnet.solana.com"); // Subscribe to changes let id = client .slot_subscribe(|slot_info| { console_log!("Slot info: {:#?}", slot_info); }) .await; sleep(5000).await; // Must unsubscribe to not leak memory client.slot_unsubscribe(id).await; } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/stake_activation.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{ impl_method, utils::{rpc_config::RpcEpochConfig, rpc_response::RpcStakeActivation}, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetStakeActivationRequest { #[serde_as(as = "DisplayFromStr")] pubkey: Pubkey, config: Option<RpcEpochConfig>, } impl_method!(GetStakeActivationRequest, "getStakeActivation"); impl GetStakeActivationRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: RpcEpochConfig) -> Self { Self { pubkey, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetStakeActivationResponse(RpcStakeActivation); impl From<GetStakeActivationResponse> for RpcStakeActivation { fn from(value: GetStakeActivationResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{ methods::Method, utils::rpc_response::StakeActivationState, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(GetStakeActivationRequest::NAME) .id(1) .params(GetStakeActivationRequest::new_with_config( pubkey!("CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT"), RpcEpochConfig { epoch: Some(4), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getStakeActivation","params":["CYRJWqiSjLitBAcRxPvWpgX3s5TvmN2SuRY3eEYypFvT",{"epoch":4}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"active":124429280,"inactive":73287840,"state":"activating"},"id":1}"#; let response: ClientResponse<GetStakeActivationResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, RpcStakeActivation { active: 124429280, inactive: 73287840, state: StakeActivationState::Activating } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/max_shred_insert_slot.rs
use crate::impl_method; #[derive(Debug, Serialize)] pub struct GetMaxShredInsertSlotRequest; impl_method!(GetMaxShredInsertSlotRequest, "getMaxShredInsertSlot"); #[derive(Debug, Deserialize)] pub struct GetMaxShredInsertSlotResponse(u64); #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetMaxShredInsertSlotRequest::NAME) .id(1) .params(GetMaxShredInsertSlotRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getMaxShredInsertSlot"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 1234, "id": 1 }"#; let response: ClientResponse<GetMaxShredInsertSlotResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 1234); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/slot.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::{clock::Slot, commitment_config::CommitmentConfig}; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetSlotRequest { config: Option<CommitmentConfig>, } impl_method!(GetSlotRequest, "getSlot"); impl GetSlotRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetSlotResponse(Slot); impl From<GetSlotResponse> for Slot { fn from(val: GetSlotResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSlotRequest::NAME) .id(1) .params(GetSlotRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getSlot"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 1234, "id": 1 }"#; let response: ClientResponse<GetSlotResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 1234); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/block_production.rs
use serde::Deserialize; use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use super::Context; use crate::{ impl_method, utils::{rpc_config::RpcBlockProductionConfig, rpc_response::RpcBlockProduction}, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Serialize_tuple, Default)] pub struct GetBlockProductionRequest { pub config: Option<RpcBlockProductionConfig>, } impl_method!(GetBlockProductionRequest, "getBlockProduction"); impl GetBlockProductionRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: RpcBlockProductionConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBlockProductionResponse { pub context: Context, pub value: RpcBlockProduction, } #[cfg(test)] mod tests { use serde_json::Value; use std::collections::HashMap; use crate::{ methods::Method, utils::rpc_response::RpcBlockProductionRange, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlockProductionRequest::NAME) .id(1) .params(GetBlockProductionRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getBlockProduction"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":9887},"value":{"byIdentity":{"85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr":[9888,9886]},"range":{"firstSlot":0,"lastSlot":9887}}},"id":1}"#; let response: ClientResponse<GetBlockProductionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 9887); let value = response.result.value; assert_eq!( value.by_identity, HashMap::from_iter([( "85iYT5RuzRTDgjyRa3cP8SYhM2j21fj7NhfJ3peu1DPr".to_string(), (9888, 9886) )]) ); assert_eq!( value.range, RpcBlockProductionRange { first_slot: 0, last_slot: 9887 } ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/request_airdrop.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::{ commitment_config::CommitmentConfig, {pubkey::Pubkey, signature::Signature}, }; use std::str::FromStr; use crate::{impl_method, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct RequestAirdropRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub lamports: u64, pub config: Option<CommitmentConfig>, } impl_method!(RequestAirdropRequest, "requestAirdrop"); impl RequestAirdropRequest { pub fn new(pubkey: Pubkey, lamports: u64) -> Self { Self { pubkey, lamports, config: None, } } pub fn new_with_config(pubkey: Pubkey, lamports: u64, config: CommitmentConfig) -> Self { Self { pubkey, lamports, config: Some(config), } } } #[serde_as] #[derive(Debug, Deserialize)] pub struct RequestAirdropResponse(#[serde_as(as = "DisplayFromStr")] Signature); impl From<RequestAirdropResponse> for Signature { fn from(val: RequestAirdropResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use std::{collections::HashMap, str::FromStr}; use serde_json::Value; use solana_extra_wasm::{ account_decoder::{UiAccount, UiAccountData, UiAccountEncoding}, transaction_status::Encodable, }; use solana_sdk::{commitment_config::CommitmentConfig, pubkey}; use crate::{ methods::Method, utils::{ rpc_config::RpcAccountInfoConfig, rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, rpc_response::RpcBlockProductionRange, }, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(RequestAirdropRequest::NAME) .id(1) .params(RequestAirdropRequest::new( pubkey!("83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"), 1000000000, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"requestAirdrop","params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri",1000000000]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":"5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW","id":1}"#; let response: ClientResponse<RequestAirdropResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, Signature::from_str("5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW").unwrap()); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/transaction_count.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use crate::{impl_method, utils::rpc_config::RpcContextConfig, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetTransactionCountRequest { pub config: Option<RpcContextConfig>, } impl_method!(GetTransactionCountRequest, "getTransactionCount"); impl GetTransactionCountRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: RpcContextConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTransactionCountResponse(u64); impl From<GetTransactionCountResponse> for u64 { fn from(val: GetTransactionCountResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTransactionCountRequest::NAME) .id(1) .params(GetTransactionCountRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getTransactionCount"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 268, "id": 1 }"#; let response: ClientResponse<GetTransactionCountResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 268); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/max_retransmit_slot.rs
use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetMaxRetransmitSlotRequest; impl_method!(GetMaxRetransmitSlotRequest, "getMaxRetransmitSlot"); #[derive(Debug, Deserialize)] pub struct GetMaxRetransmitSlotResponse(u64); #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetMaxRetransmitSlotRequest::NAME) .id(1) .params(GetMaxRetransmitSlotRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getMaxRetransmitSlot"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 1234, "id": 1 }"#; let response: ClientResponse<GetMaxRetransmitSlotResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 1234); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/largest_accounts.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use super::Context; use crate::{ impl_method, utils::{rpc_config::RpcLargestAccountsConfig, rpc_response::RpcAccountBalance}, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetLargestAccountsRequest { pub config: Option<RpcLargestAccountsConfig>, } impl_method!(GetLargestAccountsRequest, "getLargestAccounts"); impl GetLargestAccountsRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: RpcLargestAccountsConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetLargestAccountsResponse { pub context: Context, pub value: Vec<RpcAccountBalance>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetLargestAccountsRequest::NAME) .id(1) .params(GetLargestAccountsRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getLargestAccounts"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":54},"value":[{"lamports":999974,"address":"99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ"},{"lamports":42,"address":"uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL"},{"lamports":42,"address":"aYJCgU7REfu3XF8b3QhkqgqQvLizx8zxuLBHA25PzDS"},{"lamports":42,"address":"CTvHVtQ4gd4gUcw3bdVgZJJqApXE9nCbbbP4VTS5wE1D"},{"lamports":20,"address":"4fq3xJ6kfrh9RkJQsmVd5gNMvJbuSHfErywvEjNQDPxu"},{"lamports":4,"address":"AXJADheGVp9cruP8WYu46oNkRbeASngN5fPCMVGQqNHa"},{"lamports":2,"address":"8NT8yS6LiwNprgW4yM1jPPow7CwRUotddBVkrkWgYp24"},{"lamports":1,"address":"SysvarEpochSchedu1e111111111111111111111111"},{"lamports":1,"address":"11111111111111111111111111111111"},{"lamports":1,"address":"Stake11111111111111111111111111111111111111"},{"lamports":1,"address":"SysvarC1ock11111111111111111111111111111111"},{"lamports":1,"address":"StakeConfig11111111111111111111111111111111"},{"lamports":1,"address":"SysvarRent111111111111111111111111111111111"},{"lamports":1,"address":"Config1111111111111111111111111111111111111"},{"lamports":1,"address":"SysvarStakeHistory1111111111111111111111111"},{"lamports":1,"address":"SysvarRecentB1ockHashes11111111111111111111"},{"lamports":1,"address":"SysvarFees111111111111111111111111111111111"},{"lamports":1,"address":"Vote111111111111111111111111111111111111111"}]},"id":1}"#; let response: ClientResponse<GetLargestAccountsResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 54); let value = response.result.value; assert_eq!( value, vec![ RpcAccountBalance { address: pubkey!("99P8ZgtJYe1buSK8JXkvpLh8xPsCFuLYhz9hQFNw93WJ"), lamports: 999974 }, RpcAccountBalance { address: pubkey!("uPwWLo16MVehpyWqsLkK3Ka8nLowWvAHbBChqv2FZeL"), lamports: 42 }, RpcAccountBalance { address: pubkey!("aYJCgU7REfu3XF8b3QhkqgqQvLizx8zxuLBHA25PzDS"), lamports: 42 }, RpcAccountBalance { address: pubkey!("CTvHVtQ4gd4gUcw3bdVgZJJqApXE9nCbbbP4VTS5wE1D"), lamports: 42 }, RpcAccountBalance { address: pubkey!("4fq3xJ6kfrh9RkJQsmVd5gNMvJbuSHfErywvEjNQDPxu"), lamports: 20 }, RpcAccountBalance { address: pubkey!("AXJADheGVp9cruP8WYu46oNkRbeASngN5fPCMVGQqNHa"), lamports: 4 }, RpcAccountBalance { address: pubkey!("8NT8yS6LiwNprgW4yM1jPPow7CwRUotddBVkrkWgYp24"), lamports: 2 }, RpcAccountBalance { address: pubkey!("SysvarEpochSchedu1e111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("11111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("Stake11111111111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("SysvarC1ock11111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("StakeConfig11111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("SysvarRent111111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("Config1111111111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("SysvarStakeHistory1111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("SysvarRecentB1ockHashes11111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("SysvarFees111111111111111111111111111111111"), lamports: 1 }, RpcAccountBalance { address: pubkey!("Vote111111111111111111111111111111111111111"), lamports: 1 } ] ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/transaction.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::transaction_status::EncodedConfirmedTransactionWithStatusMeta; use solana_sdk::signature::Signature; use crate::{impl_method, utils::rpc_config::RpcTransactionConfig, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetTransactionRequest { #[serde_as(as = "DisplayFromStr")] pub signature: Signature, pub config: Option<RpcTransactionConfig>, } impl_method!(GetTransactionRequest, "getTransaction"); impl GetTransactionRequest { pub fn new(signature: Signature) -> Self { Self { signature, config: None, } } pub fn new_with_config(signature: Signature, config: RpcTransactionConfig) -> Self { Self { signature, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTransactionResponse(Option<EncodedConfirmedTransactionWithStatusMeta>); impl From<GetTransactionResponse> for Option<EncodedConfirmedTransactionWithStatusMeta> { fn from(value: GetTransactionResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::transaction_status::{ EncodedTransaction, UiCompiledInstruction, UiMessage, UiRawMessage, UiTransaction, UiTransactionEncoding, UiTransactionStatusMeta, }; use solana_sdk::message::MessageHeader; use std::str::FromStr; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; // Serialization differs a bit from the RPC API but it is allowed too #[test] fn request() { let request = ClientRequest::new(GetTransactionRequest::NAME) .id(1) .params(GetTransactionRequest::new_with_config(Signature::from_str("2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv").unwrap(), RpcTransactionConfig { encoding: Some(UiTransactionEncoding::Json), ..Default::default() })); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTransaction","params":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv",{"encoding": "json"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"meta":{"err":null,"fee":5000,"innerInstructions":[],"postBalances":[499998932500,26858640,1,1,1],"postTokenBalances":[],"preBalances":[499998937500,26858640,1,1,1],"preTokenBalances":[],"rewards":[],"status":{"Ok":null}},"slot":430,"transaction":{"message":{"accountKeys":["3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe","AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":1},"instructions":[{"accounts":[1,2,3,0],"data":"37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1","programIdIndex":4}],"recentBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"},"signatures":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"]}},"blockTime":null,"id":1}"#; let response: ClientResponse<GetTransactionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, Some(EncodedConfirmedTransactionWithStatusMeta { block_time: None, slot: 430, transaction: solana_extra_wasm::transaction_status::EncodedTransactionWithStatusMeta { transaction: EncodedTransaction::Json(UiTransaction { message: UiMessage::Raw(UiRawMessage { header: MessageHeader { num_readonly_signed_accounts: 0, num_readonly_unsigned_accounts: 3, num_required_signatures: 1 }, address_table_lookups: None, recent_blockhash: "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B".to_string(), instructions: vec![UiCompiledInstruction { program_id_index: 4, accounts: vec![1, 2, 3, 0], data: "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1".to_string() }], account_keys: vec![ "3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe".to_string(), "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc".to_string(), "SysvarS1otHashes111111111111111111111111111".to_string(), "SysvarC1ock11111111111111111111111111111111".to_string(), "Vote111111111111111111111111111111111111111".to_string(), ] }), signatures: vec!["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv".to_string()] }), version: None, meta: Some(UiTransactionStatusMeta { err: None, fee: 5000, inner_instructions: Some(vec![]), post_balances: vec![499998932500, 26858640, 1, 1, 1], post_token_balances: Some(vec![]), pre_balances: vec![499998937500, 26858640, 1, 1, 1], pre_token_balances: Some(vec![]), rewards: Some(vec![]), status: Ok(()), loaded_addresses: None, log_messages: None, return_data: None, }), } }) ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/account_info.rs
use serde::Deserialize; use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::account_decoder::{UiAccount, UiAccountEncoding}; use solana_sdk::pubkey::Pubkey; use super::Context; use crate::{impl_method, utils::rpc_config::RpcAccountInfoConfig, ClientRequest, ClientResponse}; #[serde_as] #[derive(Debug, Serialize_tuple)] pub struct GetAccountInfoRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub config: RpcAccountInfoConfig, } impl_method!(GetAccountInfoRequest, "getAccountInfo"); impl GetAccountInfoRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::Base58), data_slice: None, commitment: None, min_context_slot: None, }, } } pub fn new_with_config(pubkey: Pubkey, config: RpcAccountInfoConfig) -> Self { Self { pubkey, config } } } #[derive(Debug, Deserialize)] pub struct GetAccountInfoResponse { pub context: Context, pub value: Option<UiAccount>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::account_decoder::UiAccountData; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let pubkey = pubkey!("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"); let request = ClientRequest::new(GetAccountInfoRequest::NAME) .id(1) .params(GetAccountInfoRequest::new(pubkey)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getAccountInfo","params":["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg",{"encoding":"base58"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":{"data":["11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf","base58"],"executable":false,"lamports":1000000000,"owner":"11111111111111111111111111111111","rentEpoch":2,"space":80}},"id":1}"#; let response: ClientResponse<GetAccountInfoResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1); let value = response.result.value.unwrap(); assert!(!value.executable); assert_eq!(value.lamports, 1000000000); assert_eq!(value.owner, "11111111111111111111111111111111"); assert_eq!(value.rent_epoch, 2); assert_eq!(value.space, Some(80)); assert_eq!(value.data, UiAccountData::Binary("11116bv5nS2h3y12kD1yUKeMZvGcKLSjQgX6BeV7u1FrjeJcKfsHRTPuR3oZ1EioKtYGiYxpxMG5vpbZLsbcBYBEmZZcMKaSoGx9JZeAuWf".to_string(), UiAccountEncoding::Base58)) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/inflation_reward.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{ impl_method, utils::{rpc_config::RpcEpochConfig, rpc_response::RpcInflationReward}, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetInflationRewardRequest { #[serde_as(as = "Vec<DisplayFromStr>")] pub addresses: Vec<Pubkey>, pub config: Option<RpcEpochConfig>, } impl_method!(GetInflationRewardRequest, "getInflationReward"); impl GetInflationRewardRequest { pub fn new(addresses: Vec<Pubkey>) -> Self { Self { addresses, config: None, } } pub fn new_with_config(addresses: Vec<Pubkey>, config: RpcEpochConfig) -> Self { Self { addresses, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetInflationRewardResponse(Vec<Option<RpcInflationReward>>); impl From<GetInflationRewardResponse> for Vec<Option<RpcInflationReward>> { fn from(value: GetInflationRewardResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetInflationRewardRequest::NAME) .id(1) .params(GetInflationRewardRequest::new_with_config( vec![ pubkey!("6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu"), pubkey!("BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2"), ], RpcEpochConfig { epoch: Some(2), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getInflationReward","params":[["6dmNQ5jwLeLk5REvio1JcMshcbvkYMwy26sJ8pbkvStu","BGsqMegLpV6n6Ve146sSX2dTjUMj3M92HnU8BbNRMhF2"],{"epoch":2}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"amount":2500,"effectiveSlot":224,"epoch":2,"postBalance":499999442500},null],"id":1}"#; let response: ClientResponse<GetInflationRewardResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!(value.len(), 2); let inflation_reward = value[0].as_ref().unwrap(); assert_eq!(inflation_reward.amount, 2500); assert_eq!(inflation_reward.effective_slot, 224); assert_eq!(inflation_reward.epoch, 2); assert_eq!(inflation_reward.post_balance, 499999442500); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/health.rs
use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetHealthRequest; impl_method!(GetHealthRequest, "getHealth"); #[derive(Debug, Deserialize)] pub struct ErrorValue { pub code: i32, pub message: String, pub data: serde_json::Value, } #[derive(Debug, Deserialize)] pub struct GetHealthResponse(String); #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetHealthRequest::NAME) .id(1) .params(GetHealthRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getHealth"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": "ok", "id": 1 }"#; let response: ClientResponse<GetHealthResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, "ok"); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/signatures_for_address.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{ impl_method, utils::{ rpc_config::RpcSignaturesForAddressConfig, rpc_response::RpcConfirmedTransactionStatusWithSignature, }, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetSignaturesForAddressRequest { #[serde_as(as = "DisplayFromStr")] pubkey: Pubkey, config: Option<RpcSignaturesForAddressConfig>, } impl_method!(GetSignaturesForAddressRequest, "getSignaturesForAddress"); impl GetSignaturesForAddressRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: RpcSignaturesForAddressConfig) -> Self { Self { pubkey, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetSignaturesForAddressResponse(Vec<RpcConfirmedTransactionStatusWithSignature>); impl From<GetSignaturesForAddressResponse> for Vec<RpcConfirmedTransactionStatusWithSignature> { fn from(val: GetSignaturesForAddressResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSignaturesForAddressRequest::NAME) .id(1) .params(GetSignaturesForAddressRequest::new_with_config( pubkey!("Vote111111111111111111111111111111111111111"), RpcSignaturesForAddressConfig { limit: Some(1), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getSignaturesForAddress","params":["Vote111111111111111111111111111111111111111",{"limit":1}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"err":null,"memo":null,"signature":"5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv","slot":114,"blockTime":null}],"id":1}"#; let response: ClientResponse<GetSignaturesForAddressResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, vec![RpcConfirmedTransactionStatusWithSignature {block_time:None,err:None,memo:None,slot:114,signature:"5h6xBEauJ3PK6SWCZ1PGjBvj8vDdWG3KpwATGy1ARAXFSDwt8GFXM7W5Ncn16wmqokgpiKRLuS83KUxyZyv2sUYv".to_string(), confirmation_status: None}]); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/first_available_block.rs
use solana_sdk::clock::Slot; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetFirstAvailableBlockRequest; impl_method!(GetFirstAvailableBlockRequest, "getFirstAvailableBlock"); #[derive(Debug, Deserialize)] pub struct GetFirstAvailableBlockResponse(Slot); impl From<GetFirstAvailableBlockResponse> for Slot { fn from(val: GetFirstAvailableBlockResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetFirstAvailableBlockRequest::NAME) .id(1) .params(GetFirstAvailableBlockRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getFirstAvailableBlock"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 250000, "id": 1 }"#; let response: ClientResponse<GetFirstAvailableBlockResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 250000); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/minimum_balance_for_rent_exemption.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::commitment_config::CommitmentConfig; use crate::{impl_method, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetMinimumBalanceForRentExemptionRequest { pub data_length: usize, pub config: Option<CommitmentConfig>, } impl_method!( GetMinimumBalanceForRentExemptionRequest, "getMinimumBalanceForRentExemption" ); impl GetMinimumBalanceForRentExemptionRequest { pub fn new(data_length: usize) -> Self { Self { data_length, config: None, } } pub fn new_with_config(data_length: usize, config: CommitmentConfig) -> Self { Self { data_length, config: Some(config), } } } #[derive(Debug, Clone, Serialize, Deserialize)] pub struct GetMinimumBalanceForRentExemptionResponse(u64); impl From<GetMinimumBalanceForRentExemptionResponse> for u64 { fn from(val: GetMinimumBalanceForRentExemptionResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetMinimumBalanceForRentExemptionRequest::NAME) .id(1) .params(GetMinimumBalanceForRentExemptionRequest::new(50)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getMinimumBalanceForRentExemption","params":[50]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 500, "id": 1 }"#; let response: ClientResponse<GetMinimumBalanceForRentExemptionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 500); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/token_account_balance.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::account_decoder::parse_token::UiTokenAmount; use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey}; use super::Context; use crate::{impl_method, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetTokenAccountBalanceRequest { #[serde_as(as = "DisplayFromStr")] pub account: Pubkey, pub config: Option<CommitmentConfig>, } impl_method!(GetTokenAccountBalanceRequest, "getTokenAccountBalance"); impl GetTokenAccountBalanceRequest { pub fn new(account: Pubkey) -> Self { Self { account, config: None, } } pub fn new_with_config(account: Pubkey, config: CommitmentConfig) -> Self { Self { account, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTokenAccountBalanceResponse { pub context: Context, pub value: UiTokenAmount, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTokenAccountBalanceRequest::NAME) .id(1) .params(GetTokenAccountBalanceRequest::new(pubkey!( "7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7" ))); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTokenAccountBalance","params":["7fUAJdStEuGbc3sM84cKRL6yYaaSstyLSU4ve5oovLS7"]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"amount":"9864","decimals":2,"uiAmount":98.64,"uiAmountString":"98.64"}},"id":1}"#; let response: ClientResponse<GetTokenAccountBalanceResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, UiTokenAmount { amount: "9864".to_string(), decimals: 2, ui_amount: Some(98.64), ui_amount_string: "98.64".to_string() } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/slot_leader.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, DisplayFromStr}; use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey}; use std::str::FromStr; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Default, Serialize_tuple)] pub struct GetSlotLeaderRequest { #[serde(skip_serializing_if = "Option::is_none")] pub config: Option<CommitmentConfig>, } impl_method!(GetSlotLeaderRequest, "getSlotLeader"); impl GetSlotLeaderRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[serde_as] #[derive(Debug, Deserialize)] pub struct GetSlotLeaderResponse(#[serde_as(as = "DisplayFromStr")] Pubkey); impl From<GetSlotLeaderResponse> for Pubkey { fn from(val: GetSlotLeaderResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSlotLeaderRequest::NAME) .id(1) .params(GetSlotLeaderRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getSlotLeader"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":"ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS","id":1}"#; let response: ClientResponse<GetSlotLeaderResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, pubkey!("ENvAW7JScgYq6o4zKZwewtkzzJgDzuJAFxYasvmEQdpS") ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/program_accounts.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{ impl_method, utils::rpc_config::{RpcKeyedAccount, RpcProgramAccountsConfig}, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetProgramAccountsRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub config: Option<RpcProgramAccountsConfig>, } impl_method!(GetProgramAccountsRequest, "getProgramAccounts"); impl GetProgramAccountsRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: RpcProgramAccountsConfig) -> Self { Self { pubkey, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetProgramAccountsResponse(Option<Vec<RpcKeyedAccount>>); impl GetProgramAccountsResponse { pub fn keyed_accounts(&self) -> Option<&Vec<RpcKeyedAccount>> { self.0.as_ref() } } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::account_decoder::{UiAccount, UiAccountData}; use solana_sdk::pubkey; use crate::{ methods::Method, utils::{ rpc_config::RpcAccountInfoConfig, rpc_filter::{Memcmp, MemcmpEncodedBytes, RpcFilterType}, }, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(GetProgramAccountsRequest::NAME) .id(1) .params(GetProgramAccountsRequest::new_with_config( pubkey!("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T"), RpcProgramAccountsConfig { filters: Some(vec![ RpcFilterType::DataSize(17), RpcFilterType::Memcmp(Memcmp { offset: 4, bytes: MemcmpEncodedBytes::Base64("3Mc6vR".to_string()), encoding: None, }), ]), account_config: RpcAccountInfoConfig::default(), with_context: None, }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getProgramAccounts","params":["4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",{"filters":[{"dataSize":17},{"memcmp":{"offset":4,"bytes":"3Mc6vR"}}]}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"account":{"data":"2R9jLfiAQ9bgdcw6h8s44439","executable":false,"lamports":15298080,"owner":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","rentEpoch":28,"space":42},"pubkey":"CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"}],"id":1}"#; let response: ClientResponse<GetProgramAccountsResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0.unwrap(); assert_eq!( value, vec![RpcKeyedAccount { account: UiAccount { executable: false, data: UiAccountData::LegacyBinary("2R9jLfiAQ9bgdcw6h8s44439".to_string()), lamports: 15298080, owner: "4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T".to_string(), rent_epoch: 28, space: Some(42) }, pubkey: "CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY".to_string() }] ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/version.rs
use crate::{impl_method, utils::rpc_response::RpcVersionInfo, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetVersionRequest; impl_method!(GetVersionRequest, "getVersion"); #[derive(Debug, Deserialize)] pub struct GetVersionResponse(RpcVersionInfo); impl From<GetVersionResponse> for RpcVersionInfo { fn from(value: GetVersionResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetVersionRequest::NAME) .id(1) .params(GetVersionRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getVersion"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"feature-set":2891131721,"solana-core":"1.16.7"},"id":1}"#; let response: ClientResponse<GetVersionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, RpcVersionInfo { feature_set: Some(2891131721), solana_core: "1.16.7".to_string() } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/epoch_info.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::{commitment_config::CommitmentConfig, epoch_info::EpochInfo}; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple, Default)] pub struct GetEpochInfoRequest { pub config: Option<CommitmentConfig>, } impl_method!(GetEpochInfoRequest, "getEpochInfo"); impl GetEpochInfoRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetEpochInfoResponse(EpochInfo); impl From<GetEpochInfoResponse> for EpochInfo { fn from(value: GetEpochInfoResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetEpochInfoRequest::NAME) .id(1) .params(GetEpochInfoRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getEpochInfo"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"absoluteSlot":166598,"blockHeight":166500,"epoch":27,"slotIndex":2790,"slotsInEpoch":8192,"transactionCount":22661093},"id":1}"#; let response: ClientResponse<GetEpochInfoResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, EpochInfo { absolute_slot: 166598, block_height: 166500, epoch: 27, slot_index: 2790, slots_in_epoch: 8192, transaction_count: Some(22661093) } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/highest_snapshot_slot.rs
use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetHighestSnapshotSlotRequest; impl_method!(GetHighestSnapshotSlotRequest, "getHighestSnapshotSlot"); #[derive(Debug, Deserialize)] pub struct GetHighestSnapshotSlotResponse { pub full: u64, pub incremental: Option<u64>, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetHighestSnapshotSlotRequest::NAME) .id(1) .params(GetHighestSnapshotSlotRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getHighestSnapshotSlot"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"full":100,"incremental":110},"id":1}"#; let response: ClientResponse<GetHighestSnapshotSlotResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.full, 100); assert_eq!(response.result.incremental, Some(110)); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/inflation_governor.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::commitment_config::CommitmentConfig; use crate::{ impl_method, utils::rpc_response::RpcInflationGovernor, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetInflationGovernorRequest { pub config: Option<CommitmentConfig>, } impl_method!(GetInflationGovernorRequest, "getInflationGovernor"); impl GetInflationGovernorRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetInflationGovernorResponse(RpcInflationGovernor); impl From<GetInflationGovernorResponse> for RpcInflationGovernor { fn from(value: GetInflationGovernorResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetInflationGovernorRequest::NAME) .id(1) .params(GetInflationGovernorRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getInflationGovernor"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"foundation":0.05,"foundationTerm":7,"initial":0.15,"taper":0.15,"terminal":0.015},"id":1}"#; let response: ClientResponse<GetInflationGovernorResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!(value.foundation, 0.05); assert_eq!(value.foundation_term, 7.0); assert_eq!(value.initial, 0.15); assert_eq!(value.taper, 0.15); assert_eq!(value.terminal, 0.015); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/stake_minimum_delegation.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::commitment_config::CommitmentConfig; use crate::impl_method; use super::Context; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetStakeMinimumDelegationRequest { config: Option<CommitmentConfig>, } impl_method!( GetStakeMinimumDelegationRequest, "getStakeMinimumDelegation" ); impl GetStakeMinimumDelegationRequest { pub fn new() -> Self { Self { config: None } } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetStakeMinimumDelegationResponse { pub context: Context, pub value: u64, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetStakeMinimumDelegationRequest::NAME) .id(1) .params(GetStakeMinimumDelegationRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getStakeMinimumDelegation"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":501},"value":1000000000},"id":1}"#; let response: ClientResponse<GetStakeMinimumDelegationResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 501); assert_eq!(response.result.value, 1000000000); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/signature_statuses.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::transaction_status::TransactionConfirmationStatus; use solana_sdk::{signature::Signature, transaction::TransactionError}; use super::Context; use crate::{ impl_method, utils::rpc_config::RpcSignatureStatusConfig, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetSignatureStatusesRequest { #[serde_as(as = "Vec<DisplayFromStr>")] pub signatures: Vec<Signature>, pub config: Option<RpcSignatureStatusConfig>, } impl_method!(GetSignatureStatusesRequest, "getSignatureStatuses"); impl GetSignatureStatusesRequest { pub fn new(signatures: Vec<Signature>) -> Self { Self { signatures, config: None, } } pub fn new_with_config(signatures: Vec<Signature>, config: RpcSignatureStatusConfig) -> Self { Self { signatures, config: Some(config), } } } #[derive(Debug, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct SignatureStatusesValue { pub slot: u64, pub confirmations: Option<u64>, pub err: Option<TransactionError>, pub confirmation_status: Option<TransactionConfirmationStatus>, } #[derive(Debug, Deserialize)] pub struct GetSignatureStatusesResponse { pub context: Context, pub value: Vec<Option<SignatureStatusesValue>>, } #[cfg(test)] mod tests { use std::str::FromStr; use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSignatureStatusesRequest::NAME) .id(1) .params(GetSignatureStatusesRequest::new_with_config(vec![Signature::from_str("5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW").unwrap()], RpcSignatureStatusConfig {search_transaction_history: true})); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getSignatureStatuses","params":[["5VERv8NMvzbJMEkV8xnrLkEaWRtSz9CosKDYjCJjBRnbJLgp8uirBgmQpjKhoR4tjF3ZpRzrFmBV6UjKdiSZkQUW"],{"searchTransactionHistory":true}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":82},"value":[{"slot":48,"confirmations":null,"err":null,"status":{"Ok":null},"confirmationStatus":"finalized"},null]},"id":1}"#; let response: ClientResponse<GetSignatureStatusesResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 82); assert_eq!( response.result.value, vec![ Some(SignatureStatusesValue { slot: 48, err: None, confirmation_status: Some(TransactionConfirmationStatus::Finalized), confirmations: None }), None ] ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/token_accounts_by_owner.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use super::Context; use crate::{ impl_method, utils::{ rpc_config::{RpcAccountInfoConfig, RpcKeyedAccount}, rpc_filter::RpcTokenAccountsFilter, }, ClientRequest, ClientResponse, }; #[serde_as] #[derive(Debug, Serialize_tuple)] pub struct GetTokenAccountsByOwnerRequest { #[serde_as(as = "DisplayFromStr")] pub owner: Pubkey, pub filter: RpcTokenAccountsFilter, pub config: Option<RpcAccountInfoConfig>, } impl_method!(GetTokenAccountsByOwnerRequest, "getTokenAccountsByOwner"); impl GetTokenAccountsByOwnerRequest { pub fn new(owner: Pubkey, filter: RpcTokenAccountsFilter) -> Self { Self { owner, filter, config: None, } } pub fn new_with_config( owner: Pubkey, filter: RpcTokenAccountsFilter, config: RpcAccountInfoConfig, ) -> Self { Self { owner, filter, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTokenAccountsByOwnerResponse { pub context: Context, pub value: Vec<RpcKeyedAccount>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::account_decoder::{ ParsedAccount, UiAccount, UiAccountData, UiAccountEncoding, }; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTokenAccountsByOwnerRequest::NAME) .id(1) .params(GetTokenAccountsByOwnerRequest::new_with_config( pubkey!("4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"), RpcTokenAccountsFilter::Mint(pubkey!( "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" )), RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::JsonParsed), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTokenAccountsByOwner","params":["4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F",{"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"},{"encoding":"jsonParsed"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"state":"initialized","isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"},"type":"account"},"space":165},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4,"space":165},"pubkey":"C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx"}]},"id":1}"#; let response: ClientResponse<GetTokenAccountsByOwnerResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, vec![RpcKeyedAccount { account: UiAccount { owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA".to_string(), data: UiAccountData::Json(ParsedAccount { program: "spl-token".to_string(), space: 165, parsed: serde_json::from_str(r#"{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"state":"initialized","isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"},"type":"account"}"#).unwrap() }), executable: false, lamports: 1726080, rent_epoch: 4, space: Some(165) }, pubkey: "C2gJg6tKpQs41PRS1nC8aw3ZKNZK3HQQZGVrDFDup5nx".to_string() }] ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/block_height.rs
use serde::Serialize; use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::commitment_config::CommitmentConfig; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple, Default)] pub struct GetBlockHeightRequest { pub config: Option<CommitmentConfig>, } impl_method!(GetBlockHeightRequest, "getBlockHeight"); impl GetBlockHeightRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBlockHeightResponse(u64); impl From<GetBlockHeightResponse> for u64 { fn from(value: GetBlockHeightResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlockHeightRequest::NAME) .id(1) .params(GetBlockHeightRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockHeight"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":1233,"id":1}"#; let response: ClientResponse<GetBlockHeightResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 1233); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/block_time.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::clock::UnixTimestamp; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize_tuple)] pub struct GetBlockTimeRequest { pub slot: u64, } impl_method!(GetBlockTimeRequest, "getBlockTime"); impl GetBlockTimeRequest { pub fn new(slot: u64) -> Self { Self { slot } } } #[derive(Debug, Deserialize)] pub struct GetBlockTimeResponse(Option<UnixTimestamp>); impl From<GetBlockTimeResponse> for Option<UnixTimestamp> { fn from(val: GetBlockTimeResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlockTimeRequest::NAME) .id(1) .params(GetBlockTimeRequest::new(5)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockTime","params":[5]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":1574721591,"id":1}"#; let response: ClientResponse<GetBlockTimeResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0.unwrap(), 1574721591); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/blockhash_valid.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::hash::Hash; use super::Context; use crate::{impl_method, utils::rpc_config::RpcContextConfig, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple, Default)] pub struct IsBlockhashValidRequest { #[serde_as(as = "DisplayFromStr")] blockhash: Hash, config: Option<RpcContextConfig>, } impl_method!(IsBlockhashValidRequest, "isBlockhashValid"); impl IsBlockhashValidRequest { pub fn new(blockhash: Hash) -> Self { Self { blockhash, config: None, } } pub fn new_with_config(blockhash: Hash, config: RpcContextConfig) -> Self { Self { blockhash, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct IsBlockhashValidResponse { pub context: Context, pub value: bool, } #[cfg(test)] mod tests { use std::{collections::HashMap, str::FromStr}; use serde_json::Value; use solana_extra_wasm::account_decoder::UiAccountData; use solana_sdk::{commitment_config::CommitmentConfig, pubkey}; use crate::{ methods::Method, utils::rpc_response::RpcBlockProductionRange, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(IsBlockhashValidRequest::NAME) .id(45) .params(IsBlockhashValidRequest::new_with_config( Hash::from_str("J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW").unwrap(), RpcContextConfig { commitment: Some(CommitmentConfig::processed()), min_context_slot: None, }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"id":45,"jsonrpc":"2.0","method":"isBlockhashValid","params":["J7rBdM6AecPDEZp8aPq5iPSNKVkU5Q76F3oAV4eW5wsW",{"commitment":"processed"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":2483},"value":false},"id":1}"#; let response: ClientResponse<IsBlockhashValidResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert!(!response.result.value); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/block_commitment.rs
use serde::Deserialize; use serde_tuple::Serialize_tuple; use solana_extra_wasm::program::vote::vote_state::MAX_LOCKOUT_HISTORY; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize_tuple)] pub struct GetBlockCommitmentRequest { pub slot: u64, } impl_method!(GetBlockCommitmentRequest, "getBlockCommitment"); impl GetBlockCommitmentRequest { pub fn new(slot: u64) -> Self { Self { slot } } } type BlockCommitmentArray = [u64; MAX_LOCKOUT_HISTORY + 1]; #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct GetBlockCommitmentResponse { pub commitment: Option<BlockCommitmentArray>, pub total_stake: u64, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlockCommitmentRequest::NAME) .id(1) .params(GetBlockCommitmentRequest::new(5)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlockCommitment","params":[5]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"commitment":[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,32],"totalStake":42},"id":1}"#; let response: ClientResponse<GetBlockCommitmentResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.total_stake, 42); assert_eq!( response.result.commitment, Some([ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 32 ]) ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/balance.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey}; use super::Context; use crate::{impl_method, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetBalanceRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub config: Option<CommitmentConfig>, } impl_method!(GetBalanceRequest, "getBalance"); impl GetBalanceRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: CommitmentConfig) -> Self { Self { pubkey, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBalanceResponse { pub context: Context, pub value: u64, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let pubkey = pubkey!("83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"); let request = ClientRequest::new(GetBalanceRequest::NAME) .id(1) .params(GetBalanceRequest::new(pubkey)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBalance","params":["83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":0},"id":1}"#; let response: ClientResponse<GetBalanceResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1); assert_eq!(response.result.value, 0); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/identity.rs
use serde_with::{serde_as, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetIdentityRequest; impl_method!(GetIdentityRequest, "getIdentity"); #[serde_as] #[derive(Debug, Deserialize)] pub struct GetIdentityResponse { #[serde_as(as = "DisplayFromStr")] pub identity: Pubkey, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetIdentityRequest::NAME) .id(1) .params(GetIdentityRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getIdentity"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"identity":"2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN"},"id":1}"#; let response: ClientResponse<GetIdentityResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.identity, pubkey!("2r1F4iWqVcb8M1DbAjQuFpebkQHY9hcVU4WuW2DJBppN") ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/mod.rs
#![allow(unused_imports)] mod account_info; mod balance; mod block; mod block_commitment; mod block_height; mod block_production; mod block_time; mod blockhash_valid; mod blocks; mod blocks_with_limit; mod cluster_nodes; mod epoch_info; mod epoch_schedule; mod fee_for_message; mod first_available_block; mod genesis_hash; mod health; mod highest_snapshot_slot; mod identity; mod inflation_governor; mod inflation_rate; mod inflation_reward; mod largest_accounts; mod latest_blockhash; mod leader_schedule; mod max_retransmit_slot; mod max_shred_insert_slot; mod minimum_balance_for_rent_exemption; mod minimum_ledger_slot; mod multiple_accounts; mod program_accounts; mod recent_performance_samples; mod recent_prioritization_fees; mod request_airdrop; mod send_transaction; mod signature_statuses; mod signatures_for_address; mod simulate_transaction; mod slot; mod slot_leader; mod slot_leaders; mod stake_activation; mod stake_minimum_delegation; mod supply; mod token_account_balance; mod token_accounts_by_delegate; mod token_accounts_by_owner; mod token_largest_accounts; mod token_supply; mod transaction; mod transaction_count; mod version; mod vote_accounts; use serde::{Deserialize, Serialize}; use serde_with::{serde_as, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; pub use { account_info::{GetAccountInfoRequest, GetAccountInfoResponse}, balance::{GetBalanceRequest, GetBalanceResponse}, block::{GetBlockRequest, GetBlockResponse}, block_commitment::{GetBlockCommitmentRequest, GetBlockCommitmentResponse}, block_height::{GetBlockHeightRequest, GetBlockHeightResponse}, block_production::{GetBlockProductionRequest, GetBlockProductionResponse}, block_time::{GetBlockTimeRequest, GetBlockTimeResponse}, blockhash_valid::{IsBlockhashValidRequest, IsBlockhashValidResponse}, blocks::{GetBlocksRequest, GetBlocksResponse}, blocks_with_limit::{GetBlocksWithLimitRequest, GetBlocksWithLimitResponse}, cluster_nodes::{GetClusterNodesRequest, GetClusterNodesResponse, RpcContactInfoWasm}, epoch_info::{GetEpochInfoRequest, GetEpochInfoResponse}, epoch_schedule::{GetEpochScheduleRequest, GetEpochScheduleResponse}, fee_for_message::{GetFeeForMessageRequest, GetFeeForMessageResponse}, first_available_block::{GetFirstAvailableBlockRequest, GetFirstAvailableBlockResponse}, genesis_hash::{GetGenesisHashRequest, GetGenesisHashResponse}, health::{GetHealthRequest, GetHealthResponse}, highest_snapshot_slot::{GetHighestSnapshotSlotRequest, GetHighestSnapshotSlotResponse}, identity::{GetIdentityRequest, GetIdentityResponse}, inflation_governor::{GetInflationGovernorRequest, GetInflationGovernorResponse}, inflation_rate::{GetInflationRateRequest, GetInflationRateResponse}, inflation_reward::{GetInflationRewardRequest, GetInflationRewardResponse}, largest_accounts::{GetLargestAccountsRequest, GetLargestAccountsResponse}, latest_blockhash::{GetLatestBlockhashRequest, GetLatestBlockhashResponse}, leader_schedule::{GetLeaderScheduleRequest, GetLeaderScheduleResponse}, max_retransmit_slot::{GetMaxRetransmitSlotRequest, GetMaxRetransmitSlotResponse}, max_shred_insert_slot::{GetMaxShredInsertSlotRequest, GetMaxShredInsertSlotResponse}, minimum_balance_for_rent_exemption::{ GetMinimumBalanceForRentExemptionRequest, GetMinimumBalanceForRentExemptionResponse, }, minimum_ledger_slot::{MinimumLedgerSlotRequest, MinimumLedgerSlotResponse}, multiple_accounts::{GetMultipleAccountsRequest, GetMultipleAccountsResponse}, program_accounts::{GetProgramAccountsRequest, GetProgramAccountsResponse}, recent_performance_samples::{ GetRecentPerformanceSamplesRequest, GetRecentPerformanceSamplesResponse, }, recent_prioritization_fees::{ GetRecentPrioritizationFeesRequest, GetRecentPrioritizationFeesResponse, }, request_airdrop::{RequestAirdropRequest, RequestAirdropResponse}, send_transaction::{SendTransactionRequest, SendTransactionResponse}, signature_statuses::{ GetSignatureStatusesRequest, GetSignatureStatusesResponse, SignatureStatusesValue, }, signatures_for_address::{GetSignaturesForAddressRequest, GetSignaturesForAddressResponse}, simulate_transaction::{SimulateTransactionRequest, SimulateTransactionResponse}, slot::{GetSlotRequest, GetSlotResponse}, slot_leader::{GetSlotLeaderRequest, GetSlotLeaderResponse}, slot_leaders::{GetSlotLeadersRequest, GetSlotLeadersResponse}, stake_activation::{GetStakeActivationRequest, GetStakeActivationResponse}, stake_minimum_delegation::{ GetStakeMinimumDelegationRequest, GetStakeMinimumDelegationResponse, }, supply::{GetSupplyRequest, GetSupplyResponse}, token_account_balance::{GetTokenAccountBalanceRequest, GetTokenAccountBalanceResponse}, token_accounts_by_delegate::{ GetTokenAccountsByDelegateRequest, GetTokenAccountsByDelegateResponse, }, token_accounts_by_owner::{GetTokenAccountsByOwnerRequest, GetTokenAccountsByOwnerResponse}, token_largest_accounts::{GetTokenLargestAccountsRequest, GetTokenLargestAccountsResponse}, token_supply::{GetTokenSupplyRequest, GetTokenSupplyResponse}, transaction::{GetTransactionRequest, GetTransactionResponse}, transaction_count::{GetTransactionCountRequest, GetTransactionCountResponse}, version::{GetVersionRequest, GetVersionResponse}, vote_accounts::{GetVoteAccountsRequest, GetVoteAccountsResponse}, }; #[derive(Debug, PartialEq, Deserialize)] pub struct Context { slot: u64, } #[derive(Debug, Clone, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct BlockProductionRange { pub first_slot: u64, #[serde(skip_serializing_if = "Option::is_none")] pub last_slot: Option<u64>, } pub trait Method: Serialize { const NAME: &'static str; } #[macro_export] macro_rules! impl_method { ($ident:ident, $name:literal) => { impl $crate::methods::Method for $ident { const NAME: &'static str = $name; } }; }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/token_supply.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::account_decoder::parse_token::UiTokenAmount; use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey}; use super::Context; use crate::{impl_method, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetTokenSupplyRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub config: Option<CommitmentConfig>, } impl_method!(GetTokenSupplyRequest, "getTokenSupply"); impl GetTokenSupplyRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: CommitmentConfig) -> Self { Self { pubkey, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTokenSupplyResponse { pub context: Context, pub value: UiTokenAmount, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTokenSupplyRequest::NAME) .id(1) .params(GetTokenSupplyRequest::new(pubkey!( "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" ))); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTokenSupply","params":["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"amount":"100000","decimals":2,"uiAmount":1000,"uiAmountString":"1000"}},"id":1}"#; let response: ClientResponse<GetTokenSupplyResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, UiTokenAmount { amount: "100000".to_string(), ui_amount_string: "1000".to_string(), decimals: 2, ui_amount: Some(1000.0) } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/block.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_extra_wasm::transaction_status::UiConfirmedBlock; use solana_sdk::clock::Slot; use crate::{impl_method, utils::rpc_config::RpcBlockConfig, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetBlockRequest { pub slot: Slot, pub config: Option<RpcBlockConfig>, } impl_method!(GetBlockRequest, "getBlock"); impl GetBlockRequest { pub fn new(slot: Slot) -> Self { Self { slot, config: None } } pub fn new_with_config(slot: Slot, config: RpcBlockConfig) -> Self { Self { slot, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBlockResponse(UiConfirmedBlock); impl From<GetBlockResponse> for UiConfirmedBlock { fn from(value: GetBlockResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::transaction_status::{ EncodedTransaction, EncodedTransactionWithStatusMeta, TransactionDetails, UiCompiledInstruction, UiMessage, UiRawMessage, UiTransaction, UiTransactionEncoding, UiTransactionStatusMeta, }; use solana_sdk::message::MessageHeader; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlockRequest::NAME).id(1).params( GetBlockRequest::new_with_config( 430, RpcBlockConfig { encoding: Some(UiTransactionEncoding::Json), max_supported_transaction_version: Some(0), rewards: Some(false), transaction_details: Some(TransactionDetails::Full), commitment: None, }, ), ); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlock","params":[430,{"encoding":"json","maxSupportedTransactionVersion":0,"transactionDetails":"full","rewards":false}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"blockHeight":428,"blockTime":null,"blockhash":"3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA","parentSlot":429,"previousBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B","transactions":[{"meta":{"err":null,"fee":5000,"innerInstructions":[],"logMessages":[],"postBalances":[499998932500,26858640,1,1,1],"postTokenBalances":[],"preBalances":[499998937500,26858640,1,1,1],"preTokenBalances":[],"rewards":null,"status":{"Ok":null}},"transaction":{"message":{"accountKeys":["3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe","AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc","SysvarS1otHashes111111111111111111111111111","SysvarC1ock11111111111111111111111111111111","Vote111111111111111111111111111111111111111"],"header":{"numReadonlySignedAccounts":0,"numReadonlyUnsignedAccounts":3,"numRequiredSignatures":1},"instructions":[{"accounts":[1,2,3,0],"data":"37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1","programIdIndex":4}],"recentBlockhash":"mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B"},"signatures":["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv"]}}]},"id":1}"#; let response: ClientResponse<GetBlockResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!(value.block_height, Some(428)); assert!(value.block_time.is_none()); assert_eq!( value.blockhash, "3Eq21vXNB5s86c62bVuUfTeaMif1N2kUqRPBmGRJhyTA" ); assert_eq!(value.parent_slot, 429); assert_eq!( value.previous_blockhash, "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B" ); assert_eq!( value.transactions, Some(vec![EncodedTransactionWithStatusMeta { version: None, meta: Some(UiTransactionStatusMeta { err: None, status: Ok(()), fee: 5000, pre_balances: vec![499998937500, 26858640, 1, 1, 1], post_balances: vec![499998932500, 26858640, 1, 1, 1], inner_instructions: Some(vec![]), log_messages: Some(vec![]), pre_token_balances: Some(vec![]), post_token_balances: Some(vec![]), rewards: None, loaded_addresses: None, return_data: None }), transaction: EncodedTransaction::Json(UiTransaction { signatures: vec!["2nBhEBYYvfaAe16UMNqRHre4YNSskvuYgx3M6E4JP1oDYvZEJHvoPzyUidNgNX5r9sTyN1J9UxtbCXy2rqYcuyuv".to_string()], message: UiMessage::Raw(UiRawMessage { header: MessageHeader { num_required_signatures: 1, num_readonly_signed_accounts: 0, num_readonly_unsigned_accounts: 3 }, account_keys: vec!["3UVYmECPPMZSCqWKfENfuoTv51fTDTWicX9xmBD2euKe".to_string(), "AjozzgE83A3x1sHNUR64hfH7zaEBWeMaFuAN9kQgujrc".to_string(), "SysvarS1otHashes111111111111111111111111111".to_string(), "SysvarC1ock11111111111111111111111111111111".to_string(), "Vote111111111111111111111111111111111111111".to_string()], recent_blockhash: "mfcyqEXB3DnHXki6KjjmZck6YjmZLvpAByy2fj4nh6B".to_string(), instructions:vec![UiCompiledInstruction { data: "37u9WtQpcm6ULa3WRQHmj49EPs4if7o9f1jSRVZpm2dvihR9C8jY4NqEwXUbLwx15HBSNcP1".to_string(), accounts: vec![1, 2, 3, 0], program_id_index: 4, }], address_table_lookups: None }) }) }]) ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/genesis_hash.rs
use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetGenesisHashRequest; impl_method!(GetGenesisHashRequest, "getGenesisHash"); #[derive(Debug, Deserialize)] pub struct GetGenesisHashResponse(String); impl From<GetGenesisHashResponse> for String { fn from(val: GetGenesisHashResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetGenesisHashRequest::NAME) .id(1) .params(GetGenesisHashRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getGenesisHash"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":"GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC","id":1}"#; let response: ClientResponse<GetGenesisHashResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, "GH7ome3EiwEr7tu9JuTh2dpYWBJK3z69Xm1ZE3MEE6JC" ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/slot_leaders.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use std::str::FromStr; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetSlotLeadersRequest { pub start_slot: Option<u64>, pub limit: Option<u64>, } impl_method!(GetSlotLeadersRequest, "getSlotLeaders"); impl GetSlotLeadersRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(start_slot: u64, limit: u64) -> Self { Self { start_slot: Some(start_slot), limit: Some(limit), } } } #[serde_as] #[derive(Debug, Deserialize)] pub struct GetSlotLeadersResponse(#[serde_as(as = "Vec<DisplayFromStr>")] Vec<Pubkey>); #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSlotLeadersRequest::NAME) .id(1) .params(GetSlotLeadersRequest::new_with_config(100, 10)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getSlotLeaders","params":[100,10]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":["ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n","ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n","ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n","ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n","Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM","Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM","Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM","Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM","DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP","DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP"],"id":1}"#; let response: ClientResponse<GetSlotLeadersResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, vec![ pubkey!("ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n"), pubkey!("ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n"), pubkey!("ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n"), pubkey!("ChorusmmK7i1AxXeiTtQgQZhQNiXYU84ULeaYF1EH15n"), pubkey!("Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM"), pubkey!("Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM"), pubkey!("Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM"), pubkey!("Awes4Tr6TX8JDzEhCZY2QVNimT6iD1zWHzf1vNyGvpLM"), pubkey!("DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP"), pubkey!("DWvDTSh3qfn88UoQTEKRV2JnLt5jtJAVoiCo3ivtMwXP"), ] ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/simulate_transaction.rs
use serde::{ser::SerializeTuple, Serialize}; use solana_extra_wasm::{account_decoder::UiAccount, transaction_status::UiTransactionEncoding}; use solana_sdk::transaction::{Transaction, TransactionError}; use crate::{ impl_method, utils::rpc_config::{serialize_and_encode, RpcSimulateTransactionConfig}, ClientRequest, ClientResponse, }; use super::Context; #[derive(Debug)] pub struct SimulateTransactionRequest { pub transaction: Transaction, pub config: Option<RpcSimulateTransactionConfig>, } impl_method!(SimulateTransactionRequest, "simulateTransaction"); impl SimulateTransactionRequest { pub fn new(transaction: Transaction) -> Self { Self { transaction, config: Some(RpcSimulateTransactionConfig { encoding: Some(UiTransactionEncoding::Base64), replace_recent_blockhash: Some(true), ..Default::default() }), } } pub fn new_with_config(transaction: Transaction, config: RpcSimulateTransactionConfig) -> Self { Self { transaction, config: Some(config), } } } impl Serialize for SimulateTransactionRequest { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let encoding = match self.config { Some(ref c) => c.encoding.unwrap_or(UiTransactionEncoding::Base58), None => UiTransactionEncoding::Base58, }; let serialized_encoded = serialize_and_encode::<Transaction>(&self.transaction, encoding).unwrap(); let tuple = match &self.config { Some(config) => { let mut tuple = serializer.serialize_tuple(2)?; tuple.serialize_element(&serialized_encoded)?; tuple.serialize_element(&config)?; tuple } None => { let mut tuple = serializer.serialize_tuple(1)?; tuple.serialize_element(&serialized_encoded)?; tuple } }; tuple.end() } } #[derive(Deserialize, Debug, PartialEq)] #[serde(rename_all = "camelCase")] pub struct SimulateTransactionResponseValue { pub err: Option<TransactionError>, pub logs: Option<Vec<String>>, pub accounts: Option<Vec<Option<UiAccount>>>, pub units_consumed: Option<u64>, pub return_data: Option<UiTransactionReturnData>, } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] #[serde(rename_all = "camelCase")] pub struct UiTransactionReturnData { pub program_id: String, pub data: (String, UiReturnDataEncoding), } #[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, Hash, PartialEq)] #[serde(rename_all = "camelCase")] pub enum UiReturnDataEncoding { Base64, } #[derive(Debug, Deserialize)] pub struct SimulateTransactionResponse { pub context: Context, pub value: SimulateTransactionResponseValue, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let tx = bincode::deserialize(&base64::decode("AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=").unwrap()).unwrap(); let request = ClientRequest::new(SimulateTransactionRequest::NAME) .id(1) .params(SimulateTransactionRequest::new_with_config( tx, RpcSimulateTransactionConfig { encoding: Some(UiTransactionEncoding::Base64), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"simulateTransaction","params":["AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAEDArczbMia1tLmq7zz4DinMNN0pJ1JtLdqIJPUw3YrGCzYAMHBsgN27lcgB6H2WQvFgyZuJYHa46puOQo9yQ8CVQbd9uHXZaGT2cvhRs7reawctIXtX1s3kTqM9YV+/wCp20C7Wj2aiuk5TReAXo+VTVg8QTHjs0UjNMMKCvpzZ+ABAgEBARU=",{"encoding":"base64"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":218},"value":{"err":null,"accounts":null,"logs":["Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]","Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units","Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=","Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success"],"returnData":{"data":["Kg==","base64"],"programId":"83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri"},"unitsConsumed":2366}},"id":1}"#; let response: ClientResponse<SimulateTransactionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 218); assert_eq!(response.result.value, SimulateTransactionResponseValue { accounts: None, err: None, logs: Some(vec!["Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]".to_string(), "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units".to_string(), "Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=".to_string(), "Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success".to_string()]), return_data: Some(UiTransactionReturnData { program_id: "83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri".to_string(), data: ("Kg==".to_string(), UiReturnDataEncoding::Base64) }), units_consumed: Some(2366) }); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/leader_schedule.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::clock::Slot; use crate::{ impl_method, utils::{rpc_config::RpcLeaderScheduleConfig, rpc_response::RpcLeaderSchedule}, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetLeaderScheduleRequest { #[serialize_always] pub slot: Option<Slot>, pub config: Option<RpcLeaderScheduleConfig>, } impl_method!(GetLeaderScheduleRequest, "getLeaderSchedule"); impl GetLeaderScheduleRequest { pub fn new() -> Self { Self::default() } pub fn new_with_slot_and_config(slot: Slot, config: RpcLeaderScheduleConfig) -> Self { Self { slot: Some(slot), config: Some(config), } } pub fn new_with_config(config: RpcLeaderScheduleConfig) -> Self { Self { slot: None, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetLeaderScheduleResponse(Option<RpcLeaderSchedule>); impl From<GetLeaderScheduleResponse> for Option<RpcLeaderSchedule> { fn from(value: GetLeaderScheduleResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetLeaderScheduleRequest::NAME) .id(1) .params(GetLeaderScheduleRequest::new_with_config( RpcLeaderScheduleConfig { identity: Some(pubkey!("4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F")), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getLeaderSchedule","params":[null,{"identity":"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63]},"id":1}"#; let response: ClientResponse<GetLeaderScheduleResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0.unwrap(); assert_eq!( value["4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"], vec![ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63 ] ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/epoch_schedule.rs
use solana_sdk::epoch_schedule::EpochSchedule; use crate::{impl_method, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetEpochScheduleRequest; impl_method!(GetEpochScheduleRequest, "getEpochSchedule"); #[derive(Debug, Deserialize)] pub struct GetEpochScheduleResponse(EpochSchedule); impl From<GetEpochScheduleResponse> for EpochSchedule { fn from(value: GetEpochScheduleResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetEpochScheduleRequest::NAME) .id(1) .params(GetEpochScheduleRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getEpochSchedule"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"firstNormalEpoch":8,"firstNormalSlot":8160,"leaderScheduleSlotOffset":8192,"slotsPerEpoch":8192,"warmup":true},"id":1}"#; let response: ClientResponse<GetEpochScheduleResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!(value.first_normal_epoch, 8); assert_eq!(value.first_normal_slot, 8160); assert_eq!(value.leader_schedule_slot_offset, 8192); assert_eq!(value.slots_per_epoch, 8192); assert!(value.warmup); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/send_transaction.rs
use std::str::FromStr; use serde::ser::SerializeTuple; use serde::Serialize; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::transaction_status::UiTransactionEncoding; use solana_sdk::{signature::Signature, transaction::Transaction}; use crate::utils::rpc_config::{serialize_and_encode, RpcSendTransactionConfig}; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug)] pub struct SendTransactionRequest { transaction: Transaction, config: Option<RpcSendTransactionConfig>, } impl_method!(SendTransactionRequest, "sendTransaction"); impl SendTransactionRequest { pub fn new(transaction: Transaction) -> Self { Self { transaction, config: None, } } pub fn new_with_config(transaction: Transaction, config: RpcSendTransactionConfig) -> Self { Self { transaction, config: Some(config), } } } impl Serialize for SendTransactionRequest { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let encoding = match self.config { Some(ref c) => c.encoding.unwrap_or(UiTransactionEncoding::Base58), None => UiTransactionEncoding::Base58, }; let serialized_encoded = serialize_and_encode::<Transaction>(&self.transaction, encoding).unwrap(); let tuple = match self.config { Some(config) => { let mut tuple = serializer.serialize_tuple(2)?; tuple.serialize_element(&serialized_encoded)?; tuple.serialize_element(&config)?; tuple } None => { let mut tuple = serializer.serialize_tuple(1)?; tuple.serialize_element(&serialized_encoded)?; tuple } }; tuple.end() } } #[serde_as] #[derive(Debug, Deserialize)] pub struct SendTransactionResponse(#[serde_as(as = "DisplayFromStr")] Signature); impl From<SendTransactionResponse> for Signature { fn from(val: SendTransactionResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let tx = bincode::deserialize(&bs58::decode("4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT").into_vec().unwrap()).unwrap(); let request = ClientRequest::new(SendTransactionRequest::NAME) .id(1) .params(SendTransactionRequest::new(tx)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"sendTransaction","params":["4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT"]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":"2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb","id":1}"#; let response: ClientResponse<SendTransactionResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, Signature::from_str("2id3YC2jK9G5Wo2phDx4gJVAew8DcY5NAojnVuao8rkxwPYPe8cSwE5GzhEgJA2y8fVjDEo6iR6ykBvDxrTQrtpb").unwrap()); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/inflation_rate.rs
use crate::{impl_method, utils::rpc_response::RpcInflationRate, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetInflationRateRequest; impl_method!(GetInflationRateRequest, "getInflationRate"); #[derive(Debug, Deserialize)] pub struct GetInflationRateResponse(RpcInflationRate); impl From<GetInflationRateResponse> for RpcInflationRate { fn from(value: GetInflationRateResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetInflationRateRequest::NAME) .id(1) .params(GetInflationRateRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"getInflationRate"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"epoch":100,"foundation":0.001,"total":0.149,"validator":0.148},"id":1}"#; let response: ClientResponse<GetInflationRateResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!(value.foundation, 0.001); assert_eq!(value.epoch, 100); assert_eq!(value.total, 0.149); assert_eq!(value.validator, 0.148); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/cluster_nodes.rs
use serde_tuple::Serialize_tuple; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct GetClusterNodesRequest; impl_method!(GetClusterNodesRequest, "getClusterNodes"); #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] pub struct RpcContactInfoWasm { pub pubkey: String, pub gossip: Option<String>, pub tpu: Option<String>, pub rpc: Option<String>, pub version: Option<String>, pub feature_set: Option<u32>, pub shred_version: Option<u16>, } #[derive(Debug, Deserialize)] pub struct GetClusterNodesResponse(Vec<RpcContactInfoWasm>); impl From<GetClusterNodesResponse> for Vec<RpcContactInfoWasm> { fn from(value: GetClusterNodesResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetClusterNodesRequest::NAME) .id(1) .params(GetClusterNodesRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getClusterNodes"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"gossip":"10.239.6.48:8001","pubkey":"9QzsJf7LPLj8GkXbYT3LFDKqsj2hHG7TA3xinJHu8epQ","rpc":"10.239.6.48:8899","tpu":"10.239.6.48:8856","version":"1.0.0 c375ce1f"}],"id":1}"#; let response: ClientResponse<GetClusterNodesResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = &response.result.0[0]; assert_eq!(value.gossip.as_ref().unwrap(), "10.239.6.48:8001"); assert_eq!(value.pubkey, "9QzsJf7LPLj8GkXbYT3LFDKqsj2hHG7TA3xinJHu8epQ"); assert_eq!(value.rpc.as_ref().unwrap(), "10.239.6.48:8899"); assert_eq!(value.tpu.as_ref().unwrap(), "10.239.6.48:8856"); assert_eq!(value.version.as_ref().unwrap(), "1.0.0 c375ce1f"); assert!(value.feature_set.is_none()); assert!(value.shred_version.is_none()); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/blocks.rs
use serde::Deserialize; use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::{clock::Slot, commitment_config::CommitmentConfig}; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] #[serde(rename_all = "camelCase")] pub struct GetBlocksRequest { pub start_slot: Slot, pub end_slot: Option<Slot>, pub config: Option<CommitmentConfig>, } impl_method!(GetBlocksRequest, "getBlocks"); impl GetBlocksRequest { pub fn new(start_slot: Slot, end_slot: Option<Slot>) -> Self { Self { start_slot, end_slot, config: None, } } pub fn new_with_config( start_slot: Slot, end_slot: Option<Slot>, config: CommitmentConfig, ) -> Self { Self { start_slot, end_slot, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBlocksResponse(Vec<Slot>); impl From<GetBlocksResponse> for Vec<Slot> { fn from(value: GetBlocksResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlocksRequest::NAME) .id(1) .params(GetBlocksRequest::new(5, Some(10))); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocks","params":[5,10]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[5,6,7,8,9,10],"id":1}"#; let response: ClientResponse<GetBlocksResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, vec![5, 6, 7, 8, 9, 10]); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/fee_for_message.rs
use serde::Serializer; use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_extra_wasm::transaction_status::UiTransactionEncoding; use solana_sdk::{commitment_config::CommitmentConfig, message::Message}; use super::Context; use crate::{impl_method, utils::rpc_config::serialize_and_encode, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetFeeForMessageRequest { #[serde(serialize_with = "ser_message")] pub message: Message, pub config: Option<CommitmentConfig>, } impl_method!(GetFeeForMessageRequest, "getFeeForMessage"); impl GetFeeForMessageRequest { pub fn new(message: Message) -> Self { Self { message, config: None, } } pub fn new_with_config(message: Message, config: CommitmentConfig) -> Self { Self { message, config: Some(config), } } } fn ser_message<S: Serializer>(msg: &Message, ser: S) -> Result<S::Ok, S::Error> { let message = serialize_and_encode::<Message>(msg, UiTransactionEncoding::Base64) .map_err(serde::ser::Error::custom)?; ser.serialize_str(&message) } #[derive(Debug, Deserialize)] pub struct FeeForMessageValue(Option<u64>); #[derive(Debug, Deserialize)] pub struct GetFeeForMessageResponse { pub context: Context, pub value: FeeForMessageValue, } impl From<GetFeeForMessageResponse> for u64 { fn from(val: GetFeeForMessageResponse) -> Self { val.value.0.unwrap_or_default() } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let decoded = base64::decode("AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA").unwrap(); let message = bincode::deserialize(&decoded).unwrap(); let request = ClientRequest::new(GetFeeForMessageRequest::NAME) .id(1) .params(GetFeeForMessageRequest::new_with_config( message, CommitmentConfig::processed(), )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"id":1,"jsonrpc":"2.0","method":"getFeeForMessage","params":["AQABAgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEBAQAA",{"commitment":"processed"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":5068},"value":5000},"id":1}"#; let response: ClientResponse<GetFeeForMessageResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 5068); assert_eq!(response.result.value.0, Some(5000)); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/multiple_accounts.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::account_decoder::UiAccount; use solana_sdk::pubkey::Pubkey; use super::Context; use crate::{impl_method, utils::rpc_config::RpcAccountInfoConfig, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] #[serde(rename_all = "camelCase")] pub struct GetMultipleAccountsRequest { #[serde_as(as = "Vec<DisplayFromStr>")] pub addresses: Vec<Pubkey>, pub config: Option<RpcAccountInfoConfig>, } impl_method!(GetMultipleAccountsRequest, "getMultipleAccounts"); impl GetMultipleAccountsRequest { pub fn new(addresses: Vec<Pubkey>) -> Self { Self { addresses, config: None, } } pub fn new_with_config(addresses: Vec<Pubkey>, config: RpcAccountInfoConfig) -> Self { Self { addresses, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetMultipleAccountsResponse { pub context: Context, pub value: Vec<Option<UiAccount>>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::account_decoder::{UiAccountData, UiAccountEncoding}; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetMultipleAccountsRequest::NAME) .id(1) .params(GetMultipleAccountsRequest::new_with_config( vec![ pubkey!("vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg"), pubkey!("4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"), ], RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::Base58), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getMultipleAccounts","params":[["vines1vzrYbzLMRdu58ou5XTby4qAqVRLmqo36NKPTg","4fYNw3dojWmQ4dXtSGE9epjRGy9pFSx62YypT7avPYvA"],{"encoding":"base58"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1},"value":[{"data":["","base64"],"executable":false,"lamports":1000000000,"owner":"11111111111111111111111111111111","rentEpoch":2,"space":16},{"data":["","base64"],"executable":false,"lamports":5000000000,"owner":"11111111111111111111111111111111","rentEpoch":2,"space":0}]},"id":1}"#; let response: ClientResponse<GetMultipleAccountsResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1); let value = response.result.value; assert_eq!( value, vec![ Some(UiAccount { lamports: 1000000000, space: Some(16), data: UiAccountData::Binary(String::new(), UiAccountEncoding::Base64), owner: "11111111111111111111111111111111".to_string(), executable: false, rent_epoch: 2 }), Some(UiAccount { lamports: 5000000000, space: Some(0), data: UiAccountData::Binary(String::new(), UiAccountEncoding::Base64), owner: "11111111111111111111111111111111".to_string(), executable: false, rent_epoch: 2 }) ] ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/recent_prioritization_fees.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, DisplayFromStr}; use solana_sdk::pubkey::Pubkey; use crate::{impl_method, utils::rpc_response::RpcPrioritizationFee}; #[serde_as] #[derive(Debug, Serialize_tuple)] pub struct GetRecentPrioritizationFeesRequest { #[serde_as(as = "Option<Vec<DisplayFromStr>>")] accounts: Option<Vec<Pubkey>>, } impl_method!( GetRecentPrioritizationFeesRequest, "getRecentPrioritizationFees" ); impl GetRecentPrioritizationFeesRequest { pub fn new() -> Self { GetRecentPrioritizationFeesRequest { accounts: None } } pub fn new_with_accounts(accounts: Vec<Pubkey>) -> Self { GetRecentPrioritizationFeesRequest { accounts: Some(accounts), } } } #[derive(Debug, Deserialize)] pub struct GetRecentPrioritizationFeesResponse(Vec<RpcPrioritizationFee>); #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetRecentPrioritizationFeesRequest::NAME) .id(1) .params(GetRecentPrioritizationFeesRequest::new_with_accounts(vec![ pubkey!("CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"), ])); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getRecentPrioritizationFees","params":[["CxELquR1gPP8wHe33gZ4QxqGB3sZ9RSwsJ2KshVewkFY"]]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"slot":348125,"prioritizationFee":0},{"slot":348126,"prioritizationFee":1000},{"slot":348127,"prioritizationFee":500},{"slot":348128,"prioritizationFee":0},{"slot":348129,"prioritizationFee":1234}],"id":1}"#; let response: ClientResponse<GetRecentPrioritizationFeesResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, vec![ RpcPrioritizationFee { slot: 348125, prioritization_fee: 0, }, RpcPrioritizationFee { slot: 348126, prioritization_fee: 1000 }, RpcPrioritizationFee { slot: 348127, prioritization_fee: 500 }, RpcPrioritizationFee { slot: 348128, prioritization_fee: 0 }, RpcPrioritizationFee { slot: 348129, prioritization_fee: 1234 } ] ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/minimum_ledger_slot.rs
use solana_sdk::clock::Slot; use crate::{impl_method, ClientRequest, ClientResponse}; #[derive(Debug, Serialize)] pub struct MinimumLedgerSlotRequest; impl_method!(MinimumLedgerSlotRequest, "minimumLedgerSlot"); #[derive(Debug, Deserialize)] pub struct MinimumLedgerSlotResponse(Slot); impl From<MinimumLedgerSlotResponse> for Slot { fn from(val: MinimumLedgerSlotResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(MinimumLedgerSlotRequest::NAME) .id(1) .params(MinimumLedgerSlotRequest); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1, "method":"minimumLedgerSlot"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{ "jsonrpc": "2.0", "result": 1234, "id": 1 }"#; let response: ClientResponse<MinimumLedgerSlotResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, 1234); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/token_accounts_by_delegate.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_extra_wasm::transaction_status::UiTransactionEncoding; use solana_sdk::pubkey::Pubkey; use super::Context; use crate::{ impl_method, utils::{ rpc_config::{RpcAccountInfoConfig, RpcKeyedAccount}, rpc_filter::RpcTokenAccountsFilter, }, ClientRequest, ClientResponse, }; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetTokenAccountsByDelegateRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub filter: RpcTokenAccountsFilter, pub config: Option<RpcAccountInfoConfig>, } impl_method!( GetTokenAccountsByDelegateRequest, "getTokenAccountsByDelegate" ); impl GetTokenAccountsByDelegateRequest { pub fn new_mint(pubkey: Pubkey, account_key: Pubkey) -> Self { Self { pubkey, filter: RpcTokenAccountsFilter::Mint(account_key), config: None, } } pub fn new_mint_with_config( pubkey: Pubkey, account_key: Pubkey, config: RpcAccountInfoConfig, ) -> Self { Self { pubkey, filter: RpcTokenAccountsFilter::Mint(account_key), config: Some(config), } } pub fn new_program(pubkey: Pubkey, account_key: Pubkey) -> Self { Self { pubkey, filter: RpcTokenAccountsFilter::ProgramId(account_key), config: None, } } pub fn new_program_with_config( pubkey: Pubkey, account_key: Pubkey, config: RpcAccountInfoConfig, ) -> Self { Self { pubkey, filter: RpcTokenAccountsFilter::ProgramId(account_key), config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetTokenAccountsByDelegateResponse { pub context: Context, pub value: Option<Vec<RpcKeyedAccount>>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_extra_wasm::account_decoder::{ ParsedAccount, UiAccount, UiAccountData, UiAccountEncoding, }; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTokenAccountsByDelegateRequest::NAME) .id(1) .params(GetTokenAccountsByDelegateRequest::new_program_with_config( pubkey!("4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T"), pubkey!("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"), RpcAccountInfoConfig { encoding: Some(UiAccountEncoding::JsonParsed), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTokenAccountsByDelegate","params":["4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T",{"programId":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"},{"encoding":"jsonParsed"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"state":"initialized","isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"},"type":"account"},"space":165},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4,"space":165},"pubkey":"28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp"}]},"id":1}"#; let response: ClientResponse<GetTokenAccountsByDelegateResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, Some( vec![RpcKeyedAccount { account: UiAccount { owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA".to_string(), data: UiAccountData::Json(ParsedAccount { program: "spl-token".to_string(), space: 165, parsed: serde_json::from_str(r#"{"info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"state":"initialized","isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"},"type":"account"}"#).unwrap() }), executable: false, lamports: 1726080, rent_epoch: 4, space: Some(165) }, pubkey: "28YTZEwqtMHWrhWcvv34se7pjS7wctgqzCPB3gReCFKp".to_string() }]) ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/latest_blockhash.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::commitment_config::CommitmentConfig; use super::Context; use crate::{impl_method, utils::rpc_response::RpcBlockhash, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetLatestBlockhashRequest { pub config: Option<CommitmentConfig>, } impl_method!(GetLatestBlockhashRequest, "getLatestBlockhash"); impl GetLatestBlockhashRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: CommitmentConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetLatestBlockhashResponse { pub context: Context, pub value: RpcBlockhash, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetLatestBlockhashRequest::NAME) .id(1) .params(GetLatestBlockhashRequest::new_with_config( CommitmentConfig::processed(), )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"id":1,"jsonrpc":"2.0","method":"getLatestBlockhash","params":[{"commitment":"processed"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":2792},"value":{"blockhash":"EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N","lastValidBlockHeight":3090}},"id":1}"#; let response: ClientResponse<GetLatestBlockhashResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 2792); let value = response.result.value; assert_eq!( value.blockhash, "EkSnNWid2cvwEVnVx9aBqawnmiCNiDgp3gUdkDPTKN1N" ); assert_eq!(value.last_valid_block_height, 3090); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/supply.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use super::Context; use crate::{ impl_method, utils::{rpc_config::RpcSupplyConfig, rpc_response::RpcSupply}, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Serialize_tuple, Default)] pub struct GetSupplyRequest { config: Option<RpcSupplyConfig>, } impl_method!(GetSupplyRequest, "getSupply"); impl GetSupplyRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: RpcSupplyConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetSupplyResponse { pub context: Context, pub value: RpcSupply, } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetSupplyRequest::NAME) .id(1) .params(GetSupplyRequest::new()); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0", "id":1, "method":"getSupply"}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":{"circulating":16000,"nonCirculating":1000000,"nonCirculatingAccounts":["FEy8pTbP5fEoqMV1GdTz83byuA8EKByqYat1PKDgVAq5","9huDUZfxoJ7wGMTffUE7vh1xePqef7gyrLJu9NApncqA","3mi1GmwEE3zo2jmfDuzvjSX9ovRXsDUKHvsntpkhuLJ9","BYxEJTDerkaRWBem3XgnVcdhppktBXa2HbkHPKj2Ui4Z"],"total":1016000}},"id":1}"#; let response: ClientResponse<GetSupplyResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, RpcSupply { circulating: 16000, non_circulating: 1000000, total: 1016000, non_circulating_accounts: vec![ "FEy8pTbP5fEoqMV1GdTz83byuA8EKByqYat1PKDgVAq5".to_string(), "9huDUZfxoJ7wGMTffUE7vh1xePqef7gyrLJu9NApncqA".to_string(), "3mi1GmwEE3zo2jmfDuzvjSX9ovRXsDUKHvsntpkhuLJ9".to_string(), "BYxEJTDerkaRWBem3XgnVcdhppktBXa2HbkHPKj2Ui4Z".to_string() ] } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/blocks_with_limit.rs
use serde::Deserialize; use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use solana_sdk::{clock::Slot, commitment_config::CommitmentConfig}; use crate::{impl_method, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] #[serde(rename_all = "camelCase")] pub struct GetBlocksWithLimitRequest { pub start_slot: Slot, pub limit: usize, pub config: Option<CommitmentConfig>, } impl_method!(GetBlocksWithLimitRequest, "getBlocksWithLimit"); impl GetBlocksWithLimitRequest { pub fn new(start_slot: Slot, limit: usize) -> Self { Self { start_slot, limit, config: None, } } pub fn new_with_config(start_slot: Slot, limit: usize, config: CommitmentConfig) -> Self { Self { start_slot, limit, config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetBlocksWithLimitResponse(Vec<Slot>); impl From<GetBlocksWithLimitResponse> for Vec<Slot> { fn from(value: GetBlocksWithLimitResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetBlocksWithLimitRequest::NAME) .id(1) .params(GetBlocksWithLimitRequest::new(5, 3)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getBlocksWithLimit","params":[5,3]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[5,6,7],"id":1}"#; let response: ClientResponse<GetBlocksWithLimitResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.0, vec![5, 6, 7]); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/vote_accounts.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use crate::{ impl_method, utils::{rpc_config::RpcGetVoteAccountsConfig, rpc_response::RpcVoteAccountStatus}, ClientRequest, ClientResponse, }; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetVoteAccountsRequest { pub config: Option<RpcGetVoteAccountsConfig>, } impl_method!(GetVoteAccountsRequest, "getVoteAccounts"); impl GetVoteAccountsRequest { pub fn new() -> Self { Self::default() } pub fn new_with_config(config: RpcGetVoteAccountsConfig) -> Self { Self { config: Some(config), } } } #[derive(Debug, Deserialize)] pub struct GetVoteAccountsResponse(RpcVoteAccountStatus); impl From<GetVoteAccountsResponse> for RpcVoteAccountStatus { fn from(value: GetVoteAccountsResponse) -> Self { value.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{ methods::Method, utils::rpc_response::RpcVoteAccountInfo, ClientRequest, ClientResponse, }; use super::*; #[test] fn request() { let request = ClientRequest::new(GetVoteAccountsRequest::NAME) .id(1) .params(GetVoteAccountsRequest::new_with_config( RpcGetVoteAccountsConfig { vote_pubkey: Some("3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw".to_string()), ..Default::default() }, )); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getVoteAccounts","params":[{"votePubkey":"3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw"}]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"current":[{"commission":0,"epochVoteAccount":true,"epochCredits":[[1,64,0],[2,192,64]],"nodePubkey":"B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD","lastVote":147,"activatedStake":42,"votePubkey":"3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw"}],"delinquent":[]},"id":1}"#; let response: ClientResponse<GetVoteAccountsResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!( response.result.0, RpcVoteAccountStatus { current: vec![RpcVoteAccountInfo { activated_stake: 42, vote_pubkey: "3ZT31jkAGhUaw8jsy4bTknwBMP8i4Eueh52By4zXcsVw".to_string(), node_pubkey: "B97CCUW3AEZFGy6uUg6zUdnNYvnVq5VG8PUtb2HayTDD".to_string(), commission: 0, epoch_vote_account: true, epoch_credits: vec![(1, 64, 0), (2, 192, 64)], last_vote: 147, root_slot: 0 }], delinquent: vec![] } ); } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/recent_performance_samples.rs
use serde_tuple::Serialize_tuple; use serde_with::skip_serializing_none; use crate::{impl_method, utils::rpc_response::RpcPerfSample, ClientRequest, ClientResponse}; #[skip_serializing_none] #[derive(Debug, Default, Serialize_tuple)] pub struct GetRecentPerformanceSamplesRequest { pub limit: Option<usize>, } impl_method!( GetRecentPerformanceSamplesRequest, "getRecentPerformanceSamples" ); impl GetRecentPerformanceSamplesRequest { pub fn new() -> Self { Self::default() } pub fn new_with_limit(limit: usize) -> Self { Self { limit: Some(limit) } } } #[derive(Debug, Deserialize)] pub struct GetRecentPerformanceSamplesResponse(Vec<RpcPerfSample>); impl From<GetRecentPerformanceSamplesResponse> for Vec<RpcPerfSample> { fn from(val: GetRecentPerformanceSamplesResponse) -> Self { val.0 } } #[cfg(test)] mod tests { use serde_json::Value; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetRecentPerformanceSamplesRequest::NAME) .id(1) .params(GetRecentPerformanceSamplesRequest::new_with_limit(4)); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getRecentPerformanceSamples","params":[4]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":[{"numSlots":126,"numTransactions":126,"numNonVoteTransaction":1,"samplePeriodSecs":60,"slot":348125},{"numSlots":126,"numTransactions":126,"numNonVoteTransaction":1,"samplePeriodSecs":60,"slot":347999},{"numSlots":125,"numTransactions":125,"numNonVoteTransaction":0,"samplePeriodSecs":60,"slot":347873},{"numSlots":125,"numTransactions":125,"numNonVoteTransaction":0,"samplePeriodSecs":60,"slot":347748}],"id":1}"#; let response: ClientResponse<GetRecentPerformanceSamplesResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); let value = response.result.0; assert_eq!( value, vec![ RpcPerfSample { num_slots: 126, num_transactions: 126, slot: 348125, sample_period_secs: 60, num_non_vote_transaction: 1 }, RpcPerfSample { num_slots: 126, num_transactions: 126, slot: 347999, sample_period_secs: 60, num_non_vote_transaction: 1 }, RpcPerfSample { num_slots: 125, num_transactions: 125, slot: 347873, sample_period_secs: 60, num_non_vote_transaction: 0 }, RpcPerfSample { num_slots: 125, num_transactions: 125, slot: 347748, sample_period_secs: 60, num_non_vote_transaction: 0 } ] ) } }
0
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src
solana_public_repos/solana-playground/solana-playground/wasm/solana-client/src/methods/token_largest_accounts.rs
use serde_tuple::Serialize_tuple; use serde_with::{serde_as, skip_serializing_none, DisplayFromStr}; use solana_sdk::{commitment_config::CommitmentConfig, pubkey::Pubkey}; use super::Context; use crate::{impl_method, ClientRequest, ClientResponse}; #[serde_as] #[skip_serializing_none] #[derive(Debug, Serialize_tuple)] pub struct GetTokenLargestAccountsRequest { #[serde_as(as = "DisplayFromStr")] pub pubkey: Pubkey, pub config: Option<CommitmentConfig>, } impl_method!(GetTokenLargestAccountsRequest, "getTokenLargestAccounts"); impl GetTokenLargestAccountsRequest { pub fn new(pubkey: Pubkey) -> Self { Self { pubkey, config: None, } } pub fn new_with_config(pubkey: Pubkey, config: CommitmentConfig) -> Self { Self { pubkey, config: Some(config), } } } #[serde_as] #[derive(Debug, Deserialize, PartialEq)] #[serde(rename_all = "camelCase")] pub struct TokenLargestAccountsValue { #[serde_as(as = "DisplayFromStr")] pub address: Pubkey, pub amount: String, pub decimals: u8, pub ui_amount: Option<f64>, pub ui_amount_string: String, } #[derive(Debug, Deserialize)] pub struct GetTokenLargestAccountsResponse { pub context: Context, pub value: Vec<TokenLargestAccountsValue>, } #[cfg(test)] mod tests { use serde_json::Value; use solana_sdk::pubkey; use crate::{methods::Method, ClientRequest, ClientResponse}; use super::*; #[test] fn request() { let request = ClientRequest::new(GetTokenLargestAccountsRequest::NAME) .id(1) .params(GetTokenLargestAccountsRequest::new(pubkey!( "3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E" ))); let ser_value = serde_json::to_value(request).unwrap(); let raw_json = r#"{"jsonrpc":"2.0","id":1,"method":"getTokenLargestAccounts","params":["3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E"]}"#; let raw_value: Value = serde_json::from_str(raw_json).unwrap(); assert_eq!(ser_value, raw_value); } #[test] fn response() { let raw_json = r#"{"jsonrpc":"2.0","result":{"context":{"slot":1114},"value":[{"address":"FYjHNoFtSQ5uijKrZFyYAxvEr87hsKXkXcxkcmkBAf4r","amount":"771","decimals":2,"uiAmount":7.71,"uiAmountString":"7.71"},{"address":"BnsywxTcaYeNUtzrPxQUvzAWxfzZe3ZLUJ4wMMuLESnu","amount":"229","decimals":2,"uiAmount":2.29,"uiAmountString":"2.29"}]},"id":1}"#; let response: ClientResponse<GetTokenLargestAccountsResponse> = serde_json::from_str(raw_json).unwrap(); assert_eq!(response.id, 1); assert_eq!(response.jsonrpc, "2.0"); assert_eq!(response.result.context.slot, 1114); assert_eq!( response.result.value, vec![ TokenLargestAccountsValue { address: pubkey!("FYjHNoFtSQ5uijKrZFyYAxvEr87hsKXkXcxkcmkBAf4r"), amount: "771".to_string(), ui_amount_string: "7.71".to_string(), decimals: 2, ui_amount: Some(7.71) }, TokenLargestAccountsValue { address: pubkey!("BnsywxTcaYeNUtzrPxQUvzAWxfzZe3ZLUJ4wMMuLESnu"), amount: "229".to_string(), ui_amount_string: "2.29".to_string(), decimals: 2, ui_amount: Some(2.29) } ] ); } }
0