Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@saberhq/token-utils

Package Overview
Dependencies
Maintainers
2
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saberhq/token-utils - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

dist/common.d.ts

1

dist/index.d.ts

@@ -8,3 +8,4 @@ export * from "./ata";

export { BigintIsh, Fraction, IFormatUint, makeDecimalMultiplier, MAX_U64, MAX_U256, NumberFormat, ONE, parseBigintIsh, Percent, Rounding, TEN, validateU64, validateU256, ZERO, } from "@ubeswap/token-math";
export * from "./common";
export { ASSOCIATED_TOKEN_PROGRAM_ID, AuthorityType, MintInfo as MintData, MultisigInfo, NATIVE_MINT, Token as SPLToken, TOKEN_PROGRAM_ID, AccountInfo as TokenAccountData, u64, } from "@solana/spl-token";
//# sourceMappingURL=index.d.ts.map

@@ -27,2 +27,3 @@ "use strict";

// re-export SPL token types
(0, tslib_1.__exportStar)(require("./common"), exports);
var spl_token_1 = require("@solana/spl-token");

@@ -29,0 +30,0 @@ Object.defineProperty(exports, "ASSOCIATED_TOKEN_PROGRAM_ID", { enumerable: true, get: function () { return spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID; } });

3

dist/instructions/account.js

@@ -8,2 +8,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const layout_1 = require("../layout");
const createTokenAccount = ({ provider, mint, owner = provider.wallet.publicKey, payer = provider.wallet.publicKey, accountSigner = web3_js_1.Keypair.generate(), }) => (0, tslib_1.__awaiter)(void 0, void 0, void 0, function* () {

@@ -20,3 +21,3 @@ // Allocate memory for the account

lamports: balanceNeeded,
space: spl_token_1.AccountLayout.span,
space: layout_1.TokenAccountLayout.span,
programId: spl_token_1.TOKEN_PROGRAM_ID,

@@ -23,0 +24,0 @@ }),

export * from "./account";
export * from "./ata";
export * from "./mint";
export * from "./nft";
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,3 @@ "use strict";

(0, tslib_1.__exportStar)(require("./mint"), exports);
(0, tslib_1.__exportStar)(require("./nft"), exports);
//# sourceMappingURL=index.js.map

@@ -8,2 +8,3 @@ "use strict";

const web3_js_1 = require("@solana/web3.js");
const layout_1 = require("../layout");
/**

@@ -20,3 +21,3 @@ * Creates instructions for initializing a mint.

newAccountPubkey: mintKP.publicKey,
space: spl_token_1.MintLayout.span,
space: layout_1.MintLayout.span,
lamports: yield spl_token_1.Token.getMinBalanceRentForExemptMint(provider.connection),

@@ -23,0 +24,0 @@ programId: spl_token_1.TOKEN_PROGRAM_ID,

/// <reference types="node" />
import type { Layout } from "@solana/buffer-layout";
import * as BufferLayout from "@solana/buffer-layout";
import type { AccountInfo, MintInfo } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import type { Layout } from "buffer-layout";
/**
* Layout with decode/encode types.
*/
export declare type TypedLayout<T> = Omit<Layout, "decode" | "encode"> & {
decode: (data: Buffer) => T;
encode: (data: T, out: Buffer) => number;
};
/**
* Structure with decode/encode types.
*/
export declare type TypedStructure<T> = Omit<BufferLayout.Structure, "decode" | "encode"> & TypedLayout<T>;
/**
* Typed struct buffer layout
* @param fields
* @param property
* @param decodePrefixes
* @returns
*/
export declare const structLayout: <T extends unknown>(fields: Layout[], property?: string | undefined, decodePrefixes?: boolean | undefined) => TypedStructure<T>;
/**
* Layout for a public key

@@ -16,3 +35,3 @@ */

*/
export declare const TokenAccountLayout: Layout<{
export declare const TokenAccountLayout: TypedLayout<{
mint: Buffer;

@@ -33,3 +52,3 @@ owner: Buffer;

*/
export declare const MintLayout: Layout<{
export declare const MintLayout: TypedLayout<{
mintAuthorityOption: number;

@@ -49,3 +68,3 @@ mintAuthority: Buffer;

*/
export declare const deserializeAccount: (address: PublicKey, data: Buffer) => AccountInfo;
export declare const deserializeAccount: (data: Buffer) => Omit<AccountInfo, "address">;
/**

@@ -52,0 +71,0 @@ * Deserialize a {@link Buffer} into a {@link MintInfo}.

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deserializeMint = exports.deserializeAccount = exports.MintLayout = exports.TokenAccountLayout = exports.Uint64Layout = exports.PublicKeyLayout = void 0;
exports.deserializeMint = exports.deserializeAccount = exports.MintLayout = exports.TokenAccountLayout = exports.Uint64Layout = exports.PublicKeyLayout = exports.structLayout = void 0;
const tslib_1 = require("tslib");
const BufferLayout = (0, tslib_1.__importStar)(require("@solana/buffer-layout"));
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
const BufferLayout = (0, tslib_1.__importStar)(require("buffer-layout"));
/**
* Typed struct buffer layout
* @param fields
* @param property
* @param decodePrefixes
* @returns
*/
const structLayout = (fields, property, decodePrefixes) => BufferLayout.struct(fields, property, decodePrefixes);
exports.structLayout = structLayout;
/**
* Layout for a public key

@@ -36,3 +45,3 @@ */

*/
const deserializeAccount = (address, data) => {
const deserializeAccount = (data) => {
const accountInfo = exports.TokenAccountLayout.decode(data);

@@ -72,3 +81,2 @@ const mint = new web3_js_1.PublicKey(accountInfo.mint);

return {
address,
mint,

@@ -75,0 +83,0 @@ owner,

{
"name": "@saberhq/token-utils",
"version": "1.0.0",
"version": "1.1.0",
"repository": "git@github.com:saber-hq/solana-common.git",

@@ -14,2 +14,3 @@ "author": "Ian Macalinao <ian@saber.so>",

"@saberhq/solana-contrib": "^1.0.0",
"@solana/buffer-layout": "^3.0.0",
"@solana/spl-token": "^0.1.5",

@@ -19,3 +20,2 @@ "@solana/spl-token-registry": "^0.2.247",

"@ubeswap/token-math": "^4.2.0",
"buffer-layout": "^1.2.2",
"tiny-invariant": "^1.1.0",

@@ -35,3 +35,3 @@ "tslib": "^2.3.0"

},
"gitHead": "291bf728fdddf98789d5ca91fb33188984d922e1"
"gitHead": "3cc504cfee7fbb2a50ceba82447ebcb6f06a0969"
}

@@ -29,2 +29,3 @@ export * from "./ata";

// re-export SPL token types
export * from "./common";
export {

@@ -31,0 +32,0 @@ ASSOCIATED_TOKEN_PROGRAM_ID,

import type { Provider } from "@saberhq/solana-contrib";
import { TransactionEnvelope } from "@saberhq/solana-contrib";
import {
AccountLayout,
Token as SPLToken,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import { Token as SPLToken, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import type { PublicKey, Signer } from "@solana/web3.js";
import { Keypair, SystemProgram } from "@solana/web3.js";
import { TokenAccountLayout } from "../layout";
export const createTokenAccount = async ({

@@ -45,3 +43,3 @@ provider,

lamports: balanceNeeded,
space: AccountLayout.span,
space: TokenAccountLayout.span,
programId: TOKEN_PROGRAM_ID,

@@ -48,0 +46,0 @@ }),

export * from "./account";
export * from "./ata";
export * from "./mint";
export * from "./nft";
import type { Provider } from "@saberhq/solana-contrib";
import { TransactionEnvelope } from "@saberhq/solana-contrib";
import type { u64 } from "@solana/spl-token";
import {
MintLayout,
Token as SPLToken,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import { Token as SPLToken, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import type { Keypair, PublicKey, Signer } from "@solana/web3.js";
import { SystemProgram } from "@solana/web3.js";
import { MintLayout } from "../layout";
/**

@@ -13,0 +11,0 @@ * Creates instructions for initializing a mint.

@@ -0,1 +1,3 @@

import type { Layout } from "@solana/buffer-layout";
import * as BufferLayout from "@solana/buffer-layout";
import type { AccountInfo, MintInfo } from "@solana/spl-token";

@@ -8,6 +10,35 @@ import {

import { PublicKey } from "@solana/web3.js";
import type { Layout } from "buffer-layout";
import * as BufferLayout from "buffer-layout";
/**
* Layout with decode/encode types.
*/
export type TypedLayout<T> = Omit<Layout, "decode" | "encode"> & {
decode: (data: Buffer) => T;
encode: (data: T, out: Buffer) => number;
};
/**
* Structure with decode/encode types.
*/
export type TypedStructure<T> = Omit<
BufferLayout.Structure,
"decode" | "encode"
> &
TypedLayout<T>;
/**
* Typed struct buffer layout
* @param fields
* @param property
* @param decodePrefixes
* @returns
*/
export const structLayout = <T extends unknown>(
fields: Layout[],
property?: string | undefined,
decodePrefixes?: boolean | undefined
): TypedStructure<T> =>
BufferLayout.struct(fields, property, decodePrefixes) as TypedStructure<T>;
/**
* Layout for a public key

@@ -29,3 +60,3 @@ */

*/
export const TokenAccountLayout = AccountLayout as Layout<{
export const TokenAccountLayout = AccountLayout as TypedLayout<{
mint: Buffer;

@@ -47,3 +78,3 @@ owner: Buffer;

*/
export const MintLayout = TokenMintLayout as Layout<{
export const MintLayout = TokenMintLayout as TypedLayout<{
mintAuthorityOption: number;

@@ -65,5 +96,4 @@ mintAuthority: Buffer;

export const deserializeAccount = (
address: PublicKey,
data: Buffer
): AccountInfo => {
): Omit<AccountInfo, "address"> => {
const accountInfo = TokenAccountLayout.decode(data);

@@ -108,3 +138,2 @@

return {
address,
mint,

@@ -111,0 +140,0 @@ owner,

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc