mmn-client-js 1.0.11 → 1.0.13
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 +9 -6
- package/dist/index.esm.js +11 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +11 -4
- 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
|
@@ -29,8 +29,8 @@ interface ExtraInfo {
|
|
|
29
29
|
ItemId?: string;
|
|
30
30
|
ItemType?: string;
|
|
31
31
|
ClanId?: string;
|
|
32
|
-
UserSenderId
|
|
33
|
-
UserSenderUsername
|
|
32
|
+
UserSenderId?: string;
|
|
33
|
+
UserSenderUsername?: string;
|
|
34
34
|
UserReceiverId?: string;
|
|
35
35
|
ChannelId?: string;
|
|
36
36
|
MessageRefId?: string;
|
|
@@ -53,18 +53,20 @@ interface SignedTx {
|
|
|
53
53
|
tx_msg: TxMsg;
|
|
54
54
|
signature: string;
|
|
55
55
|
}
|
|
56
|
-
interface
|
|
56
|
+
interface SendTransactionBase {
|
|
57
57
|
sender: string;
|
|
58
58
|
recipient: string;
|
|
59
59
|
amount: string;
|
|
60
60
|
nonce: number;
|
|
61
61
|
timestamp?: number;
|
|
62
62
|
textData?: string;
|
|
63
|
-
extraInfo?: ExtraInfo;
|
|
64
|
-
publicKey: string;
|
|
65
63
|
privateKey: string;
|
|
64
|
+
extraInfo?: ExtraInfo;
|
|
65
|
+
}
|
|
66
|
+
interface SendTransactionRequest extends SendTransactionBase {
|
|
66
67
|
zkProof: string;
|
|
67
68
|
zkPub: string;
|
|
69
|
+
publicKey: string;
|
|
68
70
|
}
|
|
69
71
|
interface AddTxResponse {
|
|
70
72
|
ok: boolean;
|
|
@@ -259,6 +261,7 @@ declare class MmnClient {
|
|
|
259
261
|
*/
|
|
260
262
|
sendTransaction(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
261
263
|
sendTransactionByAddress(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
264
|
+
sendTransactionByPrivateKey(params: SendTransactionBase): Promise<AddTxResponse>;
|
|
262
265
|
/**
|
|
263
266
|
* Get current nonce for an account
|
|
264
267
|
*/
|
|
@@ -280,4 +283,4 @@ declare class ZkClient {
|
|
|
280
283
|
}
|
|
281
284
|
|
|
282
285
|
export { ETransferType, EZkClientType, IndexerClient, MmnClient, ZkClient, createMmnClient };
|
|
283
|
-
export type { AddTxResponse, ExtraInfo, GetAccountByAddressResponse, GetCurrentNonceResponse, GetZkProofRequest, IEphemeralKeyPair, IZkProof, IndexerClientConfig, JsonRpcError, JsonRpcRequest, JsonRpcResponse, ListTransactionResponse, Meta, MmnClientConfig, SendTransactionRequest, SignedTx, Transaction, TransactionDetailResponse, TxMsg, WalletDetail, WalletDetailResponse, ZkClientConfig };
|
|
286
|
+
export type { AddTxResponse, ExtraInfo, GetAccountByAddressResponse, GetCurrentNonceResponse, GetZkProofRequest, IEphemeralKeyPair, IZkProof, IndexerClientConfig, JsonRpcError, JsonRpcRequest, JsonRpcResponse, ListTransactionResponse, Meta, MmnClientConfig, SendTransactionBase, SendTransactionRequest, SignedTx, Transaction, TransactionDetailResponse, TxMsg, WalletDetail, WalletDetailResponse, ZkClientConfig };
|
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 {
|
|
@@ -7946,8 +7946,8 @@ class MmnClient {
|
|
|
7946
7946
|
text_data: params.textData || '',
|
|
7947
7947
|
nonce: params.nonce,
|
|
7948
7948
|
extra_info: JSON.stringify(params.extraInfo) || '',
|
|
7949
|
-
zk_proof: params.zkProof,
|
|
7950
|
-
zk_pub: params.zkPub,
|
|
7949
|
+
zk_proof: params.zkProof || '',
|
|
7950
|
+
zk_pub: params.zkPub || '',
|
|
7951
7951
|
};
|
|
7952
7952
|
const signature = this.signTransaction(txMsg, params.privateKey);
|
|
7953
7953
|
return {
|
|
@@ -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
|
*/
|