@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.iife.js
CHANGED
|
@@ -9466,6 +9466,9 @@ var solanaWeb3 = (function (exports) {
|
|
|
9466
9466
|
*/
|
|
9467
9467
|
|
|
9468
9468
|
const MAX_SEED_LENGTH = 32;
|
|
9469
|
+
/**
|
|
9470
|
+
* Value to be converted into public key
|
|
9471
|
+
*/
|
|
9469
9472
|
|
|
9470
9473
|
function isPublicKeyData(value) {
|
|
9471
9474
|
return value._bn !== undefined;
|
|
@@ -21250,6 +21253,96 @@ var solanaWeb3 = (function (exports) {
|
|
|
21250
21253
|
|
|
21251
21254
|
}
|
|
21252
21255
|
|
|
21256
|
+
const PRIVATE_KEY_BYTES$1 = 64;
|
|
21257
|
+
const PUBLIC_KEY_BYTES$1 = 32;
|
|
21258
|
+
const SIGNATURE_BYTES = 64;
|
|
21259
|
+
/**
|
|
21260
|
+
* Params for creating an ed25519 instruction using a public key
|
|
21261
|
+
*/
|
|
21262
|
+
|
|
21263
|
+
const ED25519_INSTRUCTION_LAYOUT = struct([u8('numSignatures'), u8('padding'), u16('signatureOffset'), u16('signatureInstructionIndex'), u16('publicKeyOffset'), u16('publicKeyInstructionIndex'), u16('messageDataOffset'), u16('messageDataSize'), u16('messageInstructionIndex')]);
|
|
21264
|
+
class Ed25519Program {
|
|
21265
|
+
/**
|
|
21266
|
+
* @internal
|
|
21267
|
+
*/
|
|
21268
|
+
constructor() {}
|
|
21269
|
+
/**
|
|
21270
|
+
* Public key that identifies the ed25519 program
|
|
21271
|
+
*/
|
|
21272
|
+
|
|
21273
|
+
|
|
21274
|
+
/**
|
|
21275
|
+
* Create an ed25519 instruction with a public key and signature. The
|
|
21276
|
+
* public key must be a buffer that is 32 bytes long, and the signature
|
|
21277
|
+
* must be a buffer of 64 bytes.
|
|
21278
|
+
*/
|
|
21279
|
+
static createInstructionWithPublicKey(params) {
|
|
21280
|
+
const {
|
|
21281
|
+
publicKey,
|
|
21282
|
+
message,
|
|
21283
|
+
signature,
|
|
21284
|
+
instructionIndex
|
|
21285
|
+
} = params;
|
|
21286
|
+
assert$i(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
21287
|
+
assert$i(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
21288
|
+
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
21289
|
+
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
21290
|
+
const messageDataOffset = signatureOffset + signature.length;
|
|
21291
|
+
const numSignatures = 1;
|
|
21292
|
+
const instructionData = buffer.Buffer.alloc(messageDataOffset + message.length);
|
|
21293
|
+
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
21294
|
+
numSignatures,
|
|
21295
|
+
padding: 0,
|
|
21296
|
+
signatureOffset,
|
|
21297
|
+
signatureInstructionIndex: instructionIndex,
|
|
21298
|
+
publicKeyOffset,
|
|
21299
|
+
publicKeyInstructionIndex: instructionIndex,
|
|
21300
|
+
messageDataOffset,
|
|
21301
|
+
messageDataSize: message.length,
|
|
21302
|
+
messageInstructionIndex: instructionIndex
|
|
21303
|
+
}, instructionData);
|
|
21304
|
+
instructionData.fill(publicKey, publicKeyOffset);
|
|
21305
|
+
instructionData.fill(signature, signatureOffset);
|
|
21306
|
+
instructionData.fill(message, messageDataOffset);
|
|
21307
|
+
return new TransactionInstruction({
|
|
21308
|
+
keys: [],
|
|
21309
|
+
programId: Ed25519Program.programId,
|
|
21310
|
+
data: instructionData
|
|
21311
|
+
});
|
|
21312
|
+
}
|
|
21313
|
+
/**
|
|
21314
|
+
* Create an ed25519 instruction with a private key. The private key
|
|
21315
|
+
* must be a buffer that is 64 bytes long.
|
|
21316
|
+
*/
|
|
21317
|
+
|
|
21318
|
+
|
|
21319
|
+
static createInstructionWithPrivateKey(params) {
|
|
21320
|
+
const {
|
|
21321
|
+
privateKey,
|
|
21322
|
+
message,
|
|
21323
|
+
instructionIndex
|
|
21324
|
+
} = params;
|
|
21325
|
+
assert$i(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
21326
|
+
|
|
21327
|
+
try {
|
|
21328
|
+
const keypair = Keypair.fromSecretKey(privateKey);
|
|
21329
|
+
const publicKey = keypair.publicKey.toBytes();
|
|
21330
|
+
const signature = nacl.sign.detached(message, keypair.secretKey);
|
|
21331
|
+
return this.createInstructionWithPublicKey({
|
|
21332
|
+
publicKey,
|
|
21333
|
+
message,
|
|
21334
|
+
signature,
|
|
21335
|
+
instructionIndex
|
|
21336
|
+
});
|
|
21337
|
+
} catch (error) {
|
|
21338
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
21339
|
+
}
|
|
21340
|
+
}
|
|
21341
|
+
|
|
21342
|
+
}
|
|
21343
|
+
|
|
21344
|
+
_defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
21345
|
+
|
|
21253
21346
|
/**
|
|
21254
21347
|
* Address of the stake config account which configures the rate
|
|
21255
21348
|
* of stake warmup and cooldown as well as the slashing penalty.
|
|
@@ -29249,6 +29342,7 @@ var solanaWeb3 = (function (exports) {
|
|
|
29249
29342
|
exports.BPF_LOADER_PROGRAM_ID = BPF_LOADER_PROGRAM_ID;
|
|
29250
29343
|
exports.BpfLoader = BpfLoader;
|
|
29251
29344
|
exports.Connection = Connection;
|
|
29345
|
+
exports.Ed25519Program = Ed25519Program;
|
|
29252
29346
|
exports.Enum = Enum;
|
|
29253
29347
|
exports.EpochSchedule = EpochSchedule;
|
|
29254
29348
|
exports.FeeCalculatorLayout = FeeCalculatorLayout;
|