Prep token/js for publishing (#165)

This commit is contained in:
Jack May 2020-07-30 02:07:55 -07:00 committed by GitHub
parent 87a0af07b3
commit a07935371f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 432 additions and 74 deletions

View File

@ -14,4 +14,5 @@ sudo apt-get install -y libssl-dev --allow-unauthenticated
sudo apt-get install -y libssl1.1 --allow-unauthenticated sudo apt-get install -y libssl1.1 --allow-unauthenticated
clang-7 --version clang-7 --version
nvm install node nvm install node
npm install -g typescript
node --version node --version

View File

@ -18,6 +18,7 @@ cd "$(dirname "$0")/../token/js"
npm install npm install
npm run lint npm run lint
npm run flow npm run flow
tsc module.d.ts
npm run cluster:localnet npm run cluster:localnet
npm run localnet:update npm run localnet:update
npm run localnet:up npm run localnet:up

View File

@ -4,7 +4,7 @@ import fs from 'mz/fs';
import semver from 'semver'; import semver from 'semver';
import { Account, Connection, BpfLoader, PublicKey } from '@solana/web3.js'; import { Account, Connection, BpfLoader, PublicKey } from '@solana/web3.js';
import { Token, TokenAmount } from '../../../token/js/client/token'; import { Token, u64 } from '../../../token/js/client/token';
import { TokenSwap } from '../client/token-swap'; import { TokenSwap } from '../client/token-swap';
import { Store } from '../client/util/store'; import { Store } from '../client/util/store';
import { newAccountWithLamports } from '../client/util/new-account-with-lamports'; import { newAccountWithLamports } from '../client/util/new-account-with-lamports';
@ -121,7 +121,7 @@ export async function createTokenSwap(): Promise<void> {
payer, payer,
authority, authority,
owner.publicKey, owner.publicKey,
new TokenAmount(0), new u64(0),
2, 2,
tokenProgramId, tokenProgramId,
true, true,
@ -133,7 +133,7 @@ export async function createTokenSwap(): Promise<void> {
payer, payer,
owner.publicKey, owner.publicKey,
authority, authority,
new TokenAmount(BASE_AMOUNT), new u64(BASE_AMOUNT),
2, 2,
tokenProgramId, tokenProgramId,
true, true,
@ -145,7 +145,7 @@ export async function createTokenSwap(): Promise<void> {
payer, payer,
owner.publicKey, owner.publicKey,
authority, authority,
new TokenAmount(BASE_AMOUNT), new u64(BASE_AMOUNT),
2, 2,
tokenProgramId, tokenProgramId,
true, true,

View File

@ -4,7 +4,7 @@ import fs from 'mz/fs';
import {Account, Connection, BpfLoader, PublicKey} from '@solana/web3.js'; import {Account, Connection, BpfLoader, PublicKey} from '@solana/web3.js';
import semver from 'semver'; import semver from 'semver';
import {Token, TokenAmount} from '../client/token'; import {Token, u64} from '../client/token';
import {url} from '../url'; import {url} from '../url';
import {newAccountWithLamports} from '../client/util/new-account-with-lamports'; import {newAccountWithLamports} from '../client/util/new-account-with-lamports';
import {sleep} from '../client/util/sleep'; import {sleep} from '../client/util/sleep';
@ -113,7 +113,7 @@ export async function createMint(): Promise<void> {
payer, payer,
mintOwner.publicKey, mintOwner.publicKey,
testAccountOwner.publicKey, testAccountOwner.publicKey,
new TokenAmount(10000), new u64(10000),
2, 2,
programId, programId,
false, false,
@ -255,7 +255,7 @@ export async function mintTo(): Promise<void> {
payer, payer,
mintableOwner.publicKey, mintableOwner.publicKey,
testMintableAccountOwner.publicKey, testMintableAccountOwner.publicKey,
new TokenAmount(10000), new u64(10000),
2, 2,
programId, programId,
true, true,

View File

@ -19,9 +19,9 @@ import * as Layout from './layout';
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction'; import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
/** /**
* Some amount of tokens * 64-bit value
*/ */
export class TokenAmount extends BN { export class u64 extends BN {
/** /**
* Convert to Buffer representation * Convert to Buffer representation
*/ */
@ -31,7 +31,7 @@ export class TokenAmount extends BN {
if (b.length === 8) { if (b.length === 8) {
return b; return b;
} }
assert(b.length < 8, 'TokenAmount too large'); assert(b.length < 8, 'u64 too large');
const zeroPad = Buffer.alloc(8); const zeroPad = Buffer.alloc(8);
b.copy(zeroPad); b.copy(zeroPad);
@ -39,9 +39,9 @@ export class TokenAmount extends BN {
} }
/** /**
* Construct a TokenAmount from Buffer representation * Construct a u64 from Buffer representation
*/ */
static fromBuffer(buffer: Buffer): TokenAmount { static fromBuffer(buffer: Buffer): u64 {
assert(buffer.length === 8, `Invalid buffer length: ${buffer.length}`); assert(buffer.length === 8, `Invalid buffer length: ${buffer.length}`);
return new BN( return new BN(
[...buffer] [...buffer]
@ -98,7 +98,7 @@ type AccountInfo = {|
/** /**
* Amount of tokens this account holds * Amount of tokens this account holds
*/ */
amount: TokenAmount, amount: u64,
/** /**
* The delegate for this account * The delegate for this account
@ -108,7 +108,7 @@ type AccountInfo = {|
/** /**
* The amount of tokens the delegate authorized to the delegate * The amount of tokens the delegate authorized to the delegate
*/ */
delegatedAmount: TokenAmount, delegatedAmount: u64,
/** /**
* Is this account initialized * Is this account initialized
@ -163,7 +163,6 @@ type MultisigInfo = {|
signer2: PublicKey, signer2: PublicKey,
signer3: PublicKey, signer3: PublicKey,
signer4: PublicKey, signer4: PublicKey,
signer4: PublicKey,
signer5: PublicKey, signer5: PublicKey,
signer6: PublicKey, signer6: PublicKey,
signer7: PublicKey, signer7: PublicKey,
@ -286,7 +285,7 @@ export class Token {
payer: Account, payer: Account,
mintOwner: PublicKey, mintOwner: PublicKey,
accountOwner: PublicKey, accountOwner: PublicKey,
supply: TokenAmount, supply: u64,
decimals: number, decimals: number,
programId: PublicKey, programId: PublicKey,
is_owned: boolean = false, is_owned: boolean = false,
@ -528,15 +527,15 @@ export class Token {
const accountInfo = AccountLayout.decode(data); const accountInfo = AccountLayout.decode(data);
accountInfo.mint = new PublicKey(accountInfo.mint); accountInfo.mint = new PublicKey(accountInfo.mint);
accountInfo.owner = new PublicKey(accountInfo.owner); accountInfo.owner = new PublicKey(accountInfo.owner);
accountInfo.amount = TokenAmount.fromBuffer(accountInfo.amount); accountInfo.amount = u64.fromBuffer(accountInfo.amount);
accountInfo.isInitialized = accountInfo.isInitialized != 0; accountInfo.isInitialized = accountInfo.isInitialized != 0;
accountInfo.isNative = accountInfo.isNative != 0; accountInfo.isNative = accountInfo.isNative != 0;
if (accountInfo.option === 0) { if (accountInfo.option === 0) {
accountInfo.delegate = null; accountInfo.delegate = null;
accountInfo.delegatedAmount = new TokenAmount(); accountInfo.delegatedAmount = new u64();
} else { } else {
accountInfo.delegate = new PublicKey(accountInfo.delegate); accountInfo.delegate = new PublicKey(accountInfo.delegate);
accountInfo.delegatedAmount = TokenAmount.fromBuffer( accountInfo.delegatedAmount = u64.fromBuffer(
accountInfo.delegatedAmount, accountInfo.delegatedAmount,
); );
} }
@ -599,7 +598,7 @@ export class Token {
destination: PublicKey, destination: PublicKey,
authority: Account | PublicKey, authority: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
amount: number | TokenAmount, amount: number | u64,
): Promise<?TransactionSignature> { ): Promise<?TransactionSignature> {
let ownerPublicKey; let ownerPublicKey;
let signers; let signers;
@ -614,7 +613,8 @@ export class Token {
'Transfer', 'Transfer',
this.connection, this.connection,
new Transaction().add( new Transaction().add(
this.transferInstruction( Token.createTransferInstruction(
this.programId,
source, source,
destination, destination,
ownerPublicKey, ownerPublicKey,
@ -641,7 +641,7 @@ export class Token {
delegate: PublicKey, delegate: PublicKey,
owner: Account | PublicKey, owner: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
amount: number | TokenAmount, amount: number | u64,
): Promise<void> { ): Promise<void> {
let ownerPublicKey; let ownerPublicKey;
let signers; let signers;
@ -656,7 +656,7 @@ export class Token {
'Approve', 'Approve',
this.connection, this.connection,
new Transaction().add( new Transaction().add(
this.approveInstruction(account, delegate, ownerPublicKey, multiSigners, amount), Token.createApproveInstruction(this.programId, account, delegate, ownerPublicKey, multiSigners, amount),
), ),
this.payer, this.payer,
...signers ...signers
@ -688,7 +688,7 @@ export class Token {
'Revoke', 'Revoke',
this.connection, this.connection,
new Transaction().add( new Transaction().add(
this.revokeInstruction(account, ownerPublicKey, multiSigners), Token.createRevokeInstruction(this.programId, account, ownerPublicKey, multiSigners),
), ),
this.payer, this.payer,
...signers ...signers
@ -722,7 +722,7 @@ export class Token {
'SetOwner', 'SetOwner',
this.connection, this.connection,
new Transaction().add( new Transaction().add(
this.setOwnerInstruction(owned, newOwner, ownerPublicKey, multiSigners), Token.createSetOwnerInstruction(this.programId, owned, newOwner, ownerPublicKey, multiSigners),
), ),
this.payer, this.payer,
...signers, ...signers,
@ -756,7 +756,7 @@ export class Token {
await sendAndConfirmTransaction( await sendAndConfirmTransaction(
'MintTo', 'MintTo',
this.connection, this.connection,
new Transaction().add(this.mintToInstruction(dest, ownerPublicKey, multiSigners, amount)), new Transaction().add(Token.createMintToInstruction(this.programId, this.publicKey, dest, ownerPublicKey, multiSigners, amount)),
this.payer, this.payer,
...signers, ...signers,
); );
@ -788,7 +788,7 @@ export class Token {
await sendAndConfirmTransaction( await sendAndConfirmTransaction(
'Burn', 'Burn',
this.connection, this.connection,
new Transaction().add(this.burnInstruction(account, ownerPublicKey, multiSigners, amount)), new Transaction().add(Token.createBurnInstruction(this.programId, account, ownerPublicKey, multiSigners, amount)),
this.payer, this.payer,
...signers, ...signers,
); );
@ -819,7 +819,7 @@ export class Token {
await sendAndConfirmTransaction( await sendAndConfirmTransaction(
'CloseAccount', 'CloseAccount',
this.connection, this.connection,
new Transaction().add(this.closeAccountInstruction(account, dest, ownerPublicKey, multiSigners)), new Transaction().add(Token.createCloseAccountInstruction(this.programId, account, dest, ownerPublicKey, multiSigners)),
this.payer, this.payer,
...signers, ...signers,
); );
@ -834,12 +834,13 @@ export class Token {
* @param multiSigners Signing accounts if `authority` is a multiSig * @param multiSigners Signing accounts if `authority` is a multiSig
* @param amount Number of tokens to transfer * @param amount Number of tokens to transfer
*/ */
transferInstruction( static createTransferInstruction(
programId: PublicKey,
source: PublicKey, source: PublicKey,
destination: PublicKey, destination: PublicKey,
authority: Account | PublicKey, authority: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
amount: number | TokenAmount, amount: number | u64,
): TransactionInstruction { ): TransactionInstruction {
const dataLayout = BufferLayout.struct([ const dataLayout = BufferLayout.struct([
BufferLayout.u8('instruction'), BufferLayout.u8('instruction'),
@ -850,7 +851,7 @@ export class Token {
dataLayout.encode( dataLayout.encode(
{ {
instruction: 3, // Transfer instruction instruction: 3, // Transfer instruction
amount: new TokenAmount(amount).toBuffer(), amount: new u64(amount).toBuffer(),
}, },
data, data,
); );
@ -867,7 +868,7 @@ export class Token {
} }
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -881,12 +882,13 @@ export class Token {
* @param multiSigners Signing accounts if `owner` is a multiSig * @param multiSigners Signing accounts if `owner` is a multiSig
* @param amount Maximum number of tokens the delegate may transfer * @param amount Maximum number of tokens the delegate may transfer
*/ */
approveInstruction( static createApproveInstruction(
programId: PublicKey,
account: PublicKey, account: PublicKey,
delegate: PublicKey, delegate: PublicKey,
owner: Account | PublicKey, owner: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
amount: number | TokenAmount, amount: number | u64,
): TransactionInstruction { ): TransactionInstruction {
const dataLayout = BufferLayout.struct([ const dataLayout = BufferLayout.struct([
BufferLayout.u8('instruction'), BufferLayout.u8('instruction'),
@ -897,7 +899,7 @@ export class Token {
dataLayout.encode( dataLayout.encode(
{ {
instruction: 4, // Approve instruction instruction: 4, // Approve instruction
amount: new TokenAmount(amount).toBuffer(), amount: new u64(amount).toBuffer(),
}, },
data, data,
); );
@ -915,7 +917,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -929,7 +931,8 @@ export class Token {
* @param multiSigners Signing accounts if `owner` is a multiSig * @param multiSigners Signing accounts if `owner` is a multiSig
* @param amount Maximum number of tokens the delegate may transfer * @param amount Maximum number of tokens the delegate may transfer
*/ */
revokeInstruction( static createRevokeInstruction(
programId: PublicKey,
account: PublicKey, account: PublicKey,
owner: Account | PublicKey, owner: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
@ -956,7 +959,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -969,7 +972,8 @@ export class Token {
* @param owner Owner of the account * @param owner Owner of the account
* @param multiSigners Signing accounts if `owner` is a multiSig * @param multiSigners Signing accounts if `owner` is a multiSig
*/ */
setOwnerInstruction( static createSetOwnerInstruction(
programId: PublicKey,
owned: PublicKey, owned: PublicKey,
newOwner: PublicKey, newOwner: PublicKey,
owner: Account | PublicKey, owner: Account | PublicKey,
@ -998,7 +1002,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -1012,7 +1016,9 @@ export class Token {
* @param amount amount to mint * @param amount amount to mint
*/ */
mintToInstruction( static createMintToInstruction(
programId: PublicKey,
mint: PublicKey,
dest: PublicKey, dest: PublicKey,
authority: Account | PublicKey, authority: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
@ -1027,13 +1033,13 @@ export class Token {
dataLayout.encode( dataLayout.encode(
{ {
instruction: 7, // MintTo instruction instruction: 7, // MintTo instruction
amount: new TokenAmount(amount).toBuffer(), amount: new u64(amount).toBuffer(),
}, },
data, data,
); );
let keys = [ let keys = [
{pubkey: this.publicKey, isSigner: false, isWritable: true}, {pubkey: mint, isSigner: false, isWritable: true},
{pubkey: dest, isSigner: false, isWritable: true}, {pubkey: dest, isSigner: false, isWritable: true},
]; ];
if (authority instanceof Account) { if (authority instanceof Account) {
@ -1045,7 +1051,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -1058,7 +1064,8 @@ export class Token {
* @param multiSigners Signing accounts if `authority` is a multiSig * @param multiSigners Signing accounts if `authority` is a multiSig
* @param amount ammount to burn * @param amount ammount to burn
*/ */
burnInstruction( static createBurnInstruction(
programId: PublicKey,
account: PublicKey, account: PublicKey,
authority: Account | PublicKey, authority: Account | PublicKey,
multiSigners: Array<Account>, multiSigners: Array<Account>,
@ -1073,7 +1080,7 @@ export class Token {
dataLayout.encode( dataLayout.encode(
{ {
instruction: 8, // Burn instruction instruction: 8, // Burn instruction
amount: new TokenAmount(amount).toBuffer(), amount: new u64(amount).toBuffer(),
}, },
data, data,
); );
@ -1090,7 +1097,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }
@ -1102,7 +1109,8 @@ export class Token {
* @param owner account owner * @param owner account owner
* @param multiSigners Signing accounts if `owner` is a multiSig * @param multiSigners Signing accounts if `owner` is a multiSig
*/ */
closeAccountInstruction( static createCloseAccountInstruction(
programId: PublicKey,
account: PublicKey, account: PublicKey,
dest: PublicKey, dest: PublicKey,
owner: Account | PublicKey, owner: Account | PublicKey,
@ -1130,7 +1138,7 @@ export class Token {
return new TransactionInstruction({ return new TransactionInstruction({
keys, keys,
programId: this.programId, programId: programId,
data, data,
}); });
} }

162
token/js/module.d.ts vendored Normal file
View File

@ -0,0 +1,162 @@
declare module '@solana/spl-token' {
import {Buffer} from 'buffer';
import * as BufferLayout from 'buffer-layout';
import { PublicKey, TransactionInstruction, TransactionSignature, Connection } from "@solana/web3.js";
import BN from 'bn.js';
// === src/publickey.js ===
export class u64 extends BN {
toBuffer(): Buffer;
static fromBuffer(buffer: Buffer): u64;
}
export type MintInfo = {
owner: null | PublicKey,
decimals: number,
initialized: boolean,
};
export type AccountInfo = {
mint: PublicKey,
owner: PublicKey,
amount: u64,
delegate: null | PublicKey,
delegatedAmount: u64,
isInitialized: boolean,
isNative: boolean,
};
export type MultisigInfo = {
m: number,
n: number,
initialized: boolean,
signer1: PublicKey,
signer2: PublicKey,
signer3: PublicKey,
signer4: PublicKey,
signer5: PublicKey,
signer6: PublicKey,
signer7: PublicKey,
signer8: PublicKey,
signer9: PublicKey,
signer10: PublicKey,
signer11: PublicKey,
};
export type TokenAndPublicKey = [Token, PublicKey];
export class Token {
constructor(
connection: Connection,
publicKey: PublicKey,
programId: PublicKey,
payer: Account,
);
static createMint(
connection: Connection,
payer: Account,
mintOwner: PublicKey,
accountOwner: PublicKey,
supply: u64,
decimals: number,
programId: PublicKey,
is_owned: boolean,
): Promise<TokenAndPublicKey>;
static getAccount(connection: Connection): Promise<Account>;
createAccount(owner: PublicKey): Promise<PublicKey>;
createMultisig(m: number, signers: Array<PublicKey>): Promise<PublicKey>;
getMintInfo(): Promise<MintInfo>;
getAccountInfo(account: PublicKey): Promise<AccountInfo>;
getMultisigInfo(multisig: PublicKey): Promise<MultisigInfo>;
transfer(
source: PublicKey,
destination: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): Promise<TransactionSignature>;
approve(
account: PublicKey,
delegate: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): Promise<void>;
revoke(
account: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
setOwner(
owned: PublicKey,
newOwner: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
mintTo(
dest: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): Promise<void>;
burn(
account: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): Promise<void>;
closeAccount(
account: PublicKey,
dest: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
static createTransferInstruction(
programId: PublicKey,
source: PublicKey,
destination: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): TransactionInstruction;
static createApproveInstruction(
programId: PublicKey,
account: PublicKey,
delegate: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): TransactionInstruction;
static createRevokeInstruction(
programId: PublicKey,
account: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createSetOwnerInstruction(
programId: PublicKey,
owned: PublicKey,
newOwner: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createMintToInstruction(
programId: PublicKey,
mint: PublicKey,
dest: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): TransactionInstruction;
static createBurnInstruction(
programId: PublicKey,
account: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): TransactionInstruction;
static createCloseAccountInstruction(
programId: PublicKey,
account: PublicKey,
dest: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
}
}

View File

@ -1,24 +1,47 @@
/** /**
* Flow Library definition for token * Flow Library definition for spl-token
* *
* This file is manually maintained * This file is manually maintained
* *
* Usage: add the following line under the [libs] section of your project's
* .flowconfig:
* [libs]
* token/module.flow.js
*
*/ */
declare module 'spl-token' { declare module '@solana/spl-token' {
// === client/token.js === // === client/token.js ===
declare export class TokenAmount extends BN { declare export class u64 extends BN {
/**
* Convert to Buffer representation
*/
toBuffer(): Buffer; toBuffer(): Buffer;
static fromBuffer(buffer: Buffer): TokenAmount; static fromBuffer(buffer: Buffer): u64;
} }
declare export type MintInfo = {|
owner: null | PublicKey,
decimals: number,
initialized: boolean,
|};
declare export type AccountInfo = {|
mint: PublicKey,
owner: PublicKey,
amount: u64,
delegate: null | PublicKey,
delegatedAmount: u64,
isInitialized: boolean,
isNative: boolean,
|};
declare export type MultisigInfo = {|
m: number,
n: number,
initialized: boolean,
signer1: PublicKey,
signer2: PublicKey,
signer3: PublicKey,
signer4: PublicKey,
signer5: PublicKey,
signer6: PublicKey,
signer7: PublicKey,
signer8: PublicKey,
signer9: PublicKey,
signer10: PublicKey,
signer11: PublicKey,
|};
declare export type TokenAndPublicKey = [Token, PublicKey];
declare export class Token { declare export class Token {
constructor( constructor(
connection: Connection, connection: Connection,
@ -26,18 +49,115 @@ declare module 'spl-token' {
programId: PublicKey, programId: PublicKey,
payer: Account, payer: Account,
): Token; ): Token;
static createNewToken( static createMint(
connection: Connection, connection: Connection,
payer: Account, payer: Account,
owner: Account, mintOwner: PublicKey,
supply: TokenAmount, accountOwner: PublicKey,
supply: u64,
decimals: number, decimals: number,
programId: PublicKey, programId: PublicKey,
is_owned: boolean, is_owned: boolean,
): Promise<TokenAndPublicKey>; ): Promise<TokenAndPublicKey>;
static getAccount(connection: Connection): Promise<Account>; static getAccount(connection: Connection): Promise<Account>;
newAccount(owner: Account, source: null | PublicKey): Promise<PublicKey>; createAccount(owner: PublicKey): Promise<PublicKey>;
getTokenInfo(): Promise<TokenInfo>; createMultisig(m: number, signers: Array<PublicKey>): Promise<PublicKey>;
getTokenAccountInfo(account: PublicKey): Promise<TokenAccountInfo>; getMintInfo(): Promise<MintInfo>;
getAccountInfo(account: PublicKey): Promise<AccountInfo>;
getMultisigInfo(multisig: PublicKey): Promise<MultisigInfo>;
transfer(
source: PublicKey,
destination: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): Promise<?TransactionSignature>;
approve(
account: PublicKey,
delegate: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): Promise<void>;
revoke(
account: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
setOwner(
owned: PublicKey,
newOwner: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
mintTo(
dest: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): Promise<void>;
burn(
account: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): Promise<void>;
closeAccount(
account: PublicKey,
dest: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): Promise<void>;
static createTransferInstruction(
programId: PublicKey,
source: PublicKey,
destination: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): TransactionInstruction;
static createApproveInstruction(
programId: PublicKey,
account: PublicKey,
delegate: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
amount: number | u64,
): TransactionInstruction;
static createRevokeInstruction(
programId: PublicKey,
account: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createSetOwnerInstruction(
programId: PublicKey,
owned: PublicKey,
newOwner: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstruction;
static createMintToInstruction(
programId: PublicKey,
mint: PublicKey,
dest: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): TransactionInstruction;
static createBurnInstruction(
programId: PublicKey,
account: PublicKey,
authority: Account | PublicKey,
multiSigners: Array<Account>,
amount: number,
): TransactionInstruction;
static createCloseAccountInstruction(
programId: PublicKey,
account: PublicKey,
dest: PublicKey,
owner: Account | PublicKey,
multiSigners: Array<Account>,
): TransactionInstructio;
} }
} }

View File

@ -1,5 +1,5 @@
{ {
"name": "spl-token", "name": "@solana/spl-token",
"version": "0.0.1", "version": "0.0.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
@ -2121,6 +2121,58 @@
"resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=" "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac="
}, },
"cross-env": {
"version": "7.0.2",
"resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.2.tgz",
"integrity": "sha512-KZP/bMEOJEDCkDQAyRhu3RL2ZO/SUVrxQVI0G3YEQ+OLbRA3c6zgixe8Mq8a/z7+HKlNEjo8oiLUs8iRijY2Rw==",
"dev": true,
"requires": {
"cross-spawn": "^7.0.1"
},
"dependencies": {
"cross-spawn": {
"version": "7.0.3",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
"dev": true,
"requires": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
}
},
"path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"dev": true
},
"shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"dev": true,
"requires": {
"shebang-regex": "^3.0.0"
}
},
"shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"dev": true
},
"which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"dev": true,
"requires": {
"isexe": "^2.0.0"
}
}
}
},
"cross-spawn": { "cross-spawn": {
"version": "6.0.5", "version": "6.0.5",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
@ -6656,7 +6708,7 @@
}, },
"table": { "table": {
"version": "5.4.6", "version": "5.4.6",
"resolved": "http://registry.npmjs.org/table/-/table-5.4.6.tgz", "resolved": "https://registry.npmjs.org/table/-/table-5.4.6.tgz",
"integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==", "integrity": "sha512-wmEc8m4fjnob4gt5riFRtTu/6+4rSe12TpAELNSqHMfF3IqnA+CH37USM6/YR3qRZv7e56kAEAtd6nKZaxe0Ug==",
"requires": { "requires": {
"ajv": "^6.10.2", "ajv": "^6.10.2",

View File

@ -1,13 +1,30 @@
{ {
"name": "spl-token", "name": "@solana/spl-token",
"version": "0.0.1", "version": "0.0.1",
"description": "", "description": "SPL Token Javascript API",
"license": "MIT",
"author": "Solana Maintainers <maintainers@solana.com>",
"homepage": "https://solana.com/",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/solana-labs/solana-program-library" "url": "https://github.com/solana-labs/solana-program-library"
}, },
"bugs": {
"url": "https://github.com/solana-labs/solana-program-library/issues"
},
"publishConfig": {
"access": "public"
},
"main": "client/token.js",
"types": "module.d.ts",
"files": [
"/cli",
"/client",
"/module.flow.js"
],
"testnetDefaultChannel": "v1.2.12", "testnetDefaultChannel": "v1.2.12",
"scripts": { "scripts": {
"build": "cross-env NODE_ENV=production rollup -c",
"start": "babel-node cli/main.js", "start": "babel-node cli/main.js",
"lint": "npm run pretty && eslint .", "lint": "npm run pretty && eslint .",
"lint:fix": "npm run lint -- --fix", "lint:fix": "npm run lint -- --fix",
@ -25,9 +42,6 @@
"localnet:logs": "solana-localnet logs -f", "localnet:logs": "solana-localnet logs -f",
"pretty": "prettier --write '{,src/**/}*.js'" "pretty": "prettier --write '{,src/**/}*.js'"
}, },
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": { "devDependencies": {
"prettier": "^2.0.5" "prettier": "^2.0.5"
}, },