Skip to content

Commit ea107bf

Browse files
committed
fix eslint prettier config, rebase
1 parent 19ba03a commit ea107bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+485
-1146
lines changed

packages/common/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"gitHead": "a37306eba0e762af096db642fa22f07194014cfd",
2626
"devDependencies": {
2727
"@streamflow/eslint-config": "workspace:*",
28-
"@streamflow/prettier-config": "workspace:*",
2928
"@types/bn.js": "5.1.1",
3029
"@types/jest": "29.2.4",
3130
"date-fns": "2.28.0",

packages/common/solana/instructions.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
import {
2-
Connection,
3-
PublicKey,
4-
SystemProgram,
5-
TransactionInstruction,
6-
} from "@solana/web3.js";
1+
import { Connection, PublicKey, SystemProgram, TransactionInstruction } from "@solana/web3.js";
72
import BN from "bn.js";
83
import {
94
createAssociatedTokenAccountInstruction,
@@ -17,25 +12,14 @@ export const prepareWrappedAccount = async (
1712
senderAddress: PublicKey,
1813
amount: BN
1914
): Promise<TransactionInstruction[]> => {
20-
const tokenAccount = await getAssociatedTokenAddress(
21-
NATIVE_MINT,
22-
senderAddress,
23-
true
24-
);
15+
const tokenAccount = await getAssociatedTokenAddress(NATIVE_MINT, senderAddress, true);
2516

2617
const accInfo = await connection.getParsedAccountInfo(tokenAccount);
2718

2819
const instructions =
2920
(accInfo.value?.lamports ?? 0) > 0
3021
? []
31-
: [
32-
createAssociatedTokenAccountInstruction(
33-
senderAddress,
34-
tokenAccount,
35-
senderAddress,
36-
NATIVE_MINT
37-
),
38-
];
22+
: [createAssociatedTokenAccountInstruction(senderAddress, tokenAccount, senderAddress, NATIVE_MINT)];
3923

4024
return [
4125
...instructions,

packages/common/solana/types.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
2-
import {
3-
AccountInfo,
4-
PublicKey,
5-
Keypair,
6-
TransactionSignature,
7-
TransactionInstruction,
8-
} from "@solana/web3.js";
2+
import { AccountInfo, PublicKey, Keypair, TransactionSignature, TransactionInstruction } from "@solana/web3.js";
93

104
export { WalletAdapterNetwork as Cluster } from "@solana/wallet-adapter-base";
115

packages/common/solana/utils.ts

Lines changed: 15 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
import {
2-
createAssociatedTokenAccountInstruction,
3-
getAssociatedTokenAddress,
4-
} from "@solana/spl-token";
1+
import { createAssociatedTokenAccountInstruction, getAssociatedTokenAddress } from "@solana/spl-token";
52
import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
63
import {
74
BlockheightBasedTransactionConfirmationStrategy,
@@ -48,9 +45,7 @@ export async function getProgramAccounts(
4845
* @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
4946
* @return {boolean} - Returns true if parameter is a Wallet.
5047
*/
51-
export function isSignerWallet(
52-
walletOrKeypair: Keypair | SignerWalletAdapter
53-
): walletOrKeypair is SignerWalletAdapter {
48+
export function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is SignerWalletAdapter {
5449
return (<SignerWalletAdapter>walletOrKeypair).signTransaction !== undefined;
5550
}
5651

@@ -59,20 +54,15 @@ export function isSignerWallet(
5954
* @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
6055
* @returns {boolean} - Returns true if parameter is a Keypair.
6156
*/
62-
export function isSignerKeypair(
63-
walletOrKeypair: Keypair | SignerWalletAdapter
64-
): walletOrKeypair is Keypair {
57+
export function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair {
6558
return (
6659
walletOrKeypair instanceof Keypair ||
6760
walletOrKeypair.constructor === Keypair ||
6861
walletOrKeypair.constructor.name === Keypair.prototype.constructor.name
6962
);
7063
}
7164

72-
export async function signTransaction(
73-
invoker: Keypair | SignerWalletAdapter,
74-
tx: Transaction
75-
): Promise<Transaction> {
65+
export async function signTransaction(invoker: Keypair | SignerWalletAdapter, tx: Transaction): Promise<Transaction> {
7666
let signedTx: Transaction;
7767
if (isSignerWallet(invoker)) {
7868
signedTx = await invoker.signTransaction(tx);
@@ -103,17 +93,12 @@ export async function signAndExecuteTransaction(
10393
if (!hash.lastValidBlockHeight || !signedTx.signature || !hash.blockhash)
10494
throw Error("Error with transaction parameters.");
10595

106-
const confirmationStrategy: BlockheightBasedTransactionConfirmationStrategy =
107-
{
108-
lastValidBlockHeight: hash.lastValidBlockHeight,
109-
signature: bs58.encode(signedTx.signature),
110-
blockhash: hash.blockhash,
111-
};
112-
const signature = await sendAndConfirmRawTransaction(
113-
connection,
114-
rawTx,
115-
confirmationStrategy
116-
);
96+
const confirmationStrategy: BlockheightBasedTransactionConfirmationStrategy = {
97+
lastValidBlockHeight: hash.lastValidBlockHeight,
98+
signature: bs58.encode(signedTx.signature),
99+
blockhash: hash.blockhash,
100+
};
101+
const signature = await sendAndConfirmRawTransaction(connection, rawTx, confirmationStrategy);
117102
return signature;
118103
}
119104

@@ -133,10 +118,7 @@ export function ata(mint: PublicKey, owner: PublicKey): Promise<PublicKey> {
133118
* @param paramsBatch - Array of Params for an each ATA account: {mint, owner}
134119
* @returns Array of boolean where each members corresponds to owners member
135120
*/
136-
export async function ataBatchExist(
137-
connection: Connection,
138-
paramsBatch: AtaParams[]
139-
): Promise<boolean[]> {
121+
export async function ataBatchExist(connection: Connection, paramsBatch: AtaParams[]): Promise<boolean[]> {
140122
const tokenAccounts = await Promise.all(
141123
paramsBatch.map(async ({ mint, owner }) => {
142124
const pubkey = await ata(mint, owner);
@@ -164,12 +146,7 @@ export async function generateCreateAtaBatchTx(
164146
}> {
165147
const ixs: TransactionInstruction[] = await Promise.all(
166148
paramsBatch.map(async ({ mint, owner }) => {
167-
return createAssociatedTokenAccountInstruction(
168-
payer,
169-
await ata(mint, owner),
170-
owner,
171-
mint
172-
);
149+
return createAssociatedTokenAccountInstruction(payer, await ata(mint, owner), owner, mint);
173150
})
174151
);
175152
const hash = await connection.getLatestBlockhash();
@@ -193,17 +170,8 @@ export async function createAtaBatch(
193170
invoker: Keypair | SignerWalletAdapter,
194171
paramsBatch: AtaParams[]
195172
): Promise<string> {
196-
const { tx, hash } = await generateCreateAtaBatchTx(
197-
connection,
198-
invoker.publicKey!,
199-
paramsBatch
200-
);
201-
const signature = await signAndExecuteTransaction(
202-
connection,
203-
invoker,
204-
tx,
205-
hash
206-
);
173+
const { tx, hash } = await generateCreateAtaBatchTx(connection, invoker.publicKey!, paramsBatch);
174+
const signature = await signAndExecuteTransaction(connection, invoker, tx, hash);
207175
return signature;
208176
}
209177

@@ -230,14 +198,7 @@ export async function checkOrCreateAtaBatch(
230198
const response = await connection.getMultipleAccountsInfo(atas);
231199
for (let i = 0; i < response.length; i++) {
232200
if (!response[i]) {
233-
ixs.push(
234-
createAssociatedTokenAccountInstruction(
235-
invoker.publicKey!,
236-
atas[i],
237-
owners[i],
238-
mint
239-
)
240-
);
201+
ixs.push(createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i], owners[i], mint));
241202
}
242203
}
243204
return ixs;

packages/common/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ export const getBN = (value: number, decimals: number): BN => {
2626
* @param {number} decimals - Number of decimals the token has.
2727
*/
2828
export const getNumberFromBN = (value: BN, decimals: number): number =>
29-
value.gt(new BN(2 ** 53 - 1))
30-
? value.div(new BN(10 ** decimals)).toNumber()
31-
: value.toNumber() / 10 ** decimals;
29+
value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;
3230

3331
/**
3432
* Used to make on chain calls to the contract and wrap raised errors if any

packages/distributor/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"gitHead": "a37306eba0e762af096db642fa22f07194014cfd",
2626
"devDependencies": {
2727
"@streamflow/eslint-config": "workspace:*",
28-
"@streamflow/prettier-config": "workspace:*",
2928
"@types/bn.js": "5.1.1",
3029
"@types/jest": "29.2.4",
3130
"date-fns": "2.28.0",

0 commit comments

Comments
 (0)