From 19917b2fe982ab43e1e2f2252aedfd98ef0b191a Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 10 Aug 2020 12:55:56 -0700 Subject: [PATCH 01/10] Add transfer example --- docs/src/token.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/src/token.md b/docs/src/token.md index 353e768b4f1..b6b0c0b834c 100644 --- a/docs/src/token.md +++ b/docs/src/token.md @@ -124,6 +124,36 @@ Unwrapping GJTxcnA5Sydy8YRhqvHxbQ5QNsPyRKvzguodQEaShJje Signature: f7opZ86ZHKGvkJBQsJ8Pk81v8F3v1VUfyd4kFs4CABmfTnSZK5BffETznUU3tEWvzibgKJASCf7TUpDmwGi8Rmh ``` +### Example: Transferring tokens + +``` +$ spl-token create-account AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM +Creating account CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ +Signature: 4yPWj22mbyLu5mhfZ5WATNfYzTt5EQ7LGzryxM7Ufu7QCVjTE7czZdEBqdKR7vjKsfAqsBdjU58NJvXrTqCXvfWW +``` +``` +$ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM +Account Token Balance +------------------------------------------------------------------------------------------------- +7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 100 +CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 0 +``` + +``` +$ spl-token transfer 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi 50 CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ +Transfer 50 tokens + Sender: 7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi + Recipient: CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ +Signature: 5a3qbvoJQnTAxGPHCugibZTbSu7xuTgkxvF4EJupRjRXGgZZrnWFmKzfEzcqKF2ogCaF4QKVbAtuFx7xGwrDUcGd +``` +``` +$ spl-token accounts AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM +Account Token Balance +------------------------------------------------------------------------------------------------- +7UX2i7SucgLMQcfZ75s3VXmZZY4YRUyJN9X1RgfMoDUi AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 50 +CqAxDdBRnawzx9q4PYM3wrybLHBhDZ4P6BTV13WsRJYJ AQoKYV7tYpTrFZN6P5oUufbQKAUr9mNYGe1TTJC9wajM 50 +``` + ## Operational overview ### Creating a new token type From c3a6b51077ea537ca8cf4c93885e1486bf35e244 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Mon, 10 Aug 2020 19:57:22 -0700 Subject: [PATCH 02/10] Adapt spl-token cli to Solana 1.3.2 --- Cargo.toml | 1 + docs/src/token.md | 4 +- token/cli/Cargo.toml | 8 ++- token/cli/src/main.rs | 137 ++++++++++++++++-------------------------- 4 files changed, 59 insertions(+), 91 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 77b3a33a4e9..fa0cc0016d7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,6 +15,7 @@ members = [ # 3. Use `cargo` normally # [patch.crates-io] +#solana-account-decoder = {path = "PATH_TO_SOLANA/clap-utils" } #solana-clap-utils = {path = "PATH_TO_SOLANA/clap-utils" } #solana-cli-config = {path = "PATH_TO_SOLANA/cli-config" } #solana-client = { path = "PATH_TO_SOLANA/client"} diff --git a/docs/src/token.md b/docs/src/token.md index b6b0c0b834c..92c93ccb9f9 100644 --- a/docs/src/token.md +++ b/docs/src/token.md @@ -44,8 +44,8 @@ tokens. Once you have [Rust installed](https://rustup.rs/), run: $ cargo install spl-token-cli ``` -The `spl-token` configuration is shared with the `solana` command-line tool -Run `spl-token --help` for al full description of available commands. +The `spl-token` configuration is shared with the `solana` command-line tool. +Run `spl-token --help` for a full description of available commands. ### Example: Creating your own Token diff --git a/token/cli/Cargo.toml b/token/cli/Cargo.toml index 22cd54cd98b..14684b67f0e 100644 --- a/token/cli/Cargo.toml +++ b/token/cli/Cargo.toml @@ -10,11 +10,13 @@ version = "1.0.0" [dependencies] clap = "2.33.2" -solana-clap-utils = { version = "1.3.0"} +serde_json = "1.0.57" +solana-account-decoder = { version = "1.3.2" } +solana-clap-utils = { version = "1.3.2"} solana-cli-config = { version = "1.3.2" } -solana-client = { version = "1.3.0" } +solana-client = { version = "1.3.2" } solana-logger = { version = "1.3.2" } -solana-sdk = { version = "1.3.0" } +solana-sdk = { version = "1.3.2" } spl-token = { package = "spl-token", version = "1.0", path="../program" } [[bin]] diff --git a/token/cli/src/main.rs b/token/cli/src/main.rs index 37f71f15101..446a1f6a76b 100644 --- a/token/cli/src/main.rs +++ b/token/cli/src/main.rs @@ -2,6 +2,7 @@ use clap::{ crate_description, crate_name, crate_version, value_t, value_t_or_exit, App, AppSettings, Arg, SubCommand, }; +use solana_account_decoder::{parse_token::TokenAccountType, UiAccountData}; use solana_clap_utils::{ input_parsers::{keypair_of, pubkey_of}, input_validators::{is_amount, is_keypair, is_pubkey_or_keypair, is_url}, @@ -25,6 +26,7 @@ use std::{mem::size_of, process::exit}; struct Config { rpc_client: RpcClient, + verbose: bool, owner: Keypair, fee_payer: Keypair, commitment_config: CommitmentConfig, @@ -63,19 +65,6 @@ fn check_owner_balance(config: &Config, required_balance: u64) -> Result<(), Err } } -fn get_decimals_for_token(config: &Config, token: &Pubkey) -> Result { - if *token == native_mint::id() { - Ok(native_mint::DECIMALS) - } else { - let mint = config - .rpc_client - .get_token_mint_with_commitment(token, config.commitment_config)? - .value - .ok_or_else(|| format!("Invalid token: {}", token))?; - Ok(mint.decimals) - } -} - fn command_create_token(config: &Config, decimals: u8) -> CommmandResult { let token = Keypair::new(); println!("Creating token {}", token.pubkey()); @@ -192,39 +181,12 @@ fn command_transfer( ui_amount, sender, recipient ); - let sender_token_account = config + let sender_token_balance = config .rpc_client - .get_token_account_with_commitment(&sender, config.commitment_config)? - .value; - let recipient_token_account = config - .rpc_client - .get_token_account_with_commitment(&recipient, config.commitment_config)? + .get_token_account_balance_with_commitment(&sender, config.commitment_config)? .value; - let decimals = match (sender_token_account, recipient_token_account) { - (Some(sender_token_account), Some(recipient_token_account)) => { - if sender_token_account.mint != recipient_token_account.mint { - eprintln!("Error: token mismatch between sender and recipient"); - exit(1) - } - get_decimals_for_token(config, &sender_token_account.mint.parse::()?)? - } - (None, _) => { - eprintln!( - "Error: sender account is invalid or does not exist: {}", - sender - ); - exit(1) - } - (Some(_), None) => { - eprintln!( - "Error: recipient account is invalid or does not exist: {}", - recipient - ); - exit(1) - } - }; - let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); + let amount = spl_token::ui_amount_to_amount(ui_amount, sender_token_balance.decimals); let mut transaction = Transaction::new_with_payer( &[transfer( @@ -247,25 +209,12 @@ fn command_transfer( fn command_burn(config: &Config, source: Pubkey, ui_amount: f64) -> CommmandResult { println!("Burn {} tokens\n Source: {}", ui_amount, source); - let source_token_account = config + let source_token_balance = config .rpc_client - .get_token_account_with_commitment(&source, config.commitment_config)? + .get_token_account_balance_with_commitment(&source, config.commitment_config)? .value; - let decimals = match source_token_account { - Some(source_token_account) => { - get_decimals_for_token(config, &source_token_account.mint.parse::()?)? - } - None => { - eprintln!( - "Error: burn account is invalid or does not exist: {}", - source - ); - exit(1) - } - }; - let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); - + let amount = spl_token::ui_amount_to_amount(ui_amount, source_token_balance.decimals); let mut transaction = Transaction::new_with_payer( &[burn( &spl_token::id(), @@ -294,24 +243,11 @@ fn command_mint( ui_amount, token, recipient ); - let recipient_token_account = config + let recipient_token_balance = config .rpc_client - .get_token_account_with_commitment(&recipient, config.commitment_config)? + .get_token_account_balance_with_commitment(&recipient, config.commitment_config)? .value; - - let decimals = match recipient_token_account { - Some(recipient_token_account) => { - get_decimals_for_token(config, &recipient_token_account.mint.parse::()?)? - } - None => { - eprintln!( - "Error: recipient account is invalid or does not exist: {}", - recipient - ); - exit(1) - } - }; - let amount = spl_token::ui_amount_to_amount(ui_amount, decimals); + let amount = spl_token::ui_amount_to_amount(ui_amount, recipient_token_balance.decimals); let mut transaction = Transaction::new_with_payer( &[mint_to( @@ -400,7 +336,14 @@ fn command_balance(config: &Config, address: Pubkey) -> CommmandResult { .rpc_client .get_token_account_balance_with_commitment(&address, config.commitment_config)? .value; - println!("{}", balance.ui_amount); + + if config.verbose { + println!("ui amount: {}", balance.ui_amount); + println!("decimals: {}", balance.decimals); + println!("amount: {}", balance.amount); + } else { + println!("{}", balance.ui_amount); + } Ok(None) } @@ -432,16 +375,28 @@ fn command_accounts(config: &Config, token: Option) -> CommmandResult { println!("Account Token Balance"); println!("-------------------------------------------------------------------------------------------------"); - for (address, account) in accounts { - let balance = match config - .rpc_client - .get_token_account_balance_with_commitment(&address, config.commitment_config) - { - Ok(response) => response.value.ui_amount.to_string(), - Err(err) => format!("{}", err), - }; - - println!("{:<44} {:<44} {}", address, account.mint, balance); + 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" { + println!( + "{:<44} Unsupported account program: {}", + address, parsed_account.program + ); + } else { + match serde_json::from_value(parsed_account.parsed) { + Ok(TokenAccountType::Account(ui_token_account)) => println!( + "{:<44} {:<44} {}", + address, ui_token_account.mint, ui_token_account.token_amount.ui_amount + ), + Ok(_) => println!("{:<44} Unsupported token account", address), + Err(err) => println!("{:<44} Account parse failure: {}", address, err), + } + } + } else { + println!("{:<44} Unsupported account data format", address); + } } Ok(None) } @@ -466,6 +421,14 @@ fn main() { arg } }) + .arg( + Arg::with_name("verbose") + .long("verbose") + .short("v") + .takes_value(false) + .global(true) + .help("Show additional information"), + ) .arg( Arg::with_name("json_rpc_url") .long("url") @@ -715,9 +678,11 @@ fn main() { let owner = keypair_of(&matches, "owner").unwrap_or_else(client_keypair); let fee_payer = keypair_of(&matches, "fee_payer").unwrap_or_else(client_keypair); + let verbose = matches.is_present("verbose"); Config { rpc_client: RpcClient::new(json_rpc_url), + verbose, owner, fee_payer, commitment_config: CommitmentConfig::single(), From b28d0f0b6cd6273f9395601fb4a05dbd7fab782f Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 10:52:21 -0700 Subject: [PATCH 03/10] Bump @solana/web3.js from 0.64.0 to 0.68.0 in /token/js --- token/js/package-lock.json | 30 +++++++++++++++--------------- token/js/package.json | 2 +- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/token/js/package-lock.json b/token/js/package-lock.json index 91be90609e8..16ee7b9caf6 100644 --- a/token/js/package-lock.json +++ b/token/js/package-lock.json @@ -2202,9 +2202,9 @@ "dev": true }, "@solana/web3.js": { - "version": "0.64.0", - "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-0.64.0.tgz", - "integrity": "sha512-DlNzAXgNdk7k4Pt6CfcaAutaiXJiog9hxswtzItf0q/0/Um8JvDI1YjnMONE3IKI/jyjmTaxhsQHWAQE42KofQ==", + "version": "0.68.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-0.68.0.tgz", + "integrity": "sha512-UkzLgBVHztUHzYnXlYdSp6Lc/NJi4B3qBPc/MV6lBbr9d6WISwrfUb1YmkLBEcnvmkXITZwePSgfoRkdIC3CoA==", "requires": { "@babel/runtime": "^7.3.1", "bn.js": "^5.0.0", @@ -2315,9 +2315,9 @@ } }, "@types/lodash": { - "version": "4.14.158", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.158.tgz", - "integrity": "sha512-InCEXJNTv/59yO4VSfuvNrZHt7eeNtWQEgnieIA+mIC+MOWM9arOWG2eQ8Vhk6NbOre6/BidiXhkZYeDY9U35w==" + "version": "4.14.159", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.159.tgz", + "integrity": "sha512-gF7A72f7WQN33DpqOWw9geApQPh4M3PxluMtaHxWHXEGSN12/WbcEk/eNSqWNQcQhF66VSZ06vCF94CrHwXJDg==" }, "@types/minimatch": { "version": "3.0.3", @@ -3135,9 +3135,9 @@ "dev": true }, "crypto-hash": { - "version": "1.2.2", - "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.2.2.tgz", - "integrity": "sha512-rXXMXepuKg9gIfqE7I1jtVa6saLhzIkDQ2u3kTGUWYiUGsHcUa3LTsfrjPEdOY8kxKlryQtsOmJOU0F23yRJTg==" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/crypto-hash/-/crypto-hash-1.3.0.tgz", + "integrity": "sha512-lyAZ0EMyjDkVvz8WOeVnuCPvKVBXcMv1l5SVqO1yC7PzTwrD/pPje/BIRbWhMoPe436U+Y2nD7f5bFx0kt+Sbg==" }, "css-select": { "version": "1.2.0", @@ -5392,9 +5392,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.53", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.53.tgz", - "integrity": "sha512-51MYTDTyCziHb70wtGNFRwB4l+5JNvdqzFSkbDvpbftEgVUBEE+T5f7pROhWMp/fxp07oNIEQZd5bbfAH22ohQ==" + "version": "12.12.54", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.54.tgz", + "integrity": "sha512-ge4xZ3vSBornVYlDnk7yZ0gK6ChHf/CHB7Gl1I0Jhah8DDnEQqBzgohYG4FX4p81TNirSETOiSyn+y1r9/IR6w==" } } }, @@ -7147,9 +7147,9 @@ } }, "rpc-websockets": { - "version": "5.2.4", - "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-5.2.4.tgz", - "integrity": "sha512-6jqeJK/18hPTsmeiN+K9O4miZiAmrIncgxfPXHwuGWs9BClA2zC3fOnTThRWo4blkrjH59oKKi0KMxSK+wdtNw==", + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-5.3.1.tgz", + "integrity": "sha512-rIxEl1BbXRlIA9ON7EmY/2GUM7RLMy8zrUPTiLPFiYnYOz0I3PXfCmDDrge5vt4pW4oIcAXBDvgZuJ1jlY5+VA==", "requires": { "@babel/runtime": "^7.8.7", "assert-args": "^1.2.1", diff --git a/token/js/package.json b/token/js/package.json index 40162394623..616c5822f71 100644 --- a/token/js/package.json +++ b/token/js/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@babel/runtime": "^7.10.5", - "@solana/web3.js": "^0.64.0", + "@solana/web3.js": "^0.68.0", "bn.js": "^5.0.0", "buffer-layout": "^1.2.0", "dotenv": "8.2.0", From d1df7d32897b127bd5ecf397df9605d5aacb9878 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 10:53:22 -0700 Subject: [PATCH 04/10] Bump testnetDefaultChannel --- token-swap/js/package.json | 2 +- token/js/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/token-swap/js/package.json b/token-swap/js/package.json index 2c8446d0b77..e43d303b10b 100644 --- a/token-swap/js/package.json +++ b/token-swap/js/package.json @@ -6,7 +6,7 @@ "type": "git", "url": "https://github.com/solana-labs/solana-program-library" }, - "testnetDefaultChannel": "v1.3.1", + "testnetDefaultChannel": "v1.3.2", "scripts": { "start": "babel-node --ignore node_modules cli/main.js", "lint": "npm run pretty && eslint .", diff --git a/token/js/package.json b/token/js/package.json index 616c5822f71..24f76b74c2d 100644 --- a/token/js/package.json +++ b/token/js/package.json @@ -22,7 +22,7 @@ "/lib", "/module.flow.js" ], - "testnetDefaultChannel": "v1.3.1", + "testnetDefaultChannel": "v1.3.2", "scripts": { "build": "rollup -c", "start": "babel-node cli/main.js", From e88aa4f7b56a559e0b327ee0ee50babb058f4418 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 17:06:55 -0700 Subject: [PATCH 05/10] Adapt to create_program_address changes --- token-swap/program/src/processor.rs | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/token-swap/program/src/processor.rs b/token-swap/program/src/processor.rs index 6f48b78ef2b..a8ffbd1c5a8 100644 --- a/token-swap/program/src/processor.rs +++ b/token-swap/program/src/processor.rs @@ -11,7 +11,7 @@ use num_traits::FromPrimitive; #[cfg(not(target_arch = "bpf"))] use solana_sdk::instruction::Instruction; #[cfg(target_arch = "bpf")] -use solana_sdk::program::{create_program_address, invoke_signed}; +use solana_sdk::program::invoke_signed; use solana_sdk::{ account_info::next_account_info, account_info::AccountInfo, decode_error::DecodeError, entrypoint::ProgramResult, info, program_error::PrintProgramError, program_error::ProgramError, @@ -80,7 +80,7 @@ impl State { /// Calculates the authority id by generating a program address. pub fn authority_id(program_id: &Pubkey, my_info: &Pubkey) -> Result { - create_program_address(&[&my_info.to_bytes()[..32]], program_id) + Pubkey::create_program_address(&[&my_info.to_bytes()[..32]], program_id) .or(Err(Error::InvalidProgramAddress)) } /// Issue a spl_token `Burn` instruction. @@ -460,7 +460,7 @@ pub fn invoke_signed<'a>( if meta.pubkey == *account_info.key { let mut new_account_info = account_info.clone(); for seeds in signers_seeds.iter() { - let signer = create_program_address(seeds, &SWAP_PROGRAM_ID).unwrap(); + let signer = Pubkey::create_program_address(seeds, &SWAP_PROGRAM_ID).unwrap(); if *account_info.key == signer { new_account_info.is_signer = true; } @@ -476,26 +476,6 @@ pub fn invoke_signed<'a>( ) } -/// TODO: Remove this stub function once solana-sdk exports it -#[cfg(not(target_arch = "bpf"))] -pub fn create_program_address( - seeds: &[&[u8]], - program_id: &Pubkey, -) -> Result { - let mut hasher = solana_sdk::hash::Hasher::default(); - for seed in seeds.iter() { - if seed.len() > solana_sdk::pubkey::MAX_SEED_LEN { - return Err(solana_sdk::pubkey::PubkeyError::MaxSeedLengthExceeded); - } - hasher.hash(seed); - } - hasher.hashv(&[program_id.as_ref(), "ProgramDerivedAddress".as_ref()]); - - Ok(Pubkey::new( - solana_sdk::hash::hash(hasher.result().as_ref()).as_ref(), - )) -} - impl PrintProgramError for Error { fn print(&self) where From 4cc8c2e246dfb361e89454c1e71410ecee965c75 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 20:51:52 -0700 Subject: [PATCH 06/10] Work around missing _sol_create_program_address symbol for x86_64 --- ci/token-swap.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/token-swap.sh b/ci/token-swap.sh index fb00e857411..d18acb28f12 100755 --- a/ci/token-swap.sh +++ b/ci/token-swap.sh @@ -14,7 +14,9 @@ cc token-swap/program/inc/token-swap.h -o target/token-swap.gch ./do.sh build token ./do.sh build token-swap ./do.sh doc token-swap -./do.sh test token-swap + +# TODO: Uncomment once "Undefined symbols for architecture x86_64: _sol_create_program_address" is resolved +#./do.sh test token-swap # Install dependency project ( From 1eb3d7780c1c1adaf1dc84c4042024193df8b24c Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 21:15:41 -0700 Subject: [PATCH 07/10] clippy --- token-swap/program/src/instruction.rs | 4 ++-- token-swap/program/src/processor.rs | 2 +- token/program/src/instruction.rs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/token-swap/program/src/instruction.rs b/token-swap/program/src/instruction.rs index 88215172294..e704704e69c 100644 --- a/token-swap/program/src/instruction.rs +++ b/token-swap/program/src/instruction.rs @@ -63,7 +63,7 @@ pub enum SwapInstruction { Deposit(u64), /// Withdraw the token from the pool at the current ratio. - /// + /// /// 0. `[]` Token-swap /// 1. `[]` $authority /// 2. `[writable]` SOURCE Pool account, amount is transferable by $authority. @@ -104,7 +104,7 @@ impl SwapInstruction { } /// Serializes an [SwapInstruction](enum.SwapInstruction.html) into a byte buffer. - pub fn serialize(self: &Self) -> Result, ProgramError> { + pub fn serialize(&self) -> Result, ProgramError> { let mut output = vec![0u8; size_of::()]; match self { Self::Initialize(fees) => { diff --git a/token-swap/program/src/processor.rs b/token-swap/program/src/processor.rs index a8ffbd1c5a8..16f4cb35d0a 100644 --- a/token-swap/program/src/processor.rs +++ b/token-swap/program/src/processor.rs @@ -36,7 +36,7 @@ impl State { } /// Serializes [State](struct.State.html) into a byte buffer. - pub fn serialize(self: &Self, output: &mut [u8]) -> ProgramResult { + pub fn serialize(&self, output: &mut [u8]) -> ProgramResult { if output.len() < size_of::() { return Err(ProgramError::InvalidAccountData); } diff --git a/token/program/src/instruction.rs b/token/program/src/instruction.rs index efb6b4d2cc6..d29f4590f47 100644 --- a/token/program/src/instruction.rs +++ b/token/program/src/instruction.rs @@ -254,7 +254,7 @@ impl TokenInstruction { } /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte buffer. - pub fn pack(self: &Self) -> Result, ProgramError> { + pub fn pack(&self) -> Result, ProgramError> { let mut output = vec![0u8; size_of::()]; let mut output_len = 0; match self { From c9c867b3a6505fb31979548718a6166274d5cdce Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 21:28:07 -0700 Subject: [PATCH 08/10] Adjust path to account-decoder --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index fa0cc0016d7..cef47c04ce7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ members = [ # 3. Use `cargo` normally # [patch.crates-io] -#solana-account-decoder = {path = "PATH_TO_SOLANA/clap-utils" } +#solana-account-decoder = {path = "PATH_TO_SOLANA/account-decoder" } #solana-clap-utils = {path = "PATH_TO_SOLANA/clap-utils" } #solana-cli-config = {path = "PATH_TO_SOLANA/cli-config" } #solana-client = { path = "PATH_TO_SOLANA/client"} From 5c48539c40a32cee76d587ee1635e4489fec0645 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 21:45:43 -0700 Subject: [PATCH 09/10] Bump version to v1.0.7 --- token/program/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/token/program/Cargo.toml b/token/program/Cargo.toml index f370b73c850..68bd7c7d39d 100644 --- a/token/program/Cargo.toml +++ b/token/program/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "spl-token" -version = "1.0.6" +version = "1.0.7" description = "Solana Program Library Token" authors = ["Solana Maintainers "] repository = "https://github.com/solana-labs/solana-program-library" From 0e212f355aec4f1ec11aefcc377686bbf3d921d2 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Wed, 12 Aug 2020 10:48:00 -0700 Subject: [PATCH 10/10] Cargo.lock --- Cargo.lock | 88 +++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 76b1e70bee5..9e7c9bf315b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1835,28 +1835,32 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87caa87fb0a2775180e617610c9878ada40e77d862d32c0aff4a6ed66280d58c" +checksum = "ed92884e795ce9c3be392d4e7538457372102489ff10fafab397f6e4013ddd75" dependencies = [ "Inflector", + "base64 0.12.3", "bincode", "bs58", + "bv", "lazy_static", "serde", "serde_derive", "serde_json", + "solana-config-program", "solana-sdk", + "solana-stake-program", "solana-vote-program", - "spl-token 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-token 1.0.6", "thiserror", ] [[package]] name = "solana-clap-utils" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2e94f2ed64c0b80bb502bd1fe00dc75f06d22addf71971bc634f748376a2c5e" +checksum = "7176e4e820821769de7743958bffa721469ecea2104dfc3546c8c77c41ba7377" dependencies = [ "chrono", "clap", @@ -1884,9 +1888,9 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "964ae6b8e4c10c7532f76f579749043ed332ee2ac0fd5ca78b77df74042ff5b0" +checksum = "7979bf70e7a80f361f6777450cef2b6b443dfe304fa4c5e2ed2434bedd87ff16" dependencies = [ "bincode", "bs58", @@ -1910,9 +1914,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd4460626e2d6de0f2096485010eab0d4a0865d32356299b8bb9c9c93cf99e7b" +checksum = "2204d912ad066df071bd4025f34290bd2ad672dea9ae680b13bc83444f445f0b" dependencies = [ "bincode", "chrono", @@ -1924,9 +1928,9 @@ dependencies = [ [[package]] name = "solana-crate-features" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "66ce44be0cf411c28919c5d2af9b87dcaf7a631df66494eef1134e12fa8916b6" +checksum = "b637d625477c279cf890dcd8f322db3849f829f5e10a1a966a56d76362c7b1fa" dependencies = [ "backtrace", "bytes 0.4.12", @@ -1960,9 +1964,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e15c16f8db726d70710b461b27911e9321c653eeed5b1250bebc74bbb110be1" +checksum = "a38cdc28903de5967af0d33f31e0e34841cfc599286c38e8cecb9c0f3f6c282c" dependencies = [ "env_logger", "gethostname", @@ -1974,9 +1978,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ce583800adbcf6bc7dbdc1bcb973cde80c2c1996544f48c1786bb4b72cd5ed9" +checksum = "d448c9b0aeedc1d5f17bbe95b64892efedeb55f0b26cfcc48e79d97d654b6ca4" dependencies = [ "bincode", "bytes 0.4.12", @@ -1997,9 +2001,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b0b488009a22dd0c21e7a26bdc2a31e990d0cd8161eb5bcc59e899bb3cbd158" +checksum = "27f3a2f04a45d6a01f14c8a8bf71b638a403eb364f84479facf81f81a95e31c4" dependencies = [ "base32", "console", @@ -2017,9 +2021,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5502cfd8063437ac2b289b525cff9c271f59f3c267be6e2f6e8256df842d0d96" +checksum = "105e110f5fbd4b45672194715a9155480c897c12893dba46c3d27e028bc09e5b" dependencies = [ "assert_matches", "bincode", @@ -2056,9 +2060,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ea42a0ab1199059e60b00bebd58156bc6a8c89672fbb78bd474d98c49d330c" +checksum = "f98dced0e17ff17e910fc1f4c92e06cd3c4137c6ff0804936bfbe25202fceaee" dependencies = [ "bs58", "proc-macro2 1.0.19", @@ -2069,9 +2073,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro-frozen-abi" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ddd83d11379007984161d413872ed8ba1f94c7625967d1a8de6f1e08215eede7" +checksum = "fc0646321745ba69b47071e97ddef7dedc8e11e7ecef95f2b023a2125e4da08c" dependencies = [ "lazy_static", "proc-macro2 1.0.19", @@ -2082,9 +2086,9 @@ dependencies = [ [[package]] name = "solana-stake-program" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fdc4f7c409612f5a032f5666aa00af973a91cb63a04c1990a88247d7fe0c3f8b" +checksum = "88a9a8d4bfa7f0929c76612db4ea25f44d22487ed35461d17796e88c3e2356ed" dependencies = [ "bincode", "log", @@ -2103,9 +2107,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c15cafac36d23d432a5fb2bdee4bc8b4dcab353c3a11a2a8472f1184c225ebd" +checksum = "f4a6fad3e88f38b281da8891c0306760c80243b31922353e21ea1645dfd5609f" dependencies = [ "Inflector", "bincode", @@ -2119,15 +2123,15 @@ dependencies = [ "solana-stake-program", "solana-vote-program", "spl-memo 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", - "spl-token 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)", + "spl-token 1.0.6", "thiserror", ] [[package]] name = "solana-version" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb9849b17e4a632ae09d1dc6a94bd3adf42b4a21baca2703d190f4c9a23549b0" +checksum = "55c44dde8323b7129f29eb7046b94ac6277fa3058b0f88fc8be132e0900e4711" dependencies = [ "log", "rustc_version", @@ -2140,9 +2144,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.3.1" +version = "1.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13bd63110b90df800b551d014005a59bd86d2fff5422851bc476f1099d7c30d1" +checksum = "003f2f00613d4d659c43fceed2ca5929324d56b59a1b128eab0616a9e9f6ff0c" dependencies = [ "bincode", "log", @@ -2183,11 +2187,12 @@ dependencies = [ [[package]] name = "spl-token" version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07c8482ae4aac6bb7d73aef79df5fb403a16a0cfbe200442532cff6b98613383" dependencies = [ "cbindgen", - "num-derive 0.3.1", + "num-derive 0.2.5", "num-traits", - "rand", "remove_dir_all", "solana-sdk", "thiserror", @@ -2195,13 +2200,12 @@ dependencies = [ [[package]] name = "spl-token" -version = "1.0.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07c8482ae4aac6bb7d73aef79df5fb403a16a0cfbe200442532cff6b98613383" +version = "1.0.7" dependencies = [ "cbindgen", - "num-derive 0.2.5", + "num-derive 0.3.1", "num-traits", + "rand", "remove_dir_all", "solana-sdk", "thiserror", @@ -2212,12 +2216,14 @@ name = "spl-token-cli" version = "1.0.0" dependencies = [ "clap", + "serde_json", + "solana-account-decoder", "solana-clap-utils", "solana-cli-config", "solana-client", "solana-logger", "solana-sdk", - "spl-token 1.0.6", + "spl-token 1.0.7", ] [[package]] @@ -2230,7 +2236,7 @@ dependencies = [ "rand", "remove_dir_all", "solana-sdk", - "spl-token 1.0.6", + "spl-token 1.0.7", "thiserror", ] @@ -2334,7 +2340,7 @@ version = "0.1.0" dependencies = [ "solana-sdk", "spl-memo 1.0.7", - "spl-token 1.0.6", + "spl-token 1.0.7", "spl-token-swap", ]