@alephium/web3 0.5.0-rc.10 → 0.5.0-rc.12

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.
@@ -47,7 +47,7 @@ export abstract class TransactionBuilder {
47
47
  })()
48
48
  }
49
49
 
50
- private static validatePublicKey(params: SignerAddress, publicKey: string, keyType: KeyType) {
50
+ private static validatePublicKey(params: SignerAddress, publicKey: string, keyType?: KeyType) {
51
51
  const address = addressFromPublicKey(publicKey, keyType)
52
52
  if (address !== params.signerAddress) {
53
53
  throw new Error('Unmatched public key')
@@ -58,7 +58,7 @@ export abstract class TransactionBuilder {
58
58
  params: SignTransferTxParams,
59
59
  publicKey: string
60
60
  ): Promise<Omit<SignTransferTxResult, 'signature'>> {
61
- TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType ?? 'default')
61
+ TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType)
62
62
 
63
63
  const { destinations, gasPrice, ...rest } = params
64
64
  const data: node.BuildTransaction = {
@@ -76,7 +76,7 @@ export abstract class TransactionBuilder {
76
76
  params: SignDeployContractTxParams,
77
77
  publicKey: string
78
78
  ): Promise<Omit<SignDeployContractTxResult, 'signature'>> {
79
- TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType ?? 'default')
79
+ TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType)
80
80
 
81
81
  const { initialAttoAlphAmount, initialTokenAmounts, issueTokenAmount, gasPrice, ...rest } = params
82
82
  const data: node.BuildDeployContractTx = {
@@ -97,7 +97,7 @@ export abstract class TransactionBuilder {
97
97
  params: SignExecuteScriptTxParams,
98
98
  publicKey: string
99
99
  ): Promise<Omit<SignExecuteScriptTxResult, 'signature'>> {
100
- TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType ?? 'default')
100
+ TransactionBuilder.validatePublicKey(params, publicKey, params.signerKeyType)
101
101
 
102
102
  const { attoAlphAmount, tokens, gasPrice, ...rest } = params
103
103
  const data: node.BuildExecuteScriptTx = {
@@ -162,10 +162,3 @@ export interface EnableOptionsBase {
162
162
  networkId: string
163
163
  onDisconnected: () => Promise<void>
164
164
  }
165
-
166
- // Transaction Params for InteractiveSignerProvider
167
- export type ExtSignTransferTxParams = SignTransferTxParams & { networkId: string }
168
- export type ExtSignDeployContractTxParams = SignDeployContractTxParams & { networkId: string }
169
- export type ExtSignExecuteScriptTxParams = SignExecuteScriptTxParams & { networkId: string }
170
- export type ExtSignUnsignedTxParams = SignUnsignedTxParams & { networkId: string }
171
- export type ExtSignMessageParams = SignMessageParams & { networkId: string }
@@ -19,7 +19,7 @@ along with the library. If not, see <http://www.gnu.org/licenses/>.
19
19
  import * as utils from '../utils'
20
20
  import { KeyType } from '../signer'
21
21
 
22
- export function transactionSign(txId: string, privateKey: string, keyType: KeyType): string {
22
+ export function transactionSign(txId: string, privateKey: string, keyType?: KeyType): string {
23
23
  return utils.sign(txId, privateKey, keyType)
24
24
  }
25
25
 
@@ -27,7 +27,7 @@ export function transactionVerifySignature(
27
27
  txId: string,
28
28
  publicKey: string,
29
29
  signature: string,
30
- keyType: KeyType
30
+ keyType?: KeyType
31
31
  ): boolean {
32
32
  return utils.verifySignature(txId, publicKey, signature, keyType)
33
33
  }
package/src/utils/sign.ts CHANGED
@@ -37,7 +37,7 @@ necc.utils.hmacSha256Sync = (key: Uint8Array, ...messages: Uint8Array[]): Uint8A
37
37
  }
38
38
 
39
39
  // hash has to be 32 bytes
40
- export function sign(hash: string, privateKey: string, _keyType: KeyType): string {
40
+ export function sign(hash: string, privateKey: string, _keyType?: KeyType): string {
41
41
  const keyType = _keyType ?? 'default'
42
42
 
43
43
  if (keyType === 'default') {
@@ -50,7 +50,7 @@ export function sign(hash: string, privateKey: string, _keyType: KeyType): strin
50
50
  }
51
51
  }
52
52
 
53
- export function verifySignature(hash: string, publicKey: string, signature: string, _keyType: KeyType): boolean {
53
+ export function verifySignature(hash: string, publicKey: string, signature: string, _keyType?: KeyType): boolean {
54
54
  const keyType = _keyType ?? 'default'
55
55
 
56
56
  try {
@@ -158,11 +158,11 @@ export function binToHex(bin: Uint8Array): string {
158
158
  return Buffer.from(bin).toString('hex')
159
159
  }
160
160
 
161
- export function groupOfPrivateKey(privateKey: string, keyType: KeyType): number {
161
+ export function groupOfPrivateKey(privateKey: string, keyType?: KeyType): number {
162
162
  return groupOfAddress(addressFromPublicKey(publicKeyFromPrivateKey(privateKey, keyType), keyType))
163
163
  }
164
164
 
165
- export function publicKeyFromPrivateKey(privateKey: string, _keyType: KeyType): string {
165
+ export function publicKeyFromPrivateKey(privateKey: string, _keyType?: KeyType): string {
166
166
  const keyType = _keyType ?? 'default'
167
167
 
168
168
  if (keyType === 'default') {
@@ -173,7 +173,7 @@ export function publicKeyFromPrivateKey(privateKey: string, _keyType: KeyType):
173
173
  }
174
174
  }
175
175
 
176
- export function addressFromPublicKey(publicKey: string, _keyType: KeyType): string {
176
+ export function addressFromPublicKey(publicKey: string, _keyType?: KeyType): string {
177
177
  const keyType = _keyType ?? 'default'
178
178
 
179
179
  if (keyType === 'default') {