mmn-client-js 1.0.11 → 1.0.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.
- package/README.md +17 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +9 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -105,7 +105,8 @@ const walletInfo = await indexerClient.getWalletDetail('wallet-address');
|
|
|
105
105
|
// Create ZK client for proof generation
|
|
106
106
|
const zkClient = new ZkClient({
|
|
107
107
|
endpoint: 'https://zk.mmn.network',
|
|
108
|
-
|
|
108
|
+
timeout: 30000,
|
|
109
|
+
// chainId is not required for ZK client
|
|
109
110
|
});
|
|
110
111
|
|
|
111
112
|
// Generate ZK proof for authentication
|
|
@@ -178,6 +179,21 @@ const response = await client.sendTransaction({
|
|
|
178
179
|
});
|
|
179
180
|
```
|
|
180
181
|
|
|
182
|
+
**`sendTransactionByPrivateKey(params): Promise<AddTxResponse>`**
|
|
183
|
+
Create, sign (using the provided private key) and submit a transaction without relying on a client-stored keypair.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
const response = await client.sendTransactionByPrivateKey({
|
|
187
|
+
sender: 'user123',
|
|
188
|
+
recipient: 'user456',
|
|
189
|
+
amount: '1000000000000000000',
|
|
190
|
+
nonce: 1,
|
|
191
|
+
textData: 'Optional message',
|
|
192
|
+
extraInfo: { type: 'transfer_token', UserSenderId: 'user123', ... },
|
|
193
|
+
privateKey: 'private-key-pkcs8-hex'
|
|
194
|
+
});
|
|
195
|
+
```
|
|
196
|
+
|
|
181
197
|
**`getCurrentNonce(address: string, tag?: 'latest' | 'pending'): Promise<GetCurrentNonceResponse>`**
|
|
182
198
|
Get current nonce for an account.
|
|
183
199
|
|
package/dist/index.d.ts
CHANGED
|
@@ -259,6 +259,7 @@ declare class MmnClient {
|
|
|
259
259
|
*/
|
|
260
260
|
sendTransaction(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
261
261
|
sendTransactionByAddress(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
262
|
+
sendTransactionByPrivateKey(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
262
263
|
/**
|
|
263
264
|
* Get current nonce for an account
|
|
264
265
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -7678,7 +7678,7 @@ const PRNG_CONSTANTS = {
|
|
|
7678
7678
|
};
|
|
7679
7679
|
const TX_TYPE = {
|
|
7680
7680
|
TRANSFER: 0,
|
|
7681
|
-
|
|
7681
|
+
PRIVATE_KEY: 1,
|
|
7682
7682
|
};
|
|
7683
7683
|
const DECIMALS = 6;
|
|
7684
7684
|
class MmnClient {
|
|
@@ -7997,7 +7997,7 @@ class MmnClient {
|
|
|
7997
7997
|
seed.fill(0);
|
|
7998
7998
|
keyPair.secretKey.fill(0);
|
|
7999
7999
|
// Return signature based on transaction type
|
|
8000
|
-
if (tx.type === TX_TYPE.
|
|
8000
|
+
if (tx.type === TX_TYPE.PRIVATE_KEY) {
|
|
8001
8001
|
return bs58.encode(BufferCompat.from(signature));
|
|
8002
8002
|
}
|
|
8003
8003
|
// For regular transactions, wrap signature with public key
|
|
@@ -8045,6 +8045,13 @@ class MmnClient {
|
|
|
8045
8045
|
});
|
|
8046
8046
|
return this.addTx(signedTx);
|
|
8047
8047
|
}
|
|
8048
|
+
async sendTransactionByPrivateKey(params) {
|
|
8049
|
+
const signedTx = this.createAndSignTx({
|
|
8050
|
+
...params,
|
|
8051
|
+
type: TX_TYPE.PRIVATE_KEY,
|
|
8052
|
+
});
|
|
8053
|
+
return this.addTx(signedTx);
|
|
8054
|
+
}
|
|
8048
8055
|
/**
|
|
8049
8056
|
* Get current nonce for an account
|
|
8050
8057
|
*/
|