fix: rename tokens to lamports

This commit is contained in:
Michael Vines
2019-03-05 17:52:13 -08:00
parent 09b6d2b764
commit be8821e0d0
12 changed files with 68 additions and 68 deletions

View File

@ -38,7 +38,7 @@ export type TimestampCondition = {
* Represents a payment to a given public key
*
* @typedef {Object} Payment
* @property {number} amount Number of tokens
* @property {number} amount Number of lamports
* @property {PublicKey} to Public key of the recipient
*/
export type Payment = {
@ -177,7 +177,7 @@ export class BudgetProgram {
}
/**
* Generates a transaction that transfers tokens once any of the conditions are met
* Generates a transaction that transfers lamports once any of the conditions are met
*/
static pay(
from: PublicKey,
@ -258,7 +258,7 @@ export class BudgetProgram {
}
/**
* Generates a transaction that transfers tokens once both conditions are met
* Generates a transaction that transfers lamports once both conditions are met
*/
static payOnBoth(
from: PublicKey,

View File

@ -85,7 +85,7 @@ function jsonRpcResult(resultDescription: any) {
const AccountInfoResult = struct({
executable: 'boolean',
owner: 'array',
tokens: 'number',
lamports: 'number',
userdata: 'array',
});
@ -144,7 +144,7 @@ const SendTransactionRpcResult = jsonRpcResult('string');
* Information describing an account
*
* @typedef {Object} AccountInfo
* @property {number} tokens Number of tokens assigned to the account
* @property {number} lamports Number of lamports assigned to the account
* @property {PublicKey} owner Identifier of the program that owns the account
* @property {?Buffer} userdata Optional userdata assigned to the account
* @property {boolean} executable `true` if this account's userdata contains a loaded program
@ -152,7 +152,7 @@ const SendTransactionRpcResult = jsonRpcResult('string');
type AccountInfo = {
executable: boolean,
owner: PublicKey,
tokens: number,
lamports: number,
userdata: Buffer,
};
@ -266,7 +266,7 @@ export class Connection {
return {
executable: result.executable,
owner: new PublicKey(result.owner),
tokens: result.tokens,
lamports: result.lamports,
userdata: Buffer.from(result.userdata),
};
}
@ -326,7 +326,7 @@ export class Connection {
}
/**
* Request an allocation of tokens to the specified account
* Request an allocation of lamports to the specified account
*/
async requestAirdrop(
to: PublicKey,
@ -478,7 +478,7 @@ export class Connection {
sub.callback({
executable: result.executable,
owner: new PublicKey(result.owner),
tokens: result.tokens,
lamports: result.lamports,
userdata: Buffer.from(result.userdata),
});
return true;

View File

@ -25,13 +25,13 @@ export class SystemProgram {
static createAccount(
from: PublicKey,
newAccount: PublicKey,
tokens: number,
lamports: number,
space: number,
programId: PublicKey,
): Transaction {
const userdataLayout = BufferLayout.struct([
BufferLayout.u32('instruction'),
BufferLayout.ns64('tokens'),
BufferLayout.ns64('lamports'),
BufferLayout.ns64('space'),
Layout.publicKey('programId'),
]);
@ -40,7 +40,7 @@ export class SystemProgram {
userdataLayout.encode(
{
instruction: 0, // Create Account instruction
tokens,
lamports,
space,
programId: programId.toBuffer(),
},
@ -55,7 +55,7 @@ export class SystemProgram {
}
/**
* Generate a Transaction that moves tokens from one account to another
* Generate a Transaction that moves lamports from one account to another
*/
static move(from: PublicKey, to: PublicKey, amount: number): Transaction {
const userdataLayout = BufferLayout.struct([

View File

@ -16,7 +16,7 @@ import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction';
import type {Connection} from './connection';
/**
* Some amount of tokens
* Some amount of lamports
*/
export class TokenAmount extends BN {
/**
@ -55,7 +55,7 @@ export class TokenAmount extends BN {
*/
type TokenInfo = {|
/**
* Total supply of tokens
* Total supply of lamports
*/
supply: TokenAmount,
@ -100,21 +100,21 @@ type TokenAccountInfo = {|
owner: PublicKey,
/**
* Amount of tokens this account holds
* Amount of lamports this account holds
*/
amount: TokenAmount,
/**
* The source account for the tokens.
* The source account for the lamports.
*
* If `source` is null, the source is this account.
* If `source` is not null, the `amount` of tokens in this account represent
* an allowance of tokens that may be transferred from the source account
* If `source` is not null, the `amount` of lamports in this account represent
* an allowance of lamports that may be transferred from the source account
*/
source: null | PublicKey,
/**
* Original amount of tokens this delegate account was authorized to spend
* Original amount of lamports this delegate account was authorized to spend
* If `source` is null, originalAmount is zero
*/
originalAmount: TokenAmount,
@ -185,7 +185,7 @@ export class Token {
* @param symbol Symbol for this token
* @param decimals Location of the decimal place
* @param programId Optional token programId, uses the system programId by default
* @return Token object for the newly minted token, Public key of the Token Account holding the total supply of new tokens
* @return Token object for the newly minted token, Public key of the Token Account holding the total supply of new lamports
*/
static async createNewToken(
connection: Connection,
@ -253,7 +253,7 @@ export class Token {
*
* @param owner User account that will own the new token account
* @param source If not null, create a delegate account that when authorized
* may transfer tokens from this `source` account
* may transfer lamports from this `source` account
* @return Public key of the new empty token account
*/
async newAccount(
@ -363,12 +363,12 @@ export class Token {
}
/**
* Transfer tokens to another account
* Transfer lamports to another account
*
* @param owner Owner of the source token account
* @param source Source token account
* @param destination Destination token account
* @param amount Number of tokens to transfer
* @param amount Number of lamports to transfer
*/
async transfer(
owner: Account,
@ -391,12 +391,12 @@ export class Token {
}
/**
* Grant a third-party permission to transfer up the specified number of tokens from an account
* Grant a third-party permission to transfer up the specified number of lamports from an account
*
* @param owner Owner of the source token account
* @param account Public key of the token account
* @param delegate Token account authorized to perform a transfer tokens from the source account
* @param amount Maximum number of tokens the delegate may transfer
* @param delegate Token account authorized to perform a transfer lamports from the source account
* @param amount Maximum number of lamports the delegate may transfer
*/
async approve(
owner: Account,
@ -414,7 +414,7 @@ export class Token {
}
/**
* Remove approval for the transfer of any remaining tokens
* Remove approval for the transfer of any remaining lamports
*
* @param owner Owner of the source token account
* @param account Public key of the token account
@ -455,7 +455,7 @@ export class Token {
* @param owner Owner of the source token account
* @param source Source token account
* @param destination Destination token account
* @param amount Number of tokens to transfer
* @param amount Number of lamports to transfer
*/
async transferInstruction(
owner: PublicKey,
@ -498,8 +498,8 @@ export class Token {
*
* @param owner Owner of the source token account
* @param account Public key of the token account
* @param delegate Token account authorized to perform a transfer tokens from the source account
* @param amount Maximum number of tokens the delegate may transfer
* @param delegate Token account authorized to perform a transfer lamports from the source account
* @param amount Maximum number of lamports the delegate may transfer
*/
approveInstruction(
owner: PublicKey,
@ -533,7 +533,7 @@ export class Token {
*
* @param owner Owner of the source token account
* @param account Public key of the token account
* @param delegate Token account authorized to perform a transfer tokens from the source account
* @param delegate Token account authorized to perform a transfer lamports from the source account
*/
revokeInstruction(
owner: PublicKey,