fix create token, add param with creator pubkey
This commit is contained in:
@@ -91,3 +91,5 @@ impl MethodArgs {
|
||||
}
|
||||
}
|
||||
|
||||
pub type AnyResult<T> = anyhow::Result<T>;
|
||||
|
||||
|
||||
@@ -2,10 +2,8 @@ use std::{collections::HashMap, fmt, time::Duration};
|
||||
|
||||
use futures::{channel::mpsc, sink::Sink, Stream, StreamExt, SinkExt};
|
||||
use rustls::crypto::{ring::default_provider, CryptoProvider};
|
||||
use tonic::codec::CompressionEncoding;
|
||||
use tonic::{transport::channel::ClientTlsConfig, Status};
|
||||
use yellowstone_grpc_client::{GeyserGrpcClient, GeyserGrpcClientResult};
|
||||
use yellowstone_grpc_proto::geyser::SubscribeUpdateSlot;
|
||||
use yellowstone_grpc_proto::geyser::{
|
||||
CommitmentLevel, SubscribeRequest, SubscribeRequestFilterTransactions, SubscribeUpdate,
|
||||
SubscribeUpdateTransaction, subscribe_update::UpdateOneof, SubscribeRequestPing,
|
||||
@@ -139,43 +137,6 @@ impl YellowstoneGrpc {
|
||||
transactions
|
||||
}
|
||||
|
||||
// pub fn get_subscribe_account_updater_request_filter(
|
||||
// &self,
|
||||
// account_include: Vec<String>,
|
||||
// account_exclude: Vec<String>,
|
||||
// account_required: Vec<String>,
|
||||
// ) -> TransactionsFilterMap {
|
||||
// let mut transactions = HashMap::new();
|
||||
// transactions.insert(
|
||||
// "client".to_string(),
|
||||
// SubscribeUpdateAccount {
|
||||
// account: account_include,
|
||||
// slot: None,
|
||||
// is_startup: None,
|
||||
// },
|
||||
// );
|
||||
// transactions
|
||||
// }
|
||||
|
||||
// pub fn get_subscribe_update_slot_request_filter(
|
||||
// &self,
|
||||
// account_include: Vec<String>,
|
||||
// account_exclude: Vec<String>,
|
||||
// account_required: Vec<String>,
|
||||
// ) -> TransactionsFilterMap {
|
||||
// let mut transactions = HashMap::new();
|
||||
// transactions.insert(
|
||||
// "client".to_string(),
|
||||
// SubscribeUpdateSlot {
|
||||
// slot: 0,
|
||||
// parent: None,
|
||||
// status: None,
|
||||
// dead_error: None,
|
||||
// },
|
||||
// );
|
||||
// transactions
|
||||
// }
|
||||
|
||||
async fn handle_stream_message(
|
||||
msg: SubscribeUpdate,
|
||||
tx: &mut mpsc::Sender<TransactionPretty>,
|
||||
@@ -204,20 +165,6 @@ impl YellowstoneGrpc {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// pub async fn subscribe_account_updater<F>(&self, callback: F, bot_wallet: Option<Pubkey>) -> ClientResult<()>
|
||||
// where
|
||||
// F: Fn(PumpfunEvent) + Send + Sync + 'static,
|
||||
// {
|
||||
// let addrs = vec![PUMP_PROGRAM_ID.to_string()];
|
||||
// let transactions = self.get_subscribe_request_filter(addrs, vec![], vec![]);
|
||||
// let (mut subscribe_tx, mut stream) = self.connect(transactions).await?
|
||||
// .map_err(|e| ClientError::Other(format!("Failed to subscribe: {:?}", e)))?;
|
||||
// let (mut tx, mut rx) = mpsc::channel::<TransactionPretty>(CHANNEL_SIZE);
|
||||
|
||||
// let callback = Box::new(callback);
|
||||
|
||||
// }
|
||||
|
||||
pub async fn subscribe_pumpfun<F>(&self, callback: F, bot_wallet: Option<Pubkey>) -> ClientResult<()>
|
||||
where
|
||||
F: Fn(PumpfunEvent) + Send + Sync + 'static,
|
||||
|
||||
@@ -38,11 +38,12 @@ pub struct Create {
|
||||
pub _name: String,
|
||||
pub _symbol: String,
|
||||
pub _uri: String,
|
||||
pub _creator: Pubkey,
|
||||
}
|
||||
|
||||
impl Create {
|
||||
pub fn data(&self) -> Vec<u8> {
|
||||
let mut data = Vec::with_capacity(8 + 4 + self._name.len() + 4 + self._symbol.len() + 4 + self._uri.len());
|
||||
let mut data = Vec::with_capacity(8 + 4 + self._name.len() + 4 + self._symbol.len() + 4 + self._uri.len() + 32);
|
||||
|
||||
// 追加 discriminator
|
||||
data.extend_from_slice(&[24, 30, 200, 40, 5, 28, 7, 119]); // discriminator
|
||||
@@ -59,6 +60,8 @@ impl Create {
|
||||
data.extend_from_slice(&(self._uri.len() as u32).to_le_bytes()); // 添加 uri 长度
|
||||
data.extend_from_slice(self._uri.as_bytes()); // 添加 uri 内容
|
||||
|
||||
data.extend_from_slice(&self._creator.to_bytes());
|
||||
|
||||
data
|
||||
}
|
||||
}
|
||||
@@ -247,6 +250,7 @@ pub async fn build_create_and_buy_instructions(
|
||||
_name: ipfs.metadata.name.clone(),
|
||||
_symbol: ipfs.metadata.symbol.clone(),
|
||||
_uri: ipfs.metadata_uri.clone(),
|
||||
_creator: payer.pubkey(),
|
||||
},
|
||||
));
|
||||
|
||||
|
||||
+3
-2
@@ -75,8 +75,9 @@ async fn create_and_buy() -> Result<(), Box<dyn std::error::Error>> {
|
||||
metadata_uri: None,
|
||||
};
|
||||
|
||||
// ipfs_api_key for https://api.pinata.cloud
|
||||
let ipfs_metadata = ipfs::create_token_metadata(metadata, &"ipfs_api_key".to_string()).await?;
|
||||
// ipfs jwt_token for https://pinata.cloud
|
||||
let jwt_token = "your ipfs jwt_token";
|
||||
let ipfs_metadata = ipfs::create_token_metadata(metadata, &jwt_token).await?;
|
||||
println!("ipfs_metadata: {:?}", ipfs_metadata);
|
||||
|
||||
let mint = Keypair::new();
|
||||
|
||||
@@ -37,6 +37,7 @@ pub async fn create(
|
||||
_name: ipfs.metadata.name,
|
||||
_symbol: ipfs.metadata.symbol,
|
||||
_uri: ipfs.metadata_uri,
|
||||
_creator: payer.pubkey(),
|
||||
},
|
||||
));
|
||||
|
||||
@@ -203,6 +204,7 @@ pub async fn build_create_and_buy_instructions(
|
||||
_name: ipfs.metadata.name.clone(),
|
||||
_symbol: ipfs.metadata.symbol.clone(),
|
||||
_uri: ipfs.metadata_uri.clone(),
|
||||
_creator: payer.pubkey(),
|
||||
},
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user