solone-sdk
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "solone-sdk", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "javascript sdk for solona", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,3 +8,3 @@ import { | ||
TransactionResponse, | ||
} from '@solana/web3.js'; | ||
} from "@solana/web3.js"; | ||
@@ -20,3 +20,3 @@ const { | ||
sendAndConfirmTransaction, | ||
} = require('@solana/web3.js'); | ||
} = require("@solana/web3.js"); | ||
@@ -26,8 +26,12 @@ class Solone { | ||
public connection: ConnectionType; | ||
public network: string = 'testnet'; | ||
public network: string = "testnet"; | ||
constructor(network: string) { | ||
this.connection = new Connection(clusterApiUrl(network), 'confirmed'); | ||
this.connection = new Connection(clusterApiUrl(network), "confirmed"); | ||
this.network = network; | ||
} | ||
updateConnection = async (network: string) => { | ||
this.connection = new Connection(clusterApiUrl(network), "confirmed"); | ||
}; | ||
getBalance = async (address: string): Promise<Object> => { | ||
@@ -56,5 +60,38 @@ const publicKey = new PublicKey(address); | ||
getTransactions = async (address: string): Promise<Object> => { | ||
const publicKey = new PublicKey(address); | ||
const transSignatures = | ||
await this.connection.getConfirmedSignaturesForAddress2(publicKey, { | ||
limit: 10, | ||
}); | ||
const transactions = new Array(); | ||
for (let i = 0; i < transSignatures.length; i++) { | ||
const signature = transSignatures[i].signature; | ||
const confirmedTransaction = | ||
await this.connection.getConfirmedTransaction(signature); | ||
console.log(confirmedTransaction?.meta); | ||
if (confirmedTransaction) { | ||
const { meta } = confirmedTransaction; | ||
if (meta) { | ||
const oldBalance = meta.preBalances; | ||
const newBalance = meta.postBalances; | ||
const amount = oldBalance[0] - newBalance[0]; | ||
const transWithSignature = { | ||
signature, | ||
...confirmedTransaction, | ||
fees: meta?.fee, | ||
amount, | ||
}; | ||
transactions.push(transWithSignature); | ||
} | ||
} | ||
} | ||
return transactions; | ||
}; | ||
fundAccount = async ( | ||
address: string, | ||
valueInLamports: string, | ||
valueInLamports: string | ||
): Promise<Object> => { | ||
@@ -64,3 +101,3 @@ const publicKey = new PublicKey(address); | ||
publicKey, | ||
valueInLamports ? valueInLamports : LAMPORTS_PER_SOL, | ||
valueInLamports ? valueInLamports : LAMPORTS_PER_SOL | ||
); | ||
@@ -74,3 +111,3 @@ return hash; | ||
amount: string, | ||
secretKey: Uint8Array, | ||
secretKey: Uint8Array | ||
): Promise<Object> => { | ||
@@ -94,3 +131,3 @@ const instructions: SystemProgramType = SystemProgram.transfer({ | ||
const transaction: TransactionResponse = new Transaction().add( | ||
instructions, | ||
instructions | ||
); | ||
@@ -103,3 +140,3 @@ | ||
transaction, | ||
signers, | ||
signers | ||
); | ||
@@ -113,4 +150,4 @@ | ||
const solone = new Solone('testnet'); | ||
const solone = new Solone("testnet"); | ||
module.exports = { solone }; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10735
5
197