@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.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ declare module '@solana/web3.js' {
|
|
|
18
18
|
* Maximum length of derived pubkey seed
|
|
19
19
|
*/
|
|
20
20
|
export const MAX_SEED_LENGTH = 32;
|
|
21
|
+
/**
|
|
22
|
+
* Value to be converted into public key
|
|
23
|
+
*/
|
|
21
24
|
export type PublicKeyInitData =
|
|
22
25
|
| number
|
|
23
26
|
| string
|
|
@@ -25,6 +28,9 @@ declare module '@solana/web3.js' {
|
|
|
25
28
|
| Uint8Array
|
|
26
29
|
| Array<number>
|
|
27
30
|
| PublicKeyData;
|
|
31
|
+
/**
|
|
32
|
+
* JSON object representation of PublicKey class
|
|
33
|
+
*/
|
|
28
34
|
export type PublicKeyData = {};
|
|
29
35
|
/**
|
|
30
36
|
* A public key
|
|
@@ -1956,6 +1962,45 @@ declare module '@solana/web3.js' {
|
|
|
1956
1962
|
): Promise<boolean>;
|
|
1957
1963
|
}
|
|
1958
1964
|
|
|
1965
|
+
/**
|
|
1966
|
+
* Params for creating an ed25519 instruction using a public key
|
|
1967
|
+
*/
|
|
1968
|
+
export type CreateEd25519InstructionWithPublicKeyParams = {
|
|
1969
|
+
publicKey: Uint8Array;
|
|
1970
|
+
message: Uint8Array;
|
|
1971
|
+
signature: Uint8Array;
|
|
1972
|
+
instructionIndex?: number;
|
|
1973
|
+
};
|
|
1974
|
+
/**
|
|
1975
|
+
* Params for creating an ed25519 instruction using a private key
|
|
1976
|
+
*/
|
|
1977
|
+
export type CreateEd25519InstructionWithPrivateKeyParams = {
|
|
1978
|
+
privateKey: Uint8Array;
|
|
1979
|
+
message: Uint8Array;
|
|
1980
|
+
instructionIndex?: number;
|
|
1981
|
+
};
|
|
1982
|
+
export class Ed25519Program {
|
|
1983
|
+
/**
|
|
1984
|
+
* Public key that identifies the ed25519 program
|
|
1985
|
+
*/
|
|
1986
|
+
static programId: PublicKey;
|
|
1987
|
+
/**
|
|
1988
|
+
* Create an ed25519 instruction with a public key and signature. The
|
|
1989
|
+
* public key must be a buffer that is 32 bytes long, and the signature
|
|
1990
|
+
* must be a buffer of 64 bytes.
|
|
1991
|
+
*/
|
|
1992
|
+
static createInstructionWithPublicKey(
|
|
1993
|
+
params: CreateEd25519InstructionWithPublicKeyParams,
|
|
1994
|
+
): TransactionInstruction;
|
|
1995
|
+
/**
|
|
1996
|
+
* Create an ed25519 instruction with a private key. The private key
|
|
1997
|
+
* must be a buffer that is 64 bytes long.
|
|
1998
|
+
*/
|
|
1999
|
+
static createInstructionWithPrivateKey(
|
|
2000
|
+
params: CreateEd25519InstructionWithPrivateKeyParams,
|
|
2001
|
+
): TransactionInstruction;
|
|
2002
|
+
}
|
|
2003
|
+
|
|
1959
2004
|
/**
|
|
1960
2005
|
* Program loader interface
|
|
1961
2006
|
*/
|
package/lib/index.esm.js
CHANGED
|
@@ -69,6 +69,9 @@ const SOLANA_SCHEMA = new Map();
|
|
|
69
69
|
*/
|
|
70
70
|
|
|
71
71
|
const MAX_SEED_LENGTH = 32;
|
|
72
|
+
/**
|
|
73
|
+
* Value to be converted into public key
|
|
74
|
+
*/
|
|
72
75
|
|
|
73
76
|
function isPublicKeyData(value) {
|
|
74
77
|
return value._bn !== undefined;
|
|
@@ -5650,6 +5653,96 @@ class Keypair {
|
|
|
5650
5653
|
|
|
5651
5654
|
}
|
|
5652
5655
|
|
|
5656
|
+
const PRIVATE_KEY_BYTES$1 = 64;
|
|
5657
|
+
const PUBLIC_KEY_BYTES$1 = 32;
|
|
5658
|
+
const SIGNATURE_BYTES = 64;
|
|
5659
|
+
/**
|
|
5660
|
+
* Params for creating an ed25519 instruction using a public key
|
|
5661
|
+
*/
|
|
5662
|
+
|
|
5663
|
+
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')]);
|
|
5664
|
+
class Ed25519Program {
|
|
5665
|
+
/**
|
|
5666
|
+
* @internal
|
|
5667
|
+
*/
|
|
5668
|
+
constructor() {}
|
|
5669
|
+
/**
|
|
5670
|
+
* Public key that identifies the ed25519 program
|
|
5671
|
+
*/
|
|
5672
|
+
|
|
5673
|
+
|
|
5674
|
+
/**
|
|
5675
|
+
* Create an ed25519 instruction with a public key and signature. The
|
|
5676
|
+
* public key must be a buffer that is 32 bytes long, and the signature
|
|
5677
|
+
* must be a buffer of 64 bytes.
|
|
5678
|
+
*/
|
|
5679
|
+
static createInstructionWithPublicKey(params) {
|
|
5680
|
+
const {
|
|
5681
|
+
publicKey,
|
|
5682
|
+
message,
|
|
5683
|
+
signature,
|
|
5684
|
+
instructionIndex
|
|
5685
|
+
} = params;
|
|
5686
|
+
assert(publicKey.length === PUBLIC_KEY_BYTES$1, `Public Key must be ${PUBLIC_KEY_BYTES$1} bytes but received ${publicKey.length} bytes`);
|
|
5687
|
+
assert(signature.length === SIGNATURE_BYTES, `Signature must be ${SIGNATURE_BYTES} bytes but received ${signature.length} bytes`);
|
|
5688
|
+
const publicKeyOffset = ED25519_INSTRUCTION_LAYOUT.span;
|
|
5689
|
+
const signatureOffset = publicKeyOffset + publicKey.length;
|
|
5690
|
+
const messageDataOffset = signatureOffset + signature.length;
|
|
5691
|
+
const numSignatures = 1;
|
|
5692
|
+
const instructionData = Buffer.alloc(messageDataOffset + message.length);
|
|
5693
|
+
ED25519_INSTRUCTION_LAYOUT.encode({
|
|
5694
|
+
numSignatures,
|
|
5695
|
+
padding: 0,
|
|
5696
|
+
signatureOffset,
|
|
5697
|
+
signatureInstructionIndex: instructionIndex,
|
|
5698
|
+
publicKeyOffset,
|
|
5699
|
+
publicKeyInstructionIndex: instructionIndex,
|
|
5700
|
+
messageDataOffset,
|
|
5701
|
+
messageDataSize: message.length,
|
|
5702
|
+
messageInstructionIndex: instructionIndex
|
|
5703
|
+
}, instructionData);
|
|
5704
|
+
instructionData.fill(publicKey, publicKeyOffset);
|
|
5705
|
+
instructionData.fill(signature, signatureOffset);
|
|
5706
|
+
instructionData.fill(message, messageDataOffset);
|
|
5707
|
+
return new TransactionInstruction({
|
|
5708
|
+
keys: [],
|
|
5709
|
+
programId: Ed25519Program.programId,
|
|
5710
|
+
data: instructionData
|
|
5711
|
+
});
|
|
5712
|
+
}
|
|
5713
|
+
/**
|
|
5714
|
+
* Create an ed25519 instruction with a private key. The private key
|
|
5715
|
+
* must be a buffer that is 64 bytes long.
|
|
5716
|
+
*/
|
|
5717
|
+
|
|
5718
|
+
|
|
5719
|
+
static createInstructionWithPrivateKey(params) {
|
|
5720
|
+
const {
|
|
5721
|
+
privateKey,
|
|
5722
|
+
message,
|
|
5723
|
+
instructionIndex
|
|
5724
|
+
} = params;
|
|
5725
|
+
assert(privateKey.length === PRIVATE_KEY_BYTES$1, `Private key must be ${PRIVATE_KEY_BYTES$1} bytes but received ${privateKey.length} bytes`);
|
|
5726
|
+
|
|
5727
|
+
try {
|
|
5728
|
+
const keypair = Keypair.fromSecretKey(privateKey);
|
|
5729
|
+
const publicKey = keypair.publicKey.toBytes();
|
|
5730
|
+
const signature = nacl__default.sign.detached(message, keypair.secretKey);
|
|
5731
|
+
return this.createInstructionWithPublicKey({
|
|
5732
|
+
publicKey,
|
|
5733
|
+
message,
|
|
5734
|
+
signature,
|
|
5735
|
+
instructionIndex
|
|
5736
|
+
});
|
|
5737
|
+
} catch (error) {
|
|
5738
|
+
throw new Error(`Error creating instruction; ${error}`);
|
|
5739
|
+
}
|
|
5740
|
+
}
|
|
5741
|
+
|
|
5742
|
+
}
|
|
5743
|
+
|
|
5744
|
+
_defineProperty(Ed25519Program, "programId", new PublicKey('Ed25519SigVerify111111111111111111111111111'));
|
|
5745
|
+
|
|
5653
5746
|
/**
|
|
5654
5747
|
* Address of the stake config account which configures the rate
|
|
5655
5748
|
* of stake warmup and cooldown as well as the slashing penalty.
|
|
@@ -6780,5 +6873,5 @@ function clusterApiUrl(cluster, tls) {
|
|
|
6780
6873
|
|
|
6781
6874
|
const LAMPORTS_PER_SOL = 1000000000;
|
|
6782
6875
|
|
|
6783
|
-
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 };
|
|
6876
|
+
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 };
|
|
6784
6877
|
//# sourceMappingURL=index.esm.js.map
|