@staratlas/data-source
Advanced tools
Comparing version 0.3.8 to 0.3.9
/// <reference types="node" /> | ||
import { AccountInfo, KeyedAccountInfo, PublicKey, TransactionConfirmationStatus } from '@solana/web3.js'; | ||
import { Idl, Program } from '@project-serum/anchor'; | ||
import { Coder, Idl, Program, Provider } from '@project-serum/anchor'; | ||
import { Account, AccountStatic } from './account'; | ||
@@ -44,3 +44,4 @@ export declare type ProgramMethods<IDL extends Idl> = Omit<Program<IDL>, 'provider' | 'addEventListener' | 'removeEventListener' | 'rpc' | 'account'>; | ||
new (program: ProgramMethods<IDL>): Self & ListenProgram<Accounts, IDL>; | ||
buildProgram(programId: PublicKey, provider?: Provider, coder?: Coder): ProgramMethods<IDL>; | ||
} | ||
//# sourceMappingURL=listenProgam.d.ts.map |
@@ -10,3 +10,3 @@ "use strict"; | ||
this.parsers = parsers; | ||
this.accountDiscriminants = (0, util_1.remapObject)(parsers, (_value, key) => anchor_1.BorshAccountsCoder.accountDiscriminator(key)); | ||
this.accountDiscriminants = (0, util_1.remapObject)(parsers, (value) => anchor_1.BorshAccountsCoder.accountDiscriminator(value.ACCOUNT_NAME)); | ||
this.listeners = (0, util_1.remapObject)(parsers, () => null); | ||
@@ -13,0 +13,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import { ClientSubscriptionId, Connection, GetProgramAccountsFilter, PublicKey, TransactionConfirmationStatus } from '@solana/web3.js'; | ||
import { ClientSubscriptionId, Connection, GetProgramAccountsFilter, PublicKey, TransactionConfirmationStatus, TransactionSignature } from '@solana/web3.js'; | ||
import { DataSource } from './dataSource'; | ||
@@ -12,2 +12,3 @@ import { ProgramMethods } from './listenProgam'; | ||
export declare function accountRPCSubscribe<A extends Account, IDL extends Idl>(connection: Connection, program: ProgramMethods<IDL>, key: PublicKey, accountClass: AccountStatic<A, IDL>, callback: (data: DecodedAccountData<A>) => void, commitment?: TransactionConfirmationStatus): ClientSubscriptionId; | ||
export declare function airdrop(connection: Connection, wallet: PublicKey, lamports: number, commitment?: TransactionConfirmationStatus): Promise<TransactionSignature>; | ||
//# sourceMappingURL=rpc.d.ts.map |
@@ -15,3 +15,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.accountRPCSubscribe = exports.readFromRPCNullable = exports.readFromRPCOrError = exports.readFromRPC = exports.readAllFromRPC = exports.buildRPCDataSource = void 0; | ||
exports.airdrop = exports.accountRPCSubscribe = exports.readFromRPCNullable = exports.readFromRPCOrError = exports.readFromRPC = exports.readAllFromRPC = exports.buildRPCDataSource = void 0; | ||
const util_1 = require("./util"); | ||
@@ -170,2 +170,10 @@ const anchor_1 = require("@project-serum/anchor"); | ||
exports.accountRPCSubscribe = accountRPCSubscribe; | ||
function airdrop(connection, wallet, lamports, commitment) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const sig = yield connection.requestAirdrop(wallet, lamports); | ||
yield connection.confirmTransaction(sig, commitment); | ||
return sig; | ||
}); | ||
} | ||
exports.airdrop = airdrop; | ||
//# sourceMappingURL=rpc.js.map |
import { AsyncSigner, InstructionReturn } from '.'; | ||
import { Commitment, Connection, PublicKey } from '@solana/web3.js'; | ||
export declare function createMint(mint: AsyncSigner, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null, connection: Connection, commitment?: Commitment): InstructionReturn; | ||
export declare function createTokenAccount(account: AsyncSigner, owner: PublicKey, mint: PublicKey, connection: Connection, commitment?: Commitment): InstructionReturn; | ||
import { PublicKey } from '@solana/web3.js'; | ||
export declare function createMint(mint: AsyncSigner, decimals: number, mintAuthority: PublicKey, freezeAuthority: PublicKey | null): InstructionReturn; | ||
export declare function createTokenAccount(account: AsyncSigner, owner: PublicKey, mint: PublicKey): InstructionReturn; | ||
export declare function mintToTokenAccount(mintAuthority: AsyncSigner, mint: PublicKey, tokenAccount: PublicKey, amount: number): InstructionReturn; | ||
export declare function setMintAuthority(mint: PublicKey, currentAuthority: AsyncSigner, newAuthority: PublicKey | null): InstructionReturn; | ||
export declare function setFreezeAuthority(mint: PublicKey, currentFreezeAuthority: AsyncSigner, newFreezeAuthority: PublicKey | null): InstructionReturn; | ||
export declare function setAccountAuthority(tokenAccount: PublicKey, currentAuthority: AsyncSigner, newAuthority: PublicKey | null): InstructionReturn; | ||
export declare function transferToTokenAccount(owner: AsyncSigner, source: PublicKey, destination: PublicKey, amount: number): InstructionReturn; | ||
@@ -7,0 +10,0 @@ /** |
@@ -12,6 +12,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createAssociatedTokenAccount = exports.transferToTokenAccount = exports.mintToTokenAccount = exports.createTokenAccount = exports.createMint = void 0; | ||
exports.createAssociatedTokenAccount = exports.transferToTokenAccount = exports.setAccountAuthority = exports.setFreezeAuthority = exports.setMintAuthority = exports.mintToTokenAccount = exports.createTokenAccount = exports.createMint = void 0; | ||
const _1 = require("."); | ||
const spl_token_1 = require("@solana/spl-token"); | ||
const web3_js_1 = require("@solana/web3.js"); | ||
function createMint(mint, decimals, mintAuthority, freezeAuthority, connection, commitment) { | ||
function createMint(mint, decimals, mintAuthority, freezeAuthority) { | ||
// eslint-disable-next-line require-await | ||
return (funder) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -22,3 +24,3 @@ return [ | ||
fromPubkey: funder.publicKey(), | ||
lamports: yield connection.getMinimumBalanceForRentExemption(spl_token_1.MINT_SIZE, commitment), | ||
lamports: (0, _1.calculateMinimumRent)(spl_token_1.MINT_SIZE), | ||
newAccountPubkey: mint.publicKey(), | ||
@@ -38,4 +40,4 @@ programId: spl_token_1.TOKEN_PROGRAM_ID, | ||
exports.createMint = createMint; | ||
// TODO: Get rid of connection here | ||
function createTokenAccount(account, owner, mint, connection, commitment) { | ||
function createTokenAccount(account, owner, mint) { | ||
// eslint-disable-next-line require-await | ||
return (funder) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -46,3 +48,3 @@ return [ | ||
fromPubkey: funder.publicKey(), | ||
lamports: yield connection.getMinimumBalanceForRentExemption(spl_token_1.ACCOUNT_SIZE, commitment), | ||
lamports: (0, _1.calculateMinimumRent)(spl_token_1.ACCOUNT_SIZE), | ||
newAccountPubkey: account.publicKey(), | ||
@@ -72,2 +74,32 @@ programId: spl_token_1.TOKEN_PROGRAM_ID, | ||
exports.mintToTokenAccount = mintToTokenAccount; | ||
function setMintAuthority(mint, currentAuthority, newAuthority) { | ||
// eslint-disable-next-line require-await | ||
return () => __awaiter(this, void 0, void 0, function* () { | ||
return ({ | ||
instruction: (0, spl_token_1.createSetAuthorityInstruction)(mint, currentAuthority.publicKey(), spl_token_1.AuthorityType.MintTokens, newAuthority), | ||
signers: [currentAuthority], | ||
}); | ||
}); | ||
} | ||
exports.setMintAuthority = setMintAuthority; | ||
function setFreezeAuthority(mint, currentFreezeAuthority, newFreezeAuthority) { | ||
// eslint-disable-next-line require-await | ||
return () => __awaiter(this, void 0, void 0, function* () { | ||
return ({ | ||
instruction: (0, spl_token_1.createSetAuthorityInstruction)(mint, currentFreezeAuthority.publicKey(), spl_token_1.AuthorityType.FreezeAccount, newFreezeAuthority), | ||
signers: [currentFreezeAuthority], | ||
}); | ||
}); | ||
} | ||
exports.setFreezeAuthority = setFreezeAuthority; | ||
function setAccountAuthority(tokenAccount, currentAuthority, newAuthority) { | ||
// eslint-disable-next-line require-await | ||
return () => __awaiter(this, void 0, void 0, function* () { | ||
return ({ | ||
instruction: (0, spl_token_1.createSetAuthorityInstruction)(tokenAccount, currentAuthority.publicKey(), spl_token_1.AuthorityType.AccountOwner, newAuthority), | ||
signers: [currentAuthority], | ||
}); | ||
}); | ||
} | ||
exports.setAccountAuthority = setAccountAuthority; | ||
function transferToTokenAccount(owner, source, destination, amount) { | ||
@@ -74,0 +106,0 @@ // eslint-disable-next-line require-await |
@@ -20,2 +20,3 @@ import { BlockhashWithExpiryBlockHeight, Commitment, Connection, Finality, SendOptions, SerializeConfig, SignatureResult, Transaction, TransactionInstruction, TransactionSignature } from '@solana/web3.js'; | ||
}): Promise<TransactionReturn>; | ||
export declare function formatExplorerLink(signature: TransactionSignature | string, connection: Connection): string; | ||
export declare function sendAndConfirmTransaction(tx: TransactionReturn, connection: Connection, sendOptions?: SendOptions, serializeConfig?: SerializeConfig): Promise<{ | ||
@@ -22,0 +23,0 @@ signature: TransactionSignature; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.prettyTransaction = exports.buildSendAndCheck = exports.sendAndConfirmTransaction = exports.buildAndSignTransaction = void 0; | ||
exports.prettyTransaction = exports.buildSendAndCheck = exports.sendAndConfirmTransaction = exports.formatExplorerLink = exports.buildAndSignTransaction = void 0; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
@@ -81,2 +81,7 @@ const util_1 = require("./util"); | ||
exports.buildAndSignTransaction = buildAndSignTransaction; | ||
function formatExplorerLink(signature, connection) { | ||
const clusterUrl = encodeURIComponent(connection.rpcEndpoint); | ||
return `https://explorer.solana.com/tx/${signature}?cluster=custom&customUrl=${clusterUrl}`; | ||
} | ||
exports.formatExplorerLink = formatExplorerLink; | ||
function sendAndConfirmTransaction(tx, connection, sendOptions, serializeConfig) { | ||
@@ -104,3 +109,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
} | ||
const { signature, signatureResult } = yield sendAndConfirmTransaction(tx, connection, Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.sendOptions), { skipPreflight: true }), options === null || options === void 0 ? void 0 : options.serializeConfig); | ||
const { signature, signatureResult } = yield sendAndConfirmTransaction(tx, connection, Object.assign({}, options === null || options === void 0 ? void 0 : options.sendOptions), options === null || options === void 0 ? void 0 : options.serializeConfig); | ||
if (signatureResult.err !== null) { | ||
@@ -114,2 +119,3 @@ if (!(options === null || options === void 0 ? void 0 : options.suppressLogging)) { | ||
console.error('Transaction logs: ', (_b = transaction === null || transaction === void 0 ? void 0 : transaction.meta) === null || _b === void 0 ? void 0 : _b.logMessages); | ||
console.error(`Explorer link: ${formatExplorerLink(signature, connection)}`); | ||
} | ||
@@ -116,0 +122,0 @@ throw new Error('Transaction error: ' + JSON.stringify(signatureResult.err, null, 2)); |
@@ -49,3 +49,7 @@ export declare type ExtractArrayType<T> = T extends Array<infer U> ? U : never; | ||
export declare const snakeCaseToTitleCase: (text: string) => string; | ||
export declare const ACCOUNT_STORAGE_OVERHEAD = 128; | ||
export declare const LAMPORTS_PER_BYTE_YEAR: number; | ||
export declare const EXEMPTION_THRESHOLD = 2; | ||
export declare function calculateMinimumRent(dataSize: number): number; | ||
export {}; | ||
//# sourceMappingURL=util.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.snakeCaseToTitleCase = exports.normalizeArray = exports.getElementOrError = exports.isNull = exports.staticImplements = exports.assertNever = exports.byteArrayToString = exports.stringToByteArray = exports.arrayDeepEquals = exports.fixedSizeArrayFromArray = exports.fixedSizeArrayInit = exports.fixedSizeArray = exports.remapObject = void 0; | ||
exports.calculateMinimumRent = exports.EXEMPTION_THRESHOLD = exports.LAMPORTS_PER_BYTE_YEAR = exports.ACCOUNT_STORAGE_OVERHEAD = exports.snakeCaseToTitleCase = exports.normalizeArray = exports.getElementOrError = exports.isNull = exports.staticImplements = exports.assertNever = exports.byteArrayToString = exports.stringToByteArray = exports.arrayDeepEquals = exports.fixedSizeArrayFromArray = exports.fixedSizeArrayInit = exports.fixedSizeArray = exports.remapObject = void 0; | ||
const lodash_1 = require("lodash"); | ||
@@ -103,2 +103,11 @@ function remapObject(object, mapper) { | ||
exports.snakeCaseToTitleCase = snakeCaseToTitleCase; | ||
exports.ACCOUNT_STORAGE_OVERHEAD = 128; | ||
exports.LAMPORTS_PER_BYTE_YEAR = ((1000000000 / 100) * 365) / (1024 * 1024); | ||
exports.EXEMPTION_THRESHOLD = 2; | ||
function calculateMinimumRent(dataSize) { | ||
return ((exports.ACCOUNT_STORAGE_OVERHEAD + dataSize) * | ||
exports.LAMPORTS_PER_BYTE_YEAR * | ||
exports.EXEMPTION_THRESHOLD); | ||
} | ||
exports.calculateMinimumRent = calculateMinimumRent; | ||
//# sourceMappingURL=util.js.map |
{ | ||
"name": "@staratlas/data-source", | ||
"version": "0.3.8", | ||
"version": "0.3.9", | ||
"description": "> TODO: description", | ||
@@ -33,3 +33,3 @@ "author": "Brett Etter <brett.etter@staratlas.com>", | ||
}, | ||
"gitHead": "3b02d5c46c35213403d3446ebfd796c9b926cb88" | ||
"gitHead": "545ca2fb7cc73d688552eaba6a34f843f6f6fe92" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
129874
1491