@saberhq/token-utils
Advanced tools
Comparing version 1.10.17 to 1.11.0
@@ -5,14 +5,4 @@ /// <reference types="node" /> | ||
import type { AccountInfo, MintInfo } from "@solana/spl-token"; | ||
export { Layout as TypedLayout, Structure as TypedStructure, } from "@solana/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 | ||
@@ -24,15 +14,15 @@ * @param fields | ||
*/ | ||
export declare const structLayout: <T>(fields: Layout[], property?: string | undefined, decodePrefixes?: boolean | undefined) => TypedStructure<T>; | ||
export declare const structLayout: <T>(fields: Layout<T[keyof T]>[], property?: string | undefined, decodePrefixes?: boolean | undefined) => BufferLayout.Structure<T>; | ||
/** | ||
* Layout for a public key | ||
*/ | ||
export declare const PublicKeyLayout: (property?: string) => Layout; | ||
export declare const PublicKeyLayout: (property?: string) => BufferLayout.Blob; | ||
/** | ||
* Layout for a 64bit unsigned value | ||
*/ | ||
export declare const Uint64Layout: (property?: string) => Layout; | ||
export declare const Uint64Layout: (property?: string) => BufferLayout.Blob; | ||
/** | ||
* Layout for a TokenAccount. | ||
*/ | ||
export declare const TokenAccountLayout: TypedLayout<{ | ||
export declare const TokenAccountLayout: Layout<{ | ||
mint: Buffer; | ||
@@ -53,3 +43,3 @@ owner: Buffer; | ||
*/ | ||
export declare const MintLayout: TypedLayout<{ | ||
export declare const MintLayout: Layout<{ | ||
mintAuthorityOption: number; | ||
@@ -56,0 +46,0 @@ mintAuthority: Buffer; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.deserializeMint = exports.deserializeAccount = exports.MintLayout = exports.TokenAccountLayout = exports.Uint64Layout = exports.PublicKeyLayout = exports.structLayout = void 0; | ||
exports.deserializeMint = exports.deserializeAccount = exports.MintLayout = exports.TokenAccountLayout = exports.Uint64Layout = exports.PublicKeyLayout = exports.structLayout = exports.TypedStructure = exports.TypedLayout = void 0; | ||
const tslib_1 = require("tslib"); | ||
@@ -8,2 +8,5 @@ const solana_contrib_1 = require("@saberhq/solana-contrib"); | ||
const spl_token_1 = require("@solana/spl-token"); | ||
var buffer_layout_1 = require("@solana/buffer-layout"); | ||
Object.defineProperty(exports, "TypedLayout", { enumerable: true, get: function () { return buffer_layout_1.Layout; } }); | ||
Object.defineProperty(exports, "TypedStructure", { enumerable: true, get: function () { return buffer_layout_1.Structure; } }); | ||
/** | ||
@@ -10,0 +13,0 @@ * Typed struct buffer layout |
@@ -5,14 +5,4 @@ /// <reference types="node" /> | ||
import type { AccountInfo, MintInfo } from "@solana/spl-token"; | ||
export { Layout as TypedLayout, Structure as TypedStructure, } from "@solana/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 | ||
@@ -24,15 +14,15 @@ * @param fields | ||
*/ | ||
export declare const structLayout: <T>(fields: Layout[], property?: string | undefined, decodePrefixes?: boolean | undefined) => TypedStructure<T>; | ||
export declare const structLayout: <T>(fields: Layout<T[keyof T]>[], property?: string | undefined, decodePrefixes?: boolean | undefined) => BufferLayout.Structure<T>; | ||
/** | ||
* Layout for a public key | ||
*/ | ||
export declare const PublicKeyLayout: (property?: string) => Layout; | ||
export declare const PublicKeyLayout: (property?: string) => BufferLayout.Blob; | ||
/** | ||
* Layout for a 64bit unsigned value | ||
*/ | ||
export declare const Uint64Layout: (property?: string) => Layout; | ||
export declare const Uint64Layout: (property?: string) => BufferLayout.Blob; | ||
/** | ||
* Layout for a TokenAccount. | ||
*/ | ||
export declare const TokenAccountLayout: TypedLayout<{ | ||
export declare const TokenAccountLayout: Layout<{ | ||
mint: Buffer; | ||
@@ -53,3 +43,3 @@ owner: Buffer; | ||
*/ | ||
export declare const MintLayout: TypedLayout<{ | ||
export declare const MintLayout: Layout<{ | ||
mintAuthorityOption: number; | ||
@@ -56,0 +46,0 @@ mintAuthority: Buffer; |
import { PublicKey } from "@saberhq/solana-contrib"; | ||
import * as BufferLayout from "@solana/buffer-layout"; | ||
import { AccountLayout, MintLayout as TokenMintLayout, u64, } from "@solana/spl-token"; | ||
export { Layout as TypedLayout, Structure as TypedStructure, } from "@solana/buffer-layout"; | ||
/** | ||
@@ -5,0 +6,0 @@ * Typed struct buffer layout |
{ | ||
"name": "@saberhq/token-utils", | ||
"description": "Token-related math and transaction utilities for Solana.", | ||
"version": "1.10.17", | ||
"version": "1.11.0", | ||
"repository": "git@github.com:saber-hq/solana-common.git", | ||
@@ -18,4 +18,4 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
"dependencies": { | ||
"@saberhq/solana-contrib": "^1.10.17", | ||
"@solana/buffer-layout": "^3.0.0", | ||
"@saberhq/solana-contrib": "^1.11.0", | ||
"@solana/buffer-layout": "^4.0.0", | ||
"@solana/spl-token": "^0.1.8", | ||
@@ -33,3 +33,3 @@ "@ubeswap/token-math": "^4.4.1", | ||
"devDependencies": { | ||
"@saberhq/tsconfig": "^1.10.17", | ||
"@saberhq/tsconfig": "^1.11.0", | ||
"@solana/web3.js": "^1.31.0", | ||
@@ -47,3 +47,3 @@ "@types/bn.js": "^5.1.0", | ||
}, | ||
"gitHead": "9fddfc4202fb58cc60eac9963a2c8475bd4f60ca" | ||
"gitHead": "d8f8ead7a857ecfcc0b6ba00f67ac3e289843247" | ||
} |
@@ -11,20 +11,8 @@ import { PublicKey } from "@saberhq/solana-contrib"; | ||
/** | ||
* Layout with decode/encode types. | ||
*/ | ||
export type TypedLayout<T> = Omit<Layout, "decode" | "encode"> & { | ||
decode: (data: Buffer) => T; | ||
encode: (data: T, out: Buffer) => number; | ||
}; | ||
export { | ||
Layout as TypedLayout, | ||
Structure as TypedStructure, | ||
} from "@solana/buffer-layout"; | ||
/** | ||
* Structure with decode/encode types. | ||
*/ | ||
export type TypedStructure<T> = Omit< | ||
BufferLayout.Structure, | ||
"decode" | "encode" | ||
> & | ||
TypedLayout<T>; | ||
/** | ||
* Typed struct buffer layout | ||
@@ -37,7 +25,7 @@ * @param fields | ||
export const structLayout = <T>( | ||
fields: Layout[], | ||
fields: Layout<T[keyof T]>[], | ||
property?: string | undefined, | ||
decodePrefixes?: boolean | undefined | ||
): TypedStructure<T> => | ||
BufferLayout.struct(fields, property, decodePrefixes) as TypedStructure<T>; | ||
): BufferLayout.Structure<T> => | ||
BufferLayout.struct<T>(fields, property, decodePrefixes); | ||
@@ -47,3 +35,3 @@ /** | ||
*/ | ||
export const PublicKeyLayout = (property = "publicKey"): Layout => { | ||
export const PublicKeyLayout = (property = "publicKey"): BufferLayout.Blob => { | ||
return BufferLayout.blob(32, property); | ||
@@ -55,3 +43,3 @@ }; | ||
*/ | ||
export const Uint64Layout = (property = "uint64"): Layout => { | ||
export const Uint64Layout = (property = "uint64"): BufferLayout.Blob => { | ||
return BufferLayout.blob(8, property); | ||
@@ -63,3 +51,3 @@ }; | ||
*/ | ||
export const TokenAccountLayout = AccountLayout as TypedLayout<{ | ||
export const TokenAccountLayout = AccountLayout as Layout<{ | ||
mint: Buffer; | ||
@@ -81,3 +69,3 @@ owner: Buffer; | ||
*/ | ||
export const MintLayout = TokenMintLayout as TypedLayout<{ | ||
export const MintLayout = TokenMintLayout as Layout<{ | ||
mintAuthorityOption: number; | ||
@@ -84,0 +72,0 @@ mintAuthority: Buffer; |
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
282073
4063
- Removed@solana/buffer-layout@3.0.0(transitive)
Updated@solana/buffer-layout@^4.0.0