Socket
Socket
Sign inDemoInstall

@solana/spl-token

Package Overview
Dependencies
Maintainers
7
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/spl-token - npm Package Compare versions

Comparing version 0.0.13 to 0.1.0

lib/index.browser.esm.js

121

lib/index.cjs.js

@@ -6,2 +6,3 @@ 'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var buffer = require('buffer');
var assert = require('assert');

@@ -18,2 +19,3 @@ var BN = require('bn.js');

//
/**

@@ -34,2 +36,3 @@ * Layout for a public key

//
function sendAndConfirmTransaction(title, connection, transaction, ...signers) {

@@ -45,5 +48,15 @@ return web3_js.sendAndConfirmTransaction(connection, transaction, signers, {

/**
* Unfortunately, BufferLayout.encode uses an `instanceof` check for `Buffer`
* which fails when using `publicKey.toBuffer()` directly because the bundled `Buffer`
* class in `@solana/web3.js` is different from the bundled `Buffer` class in this package
*/
function pubkeyToBuffer(publicKey) {
return buffer.Buffer.from(publicKey.toBuffer());
}
/**
* 64-bit value
*/
class u64 extends BN__default['default'] {

@@ -55,3 +68,3 @@ /**

const a = super.toArray().reverse();
const b = Buffer.from(a);
const b = buffer.Buffer.from(a);

@@ -63,3 +76,3 @@ if (b.length === 8) {

assert__default['default'](b.length < 8, 'u64 too large');
const zeroPad = Buffer.alloc(8);
const zeroPad = buffer.Buffer.alloc(8);
b.copy(zeroPad);

@@ -74,4 +87,4 @@ return zeroPad;

static fromBuffer(buffer) {
assert__default['default'](buffer.length === 8, `Invalid buffer length: ${buffer.length}`);
return new BN__default['default']([...buffer].reverse().map(i => `00${i.toString(16)}`.slice(-2)).join(''), 16);
assert__default['default'](buffer.length === 8, "Invalid buffer length: ".concat(buffer.length));
return new u64([...buffer].reverse().map(i => "00".concat(i.toString(16)).slice(-2)).join(''), 16);
}

@@ -105,2 +118,3 @@

*/
const AccountLayout = BufferLayout.struct([publicKey('mint'), publicKey('owner'), uint64('amount'), BufferLayout.u32('delegateOption'), publicKey('delegate'), BufferLayout.u8('state'), BufferLayout.u32('isNativeOption'), uint64('isNative'), uint64('delegatedAmount'), BufferLayout.u32('closeAuthorityOption'), publicKey('closeAuthority')]);

@@ -114,2 +128,3 @@ /**

*/
const MultisigLayout = BufferLayout.struct([BufferLayout.u8('m'), BufferLayout.u8('n'), BufferLayout.u8('is_initialized'), publicKey('signer1'), publicKey('signer2'), publicKey('signer3'), publicKey('signer4'), publicKey('signer5'), publicKey('signer6'), publicKey('signer7'), publicKey('signer8'), publicKey('signer9'), publicKey('signer10'), publicKey('signer11')]);

@@ -333,3 +348,3 @@ /**

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u8('m')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -362,10 +377,10 @@ instruction: 2,

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid mint owner: ${JSON.stringify(info.owner)}`);
throw new Error("Invalid mint owner: ".concat(JSON.stringify(info.owner)));
}
if (info.data.length != MintLayout.span) {
throw new Error(`Invalid mint size`);
throw new Error("Invalid mint size");
}
const data = Buffer.from(info.data);
const data = buffer.Buffer.from(info.data);
const mintInfo = MintLayout.decode(data);

@@ -405,10 +420,10 @@

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid account owner`);
throw new Error("Invalid account owner");
}
if (info.data.length != AccountLayout.span) {
throw new Error(`Invalid account size`);
throw new Error("Invalid account size");
}
const data = Buffer.from(info.data);
const data = buffer.Buffer.from(info.data);
const accountInfo = AccountLayout.decode(data);

@@ -445,3 +460,3 @@ accountInfo.mint = new web3_js.PublicKey(accountInfo.mint);

if (!accountInfo.mint.equals(this.publicKey)) {
throw new Error(`Invalid account mint: ${JSON.stringify(accountInfo.mint)} !== ${JSON.stringify(this.publicKey)}`);
throw new Error("Invalid account mint: ".concat(JSON.stringify(accountInfo.mint), " !== ").concat(JSON.stringify(this.publicKey)));
}

@@ -466,10 +481,10 @@

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid multisig owner`);
throw new Error("Invalid multisig owner");
}
if (info.data.length != MultisigLayout.span) {
throw new Error(`Invalid multisig size`);
throw new Error("Invalid multisig size");
}
const data = Buffer.from(info.data);
const data = buffer.Buffer.from(info.data);
const multisigInfo = MultisigLayout.decode(data);

@@ -717,3 +732,3 @@ multisigInfo.signer1 = new web3_js.PublicKey(multisigInfo.signer1);

async transfer2(source, destination, owner, multiSigners, amount, decimals) {
async transferChecked(source, destination, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -730,3 +745,3 @@ let signers;

return await sendAndConfirmTransaction('Transfer2', this.connection, new web3_js.Transaction().add(Token.createTransfer2Instruction(this.programId, source, this.publicKey, destination, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
return await sendAndConfirmTransaction('TransferChecked', this.connection, new web3_js.Transaction().add(Token.createTransferCheckedInstruction(this.programId, source, this.publicKey, destination, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -746,3 +761,3 @@ /**

async approve2(account, delegate, owner, multiSigners, amount, decimals) {
async approveChecked(account, delegate, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -759,3 +774,3 @@ let signers;

await sendAndConfirmTransaction('Approve2', this.connection, new web3_js.Transaction().add(Token.createApprove2Instruction(this.programId, account, this.publicKey, delegate, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('ApproveChecked', this.connection, new web3_js.Transaction().add(Token.createApproveCheckedInstruction(this.programId, account, this.publicKey, delegate, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -773,3 +788,3 @@ /**

async mintTo2(dest, authority, multiSigners, amount, decimals) {
async mintToChecked(dest, authority, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -786,3 +801,3 @@ let signers;

await sendAndConfirmTransaction('MintTo2', this.connection, new web3_js.Transaction().add(Token.createMintTo2Instruction(this.programId, this.publicKey, dest, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('MintToChecked', this.connection, new web3_js.Transaction().add(Token.createMintToCheckedInstruction(this.programId, this.publicKey, dest, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -800,3 +815,3 @@ /**

async burn2(account, owner, multiSigners, amount, decimals) {
async burnChecked(account, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -813,3 +828,3 @@ let signers;

await sendAndConfirmTransaction('Burn2', this.connection, new web3_js.Transaction().add(Token.createBurn2Instruction(this.programId, this.publicKey, account, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('BurnChecked', this.connection, new web3_js.Transaction().add(Token.createBurnCheckedInstruction(this.programId, this.publicKey, account, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -838,3 +853,3 @@ /**

const commandDataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u8('decimals'), publicKey('mintAuthority'), BufferLayout.u8('option'), publicKey('freezeAuthority')]);
let data = Buffer.alloc(1024);
let data = buffer.Buffer.alloc(1024);
{

@@ -845,5 +860,5 @@ const encodeLength = commandDataLayout.encode({

decimals,
mintAuthority: mintAuthority.toBuffer(),
mintAuthority: pubkeyToBuffer(mintAuthority),
option: freezeAuthority === null ? 0 : 1,
freezeAuthority: (freezeAuthority || new web3_js.PublicKey()).toBuffer()
freezeAuthority: pubkeyToBuffer(freezeAuthority || new web3_js.PublicKey())
}, data);

@@ -887,3 +902,3 @@ data = data.slice(0, encodeLength);

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -913,3 +928,3 @@ instruction: 1 // InitializeAccount instruction

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -969,3 +984,3 @@ instruction: 3,

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1023,3 +1038,3 @@ instruction: 4,

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1074,3 +1089,3 @@ instruction: 5 // Approve instruction

const commandDataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), BufferLayout.u8('authorityType'), BufferLayout.u8('option'), publicKey('newAuthority')]);
let data = Buffer.alloc(1024);
let data = buffer.Buffer.alloc(1024);
{

@@ -1082,3 +1097,3 @@ const encodeLength = commandDataLayout.encode({

option: newAuthority === null ? 0 : 1,
newAuthority: (newAuthority || new web3_js.PublicKey()).toBuffer()
newAuthority: pubkeyToBuffer(newAuthority || new web3_js.PublicKey())
}, data);

@@ -1132,3 +1147,3 @@ data = data.slice(0, encodeLength);

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1188,3 +1203,3 @@ instruction: 7,

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1243,3 +1258,3 @@ instruction: 8,

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1297,3 +1312,3 @@ instruction: 9 // CloseAccount instruction

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1351,3 +1366,3 @@ instruction: 10 // FreezeAccount instruction

const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({

@@ -1393,3 +1408,3 @@ instruction: 11 // ThawAccount instruction

/**
* Construct a Transfer2 instruction
* Construct a TransferChecked instruction
*

@@ -1407,8 +1422,8 @@ * @param programId SPL Token program account

static createTransfer2Instruction(programId, source, mint, destination, owner, multiSigners, amount, decimals) {
static createTransferCheckedInstruction(programId, source, mint, destination, owner, multiSigners, amount, decimals) {
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount'), BufferLayout.u8('decimals')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({
instruction: 12,
// Transfer2 instruction
// TransferChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1457,3 +1472,3 @@ decimals

/**
* Construct an Approve2 instruction
* Construct an ApproveChecked instruction
*

@@ -1471,8 +1486,8 @@ * @param programId SPL Token program account

static createApprove2Instruction(programId, account, mint, delegate, owner, multiSigners, amount, decimals) {
static createApproveCheckedInstruction(programId, account, mint, delegate, owner, multiSigners, amount, decimals) {
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount'), BufferLayout.u8('decimals')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({
instruction: 13,
// Approve2 instruction
// ApproveChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1521,3 +1536,3 @@ decimals

/**
* Construct a MintTo2 instruction
* Construct a MintToChecked instruction
*

@@ -1534,8 +1549,8 @@ * @param programId SPL Token program account

static createMintTo2Instruction(programId, mint, dest, authority, multiSigners, amount, decimals) {
static createMintToCheckedInstruction(programId, mint, dest, authority, multiSigners, amount, decimals) {
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount'), BufferLayout.u8('decimals')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({
instruction: 14,
// MintTo2 instruction
// MintToChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1580,3 +1595,3 @@ decimals

/**
* Construct a Burn2 instruction
* Construct a BurnChecked instruction
*

@@ -1592,8 +1607,8 @@ * @param programId SPL Token program account

static createBurn2Instruction(programId, mint, account, owner, multiSigners, amount, decimals) {
static createBurnCheckedInstruction(programId, mint, account, owner, multiSigners, amount, decimals) {
const dataLayout = BufferLayout.struct([BufferLayout.u8('instruction'), uint64('amount'), BufferLayout.u8('decimals')]);
const data = Buffer.alloc(dataLayout.span);
const data = buffer.Buffer.alloc(dataLayout.span);
dataLayout.encode({
instruction: 15,
// Burn2 instruction
// BurnChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1600,0 +1615,0 @@ decimals

@@ -75,2 +75,11 @@ declare module '@solana/spl-token' {

);
static getMinBalanceRentForExemptMint(
connection: Connection,
): Promise<number>;
static getMinBalanceRentForExemptAccount(
connection: Connection,
): Promise<number>;
static getMinBalanceRentForExemptMultisig(
connection: Connection,
): Promise<number>;
static createMint(

@@ -84,3 +93,2 @@ connection: Connection,

): Promise<Token>;
static getAccount(connection: Connection): Promise<Account>;
createAccount(owner: PublicKey): Promise<PublicKey>;

@@ -191,2 +199,3 @@ static createWrappedNativeAccount(

newAuthority: PublicKey | null,
authorityType: AuthorityType,
authority: PublicKey,

@@ -218,3 +227,17 @@ multiSigners: Array<Account>,

): TransactionInstruction;
static createFreezeAccountInstruction(
programId: PublicKey,
account: PublicKey,
mint: PublicKey,
authority: PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createThawAccountInstruction(
programId: PublicKey,
account: PublicKey,
mint: PublicKey,
authority: PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
}
}
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { Buffer } from 'buffer';
import assert from 'assert';

@@ -7,2 +8,3 @@ import BN from 'bn.js';

//
/**

@@ -23,2 +25,3 @@ * Layout for a public key

//
function sendAndConfirmTransaction(title, connection, transaction, ...signers) {

@@ -34,5 +37,15 @@ return sendAndConfirmTransaction$1(connection, transaction, signers, {

/**
* Unfortunately, BufferLayout.encode uses an `instanceof` check for `Buffer`
* which fails when using `publicKey.toBuffer()` directly because the bundled `Buffer`
* class in `@solana/web3.js` is different from the bundled `Buffer` class in this package
*/
function pubkeyToBuffer(publicKey) {
return Buffer.from(publicKey.toBuffer());
}
/**
* 64-bit value
*/
class u64 extends BN {

@@ -61,4 +74,4 @@ /**

static fromBuffer(buffer) {
assert(buffer.length === 8, `Invalid buffer length: ${buffer.length}`);
return new BN([...buffer].reverse().map(i => `00${i.toString(16)}`.slice(-2)).join(''), 16);
assert(buffer.length === 8, "Invalid buffer length: ".concat(buffer.length));
return new u64([...buffer].reverse().map(i => "00".concat(i.toString(16)).slice(-2)).join(''), 16);
}

@@ -92,2 +105,3 @@

*/
const AccountLayout = struct([publicKey('mint'), publicKey('owner'), uint64('amount'), u32('delegateOption'), publicKey('delegate'), u8('state'), u32('isNativeOption'), uint64('isNative'), uint64('delegatedAmount'), u32('closeAuthorityOption'), publicKey('closeAuthority')]);

@@ -101,2 +115,3 @@ /**

*/
const MultisigLayout = struct([u8('m'), u8('n'), u8('is_initialized'), publicKey('signer1'), publicKey('signer2'), publicKey('signer3'), publicKey('signer4'), publicKey('signer5'), publicKey('signer6'), publicKey('signer7'), publicKey('signer8'), publicKey('signer9'), publicKey('signer10'), publicKey('signer11')]);

@@ -348,7 +363,7 @@ /**

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid mint owner: ${JSON.stringify(info.owner)}`);
throw new Error("Invalid mint owner: ".concat(JSON.stringify(info.owner)));
}
if (info.data.length != MintLayout.span) {
throw new Error(`Invalid mint size`);
throw new Error("Invalid mint size");
}

@@ -391,7 +406,7 @@

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid account owner`);
throw new Error("Invalid account owner");
}
if (info.data.length != AccountLayout.span) {
throw new Error(`Invalid account size`);
throw new Error("Invalid account size");
}

@@ -431,3 +446,3 @@

if (!accountInfo.mint.equals(this.publicKey)) {
throw new Error(`Invalid account mint: ${JSON.stringify(accountInfo.mint)} !== ${JSON.stringify(this.publicKey)}`);
throw new Error("Invalid account mint: ".concat(JSON.stringify(accountInfo.mint), " !== ").concat(JSON.stringify(this.publicKey)));
}

@@ -452,7 +467,7 @@

if (!info.owner.equals(this.programId)) {
throw new Error(`Invalid multisig owner`);
throw new Error("Invalid multisig owner");
}
if (info.data.length != MultisigLayout.span) {
throw new Error(`Invalid multisig size`);
throw new Error("Invalid multisig size");
}

@@ -703,3 +718,3 @@

async transfer2(source, destination, owner, multiSigners, amount, decimals) {
async transferChecked(source, destination, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -716,3 +731,3 @@ let signers;

return await sendAndConfirmTransaction('Transfer2', this.connection, new Transaction().add(Token.createTransfer2Instruction(this.programId, source, this.publicKey, destination, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
return await sendAndConfirmTransaction('TransferChecked', this.connection, new Transaction().add(Token.createTransferCheckedInstruction(this.programId, source, this.publicKey, destination, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -732,3 +747,3 @@ /**

async approve2(account, delegate, owner, multiSigners, amount, decimals) {
async approveChecked(account, delegate, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -745,3 +760,3 @@ let signers;

await sendAndConfirmTransaction('Approve2', this.connection, new Transaction().add(Token.createApprove2Instruction(this.programId, account, this.publicKey, delegate, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('ApproveChecked', this.connection, new Transaction().add(Token.createApproveCheckedInstruction(this.programId, account, this.publicKey, delegate, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -759,3 +774,3 @@ /**

async mintTo2(dest, authority, multiSigners, amount, decimals) {
async mintToChecked(dest, authority, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -772,3 +787,3 @@ let signers;

await sendAndConfirmTransaction('MintTo2', this.connection, new Transaction().add(Token.createMintTo2Instruction(this.programId, this.publicKey, dest, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('MintToChecked', this.connection, new Transaction().add(Token.createMintToCheckedInstruction(this.programId, this.publicKey, dest, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -786,3 +801,3 @@ /**

async burn2(account, owner, multiSigners, amount, decimals) {
async burnChecked(account, owner, multiSigners, amount, decimals) {
let ownerPublicKey;

@@ -799,3 +814,3 @@ let signers;

await sendAndConfirmTransaction('Burn2', this.connection, new Transaction().add(Token.createBurn2Instruction(this.programId, this.publicKey, account, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
await sendAndConfirmTransaction('BurnChecked', this.connection, new Transaction().add(Token.createBurnCheckedInstruction(this.programId, this.publicKey, account, ownerPublicKey, multiSigners, amount, decimals)), this.payer, ...signers);
}

@@ -830,5 +845,5 @@ /**

decimals,
mintAuthority: mintAuthority.toBuffer(),
mintAuthority: pubkeyToBuffer(mintAuthority),
option: freezeAuthority === null ? 0 : 1,
freezeAuthority: (freezeAuthority || new PublicKey()).toBuffer()
freezeAuthority: pubkeyToBuffer(freezeAuthority || new PublicKey())
}, data);

@@ -1062,3 +1077,3 @@ data = data.slice(0, encodeLength);

option: newAuthority === null ? 0 : 1,
newAuthority: (newAuthority || new PublicKey()).toBuffer()
newAuthority: pubkeyToBuffer(newAuthority || new PublicKey())
}, data);

@@ -1368,3 +1383,3 @@ data = data.slice(0, encodeLength);

/**
* Construct a Transfer2 instruction
* Construct a TransferChecked instruction
*

@@ -1382,3 +1397,3 @@ * @param programId SPL Token program account

static createTransfer2Instruction(programId, source, mint, destination, owner, multiSigners, amount, decimals) {
static createTransferCheckedInstruction(programId, source, mint, destination, owner, multiSigners, amount, decimals) {
const dataLayout = struct([u8('instruction'), uint64('amount'), u8('decimals')]);

@@ -1388,3 +1403,3 @@ const data = Buffer.alloc(dataLayout.span);

instruction: 12,
// Transfer2 instruction
// TransferChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1433,3 +1448,3 @@ decimals

/**
* Construct an Approve2 instruction
* Construct an ApproveChecked instruction
*

@@ -1447,3 +1462,3 @@ * @param programId SPL Token program account

static createApprove2Instruction(programId, account, mint, delegate, owner, multiSigners, amount, decimals) {
static createApproveCheckedInstruction(programId, account, mint, delegate, owner, multiSigners, amount, decimals) {
const dataLayout = struct([u8('instruction'), uint64('amount'), u8('decimals')]);

@@ -1453,3 +1468,3 @@ const data = Buffer.alloc(dataLayout.span);

instruction: 13,
// Approve2 instruction
// ApproveChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1498,3 +1513,3 @@ decimals

/**
* Construct a MintTo2 instruction
* Construct a MintToChecked instruction
*

@@ -1511,3 +1526,3 @@ * @param programId SPL Token program account

static createMintTo2Instruction(programId, mint, dest, authority, multiSigners, amount, decimals) {
static createMintToCheckedInstruction(programId, mint, dest, authority, multiSigners, amount, decimals) {
const dataLayout = struct([u8('instruction'), uint64('amount'), u8('decimals')]);

@@ -1517,3 +1532,3 @@ const data = Buffer.alloc(dataLayout.span);

instruction: 14,
// MintTo2 instruction
// MintToChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1558,3 +1573,3 @@ decimals

/**
* Construct a Burn2 instruction
* Construct a BurnChecked instruction
*

@@ -1570,3 +1585,3 @@ * @param programId SPL Token program account

static createBurn2Instruction(programId, mint, account, owner, multiSigners, amount, decimals) {
static createBurnCheckedInstruction(programId, mint, account, owner, multiSigners, amount, decimals) {
const dataLayout = struct([u8('instruction'), uint64('amount'), u8('decimals')]);

@@ -1576,3 +1591,3 @@ const data = Buffer.alloc(dataLayout.span);

instruction: 15,
// Burn2 instruction
// BurnChecked instruction
amount: new u64(amount).toBuffer(),

@@ -1579,0 +1594,0 @@ decimals

@@ -5,10 +5,20 @@ /**

* This file is manually maintained
*
*/
import BN from 'bn.js'; // eslint-disable-line
import {Buffer} from 'buffer';
import {Layout} from 'buffer-layout';
import {
Account,
Connection,
PublicKey,
TransactionInstruction,
} from '@solana/web3.js';
import type {TransactionSignature} from '@solana/web3.js';
declare module '@solana/spl-token' {
declare export var TOKEN_PROGRAM_ID;
declare export class u64 extends BN {
toBuffer(): Buffer;
static fromBuffer(buffer: Buffer): u64;
toBuffer(): typeof Buffer;
static fromBuffer(buffer: typeof Buffer): u64;
}

@@ -21,3 +31,3 @@ declare export type AuthorityType =

declare export var NATIVE_MINT: PublicKey;
declare export var MintLayout: Layout;
declare export var MintLayout: typeof Layout;
declare export type MintInfo = {|

@@ -30,3 +40,3 @@ mintAuthority: null | PublicKey,

|};
declare export var AccountLayout: Layout;
declare export var AccountLayout: typeof Layout;
declare export type AccountInfo = {|

@@ -70,2 +80,11 @@ mint: PublicKey,

): Token;
static getMinBalanceRentForExemptMint(
connection: Connection,
): Promise<number>;
static getMinBalanceRentForExemptAccount(
connection: Connection,
): Promise<number>;
static getMinBalanceRentForExemptMultisig(
connection: Connection,
): Promise<number>;
static createMint(

@@ -79,3 +98,2 @@ connection: Connection,

): Promise<Token>;
static getAccount(connection: Connection): Promise<Account>;
createAccount(owner: PublicKey): Promise<PublicKey>;

@@ -186,2 +204,3 @@ static createWrappedNativeAccount(

newAuthority: PublicKey | null,
authorityType: AuthorityType,
authority: PublicKey,

@@ -213,3 +232,17 @@ multiSigners: Array<Account>,

): TransactionInstruction;
static createFreezeAccountInstruction(
programId: PublicKey,
account: PublicKey,
mint: PublicKey,
authority: PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createThawAccountInstruction(
programId: PublicKey,
account: PublicKey,
mint: PublicKey,
authority: PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
}
}
{
"name": "@solana/spl-token",
"version": "0.0.13",
"version": "0.1.0",
"description": "SPL Token JavaScript API",

@@ -18,5 +18,14 @@ "license": "MIT",

},
"browser": {
"./lib/index.cjs.js": "./lib/index.browser.esm.js",
"./lib/index.esm.js": "./lib/index.browser.esm.js"
},
"main": "lib/index.cjs.js",
"module": "lib/index.esm.js",
"types": "lib/index.d.ts",
"browserslist": [
"defaults",
"not IE 11",
"maintained node versions"
],
"files": [

@@ -29,3 +38,5 @@ "/lib",

"build": "rollup -c",
"build:browser-test": "rollup -c test/rollup.config.js",
"start": "babel-node cli/main.js",
"start-with-test-validator": "start-server-and-test 'solana-test-validator --reset --quiet' http://localhost:8899/health start",
"lint": "npm run pretty && eslint .",

@@ -41,16 +52,16 @@ "lint:fix": "npm run pretty:fix && eslint . --fix",

"cluster:mainnet-beta": "cp cluster-mainnet-beta.env .env",
"localnet:update": "solana-localnet update",
"localnet:up": "rm -f client/util/store/config.json; set -x; solana-localnet down; set -e; solana-localnet up",
"localnet:down": "solana-localnet down",
"localnet:logs": "solana-localnet logs -f",
"defs": "set -ex; flow check-contents < module.flow.js; tsc --esModuleInterop module.d.ts",
"pretty": "prettier --check '{,cli*/**/}*.[jt]s'",
"pretty:fix": "prettier --write '{,cli*/**/}*.[jt]s'"
"pretty:fix": "prettier --write '{,cli*/**/}*.[jt]s'",
"test": "mocha './test/**/*.test.js'",
"test:browser": "npm run build:browser-test && mocha-headless-chrome -f http://localhost:8080/mocha.html --timeout 180000",
"test:browser-with-server": "start-server-and-test 'http-server -p 8080' 8080 test:browser"
},
"dependencies": {
"@babel/runtime": "^7.10.5",
"@solana/web3.js": "^0.86.1",
"bn.js": "^5.0.0",
"@solana/web3.js": "^0.92.1",
"bn.js": "^5.1.0",
"buffer": "6.0.3",
"buffer-layout": "^1.2.0",
"dotenv": "8.2.0",
"mkdirp": "1.0.4"
"dotenv": "8.2.0"
},

@@ -65,9 +76,26 @@ "devDependencies": {

"@babel/preset-flow": "^7.10.4",
"@babel/register": "^7.13.0",
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-babel": "^5.1.0",
"@rollup/plugin-commonjs": "^16.0.0",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-multi-entry": "^4.0.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@types/bn.js": "^5.1.0",
"@typescript-eslint/eslint-plugin": "^4.14.2",
"@typescript-eslint/parser": "^4.14.2",
"babel-eslint": "^10.1.0",
"chai": "^4.3.0",
"eslint": "^7.4.0",
"eslint-plugin-flowtype": "^5.3.1",
"eslint-plugin-import": "^2.22.0",
"flow-bin": "0.136.0",
"flow-typed": "^3.2.0",
"eslint-plugin-mocha": "^8.0.0",
"esm": "^3.2.25",
"flow-bin": "^0.145.0",
"flow-remove-types": "^2.145.0",
"flow-typed": "^3.3.1",
"http-server": "^0.12.3",
"mkdirp": "^1.0.4",
"mocha": "^8.3.0",
"mocha-headless-chrome": "^3.1.0",
"mz": "^2.7.0",

@@ -77,2 +105,6 @@ "prettier": "^2.0.5",

"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-node-polyfills": "^0.2.1",
"rollup-plugin-terser": "^7.0.2",
"start-server-and-test": "^1.11.6",
"typescript": "^4.1.3",
"watch": "^1.0.2"

@@ -79,0 +111,0 @@ },

@@ -28,4 +28,3 @@ # Token JavaScript API

```bash
$ npm run localnet:update
$ npm run localnet:up
$ solana-test-validator
```

@@ -35,8 +34,5 @@

```bash
$ npm run localnet:logs
$ solana --url http://127.0.0.1:8899/ logs
```
For more details on working with a local cluster, see the [full
instructions](https://github.com/solana-labs/solana-web3.js#local-network).
### Build the on-chain program

@@ -43,0 +39,0 @@

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