@solana/web3.js 1.26.1 → 1.27.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.browser.esm.js +94 -1
- package/lib/index.browser.esm.js.map +1 -1
- package/lib/index.cjs.js +94 -0
- package/lib/index.cjs.js.map +1 -1
- package/lib/index.d.ts +45 -0
- package/lib/index.esm.js +94 -1
- package/lib/index.esm.js.map +1 -1
- package/lib/index.iife.js +94 -0
- package/lib/index.iife.js.map +1 -1
- package/lib/index.iife.min.js +2 -2
- package/lib/index.iife.min.js.map +1 -1
- package/module.flow.js +52 -0
- package/package.json +4 -3
- package/src/ed25519-program.ts +140 -0
- package/src/index.ts +1 -0
- package/src/publickey.ts +8 -2
- package/src/transaction.ts +2 -2
package/lib/index.browser.esm.js
CHANGED
|
@@ -66,6 +66,9 @@ const SOLANA_SCHEMA = new Map();
|
|
|
66
66
|
*/
|
|
67
67
|
|
|
68
68
|
const MAX_SEED_LENGTH = 32;
|
|
69
|
+
/**
|
|
70
|
+
* Value to be converted into public key
|
|
71
|
+
*/
|
|
69
72
|
|
|
70
73
|
function isPublicKeyData(value) {
|
|
71
74
|
return value._bn !== undefined;
|
|
@@ -6155,6 +6158,96 @@ class Keypair {
|
|
|
6155
6158
|
|
|
6156
6159
|
}
|
|
6157
6160
|
|
|
6161
|
+
const PRIVATE_KEY_BYTES$1 = 64;
|
|
6162
|
+
const PUBLIC_KEY_BYTES$1 = 32;
|
|
6163
|
+
const SIGNATURE_BYTES = 64;
|
|
6164
|
+
/**
|
|
6165
|
+
* Params for creating an ed25519 instruction using a public key
|
|
6166
|
+
*/
|
|
6167
|
+
|
|
6168
|
+
const ED25519_INSTRUCTION_LAYOUT = BufferLayout.struct([BufferLayout.u8('numSignatures'), BufferLayout.u8('padding'), BufferLayout.u16('signatureOffset'), BufferLayout.u16('signatureInstructionIndex'), BufferLayout.u16('publicKeyOffset'), BufferLayout.u16('publicKeyInstructionIndex'), BufferLayout.u16('messageDataOffset'), BufferLayout.u16('messageDataSize'), BufferLayout.u16('messageInstructionIndex')]);
|
|
6169
|
+
class Ed25519Program {
|
|
6170
|
+
/**
|
|
6171
|
+
* @internal
|
|
6172
|
+
*/
|
|
6173
|
+
constructor() {}
|
|
6174
|
+
/**
|
|
6175
|
+
* Public key that identifies the ed25519 program
|
|
6176
|
+
*/
|
|
6177
|
+
|
|
6178
|
+
|
|
6179
|
+
/**
|
|
6180
|
+
* Create an ed25519 instruction with a public key and signature. The
|
|
6181
|
+
* public key must be a buffer that is 32 bytes long, and the signature
|
|
6182
|
+
* must be a buffer of 64 bytes.
|
|
6183
|
+
*/
|
|
6184
|
+
static createInstructionWithPublicKey(params) {
|
|
6185
|
+
const {
|
|
6186
|
+
publicKey,
|
|
6187
|
+
message,
|
|
6188
|
+
signature,
|
|
6189
|
+
instructionIndex
|
|
6190
|
+
} = params;
|
|
6191
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
6192
|
+
assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
6193
|
+
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
6194
|
+
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
6195
|
+
const messageDataOffset = signatureOffset + signature.length;
|
|
6196
|
+
const numSignatures = 1;
|
|
6197
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
6198
|
+
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
6199
|
+
numSignatures,
|
|
6200
|
+
padding: 0,
|
|
6201
|
+
signatureOffset,
|
|
6202
|
+
signatureInstructionIndex: instructionIndex,
|
|
6203
|
+
publicKeyOffset,
|
|
6204
|
+
publicKeyInstructionIndex: instructionIndex,
|
|
6205
|
+
messageDataOffset,
|
|
6206
|
+
messageDataSize: message.length,
|
|
6207
|
+
messageInstructionIndex: instructionIndex
|
|
6208
|
+
}, instructionData);
|
|
6209
|
+
instructionData.fill(publicKey, publicKeyOffset);
|
|
6210
|
+
instructionData.fill(signature, signatureOffset);
|
|
6211
|
+
instructionData.fill(message, messageDataOffset);
|
|
6212
|
+
return new TransactionInstruction({
|
|
6213
|
+
keys: [],
|
|
6214
|
+
programId: Ed25519Program.programId,
|
|
6215
|
+
data: instructionData
|
|
6216
|
+
});
|
|
6217
|
+
}
|
|
6218
|
+
/**
|
|
6219
|
+
* Create an ed25519 instruction with a private key. The private key
|
|
6220
|
+
* must be a buffer that is 64 bytes long.
|
|
6221
|
+
*/
|
|
6222
|
+
|
|
6223
|
+
|
|
6224
|
+
static createInstructionWithPrivateKey(params) {
|
|
6225
|
+
const {
|
|
6226
|
+
privateKey,
|
|
6227
|
+
message,
|
|
6228
|
+
instructionIndex
|
|
6229
|
+
} = params;
|
|
6230
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
6231
|
+
|
|
6232
|
+
try {
|
|
6233
|
+
const keypair = Keypair.fromSecretKey(privateKey);
|
|
6234
|
+
const publicKey = keypair.publicKey.toBytes();
|
|
6235
|
+
const signature = nacl__default.sign.detached(message, keypair.secretKey);
|
|
6236
|
+
return this.createInstructionWithPublicKey({
|
|
6237
|
+
publicKey,
|
|
6238
|
+
message,
|
|
6239
|
+
signature,
|
|
6240
|
+
instructionIndex
|
|
6241
|
+
});
|
|
6242
|
+
} catch (error) {
|
|
6243
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
|
|
6247
|
+
}
|
|
6248
|
+
|
|
6249
|
+
_defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
6250
|
+
|
|
6158
6251
|
/**
|
|
6159
6252
|
* Address of the stake config account which configures the rate
|
|
6160
6253
|
* of stake warmup and cooldown as well as the slashing penalty.
|
|
@@ -7285,5 +7378,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
7285
7378
|
|
|
7286
7379
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
7287
7380
|
|
|
7288
|
-
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
7381
|
+
export { Account, Authorized, BLOCKHASH_CACHE_TIMEOUT_MS, BPF_LOADER_DEPRECATED_PROGRAM_ID, BPF_LOADER_PROGRAM_ID, BpfLoader, Connection, Ed25519Program, Enum, EpochSchedule, FeeCalculatorLayout, Keypair, LAMPORTS_PER_SOL, Loader, Lockup, MAX_SEED_LENGTH, Message, NONCE_ACCOUNT_LENGTH, NonceAccount, PACKET_DATA_SIZE, PublicKey, SOLANA_SCHEMA, STAKE_CONFIG_ID, STAKE_INSTRUCTION_LAYOUTS, SYSTEM_INSTRUCTION_LAYOUTS, SYSVAR_CLOCK_PUBKEY, SYSVAR_INSTRUCTIONS_PUBKEY, SYSVAR_RECENT_BLOCKHASHES_PUBKEY, SYSVAR_RENT_PUBKEY, SYSVAR_REWARDS_PUBKEY, SYSVAR_STAKE_HISTORY_PUBKEY, Secp256k1Program, SendTransactionError, StakeAuthorizationLayout, StakeInstruction, StakeProgram, Struct, SystemInstruction, SystemProgram, Transaction, TransactionInstruction, VALIDATOR_INFO_KEY, VOTE_PROGRAM_ID, ValidatorInfo, VoteAccount, clusterApiUrl, sendAndConfirmRawTransaction, sendAndConfirmTransaction };
|
|
7289
7382
|
//# sourceMappingURL=index.browser.esm.js.map
|