mmn-client-js 1.0.13 → 1.0.14
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/dist/index.d.ts +6 -1
- package/dist/index.esm.js +40 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +40 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,7 @@ interface ExtraInfo {
|
|
|
35
35
|
ChannelId?: string;
|
|
36
36
|
MessageRefId?: string;
|
|
37
37
|
ExtraAttribute?: string;
|
|
38
|
-
[x: string]: string;
|
|
38
|
+
[x: string]: string | string[];
|
|
39
39
|
}
|
|
40
40
|
interface TxMsg {
|
|
41
41
|
type: number;
|
|
@@ -135,6 +135,9 @@ interface Meta {
|
|
|
135
135
|
limit?: number;
|
|
136
136
|
total_items?: number;
|
|
137
137
|
total_pages?: number;
|
|
138
|
+
has_more?: boolean;
|
|
139
|
+
next_timestamp?: string;
|
|
140
|
+
next_hash?: string;
|
|
138
141
|
}
|
|
139
142
|
interface WalletDetail {
|
|
140
143
|
address: string;
|
|
@@ -198,6 +201,7 @@ declare class IndexerClient {
|
|
|
198
201
|
*/
|
|
199
202
|
private makeRequest;
|
|
200
203
|
getTransactionByHash(hash: string): Promise<Transaction>;
|
|
204
|
+
getTransactionsByWalletBeforeTimestamp(wallet: string, filter: number, limit?: number, timestamp_lt?: string, last_hash?: string): Promise<ListTransactionResponse>;
|
|
201
205
|
getTransactionByWallet(wallet: string, page: number | undefined, limit: number | undefined, filter: number, sortBy?: string, sortOrder?: 'asc' | 'desc'): Promise<ListTransactionResponse>;
|
|
202
206
|
getWalletDetail(wallet: string): Promise<WalletDetail>;
|
|
203
207
|
}
|
|
@@ -262,6 +266,7 @@ declare class MmnClient {
|
|
|
262
266
|
sendTransaction(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
263
267
|
sendTransactionByAddress(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
264
268
|
sendTransactionByPrivateKey(params: SendTransactionBase): Promise<AddTxResponse>;
|
|
269
|
+
postDonationCampaignFeed(params: SendTransactionRequest): Promise<AddTxResponse>;
|
|
265
270
|
/**
|
|
266
271
|
* Get current nonce for an account
|
|
267
272
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -84,6 +84,32 @@ class IndexerClient {
|
|
|
84
84
|
const res = await this.makeRequest('GET', path);
|
|
85
85
|
return res.data.transaction;
|
|
86
86
|
}
|
|
87
|
+
async getTransactionsByWalletBeforeTimestamp(wallet, filter, limit, timestamp_lt, last_hash) {
|
|
88
|
+
if (!wallet) {
|
|
89
|
+
throw new Error("wallet address cannot be empty");
|
|
90
|
+
}
|
|
91
|
+
let finalLimit = limit && limit > 0 ? limit : 20;
|
|
92
|
+
if (finalLimit > 1000)
|
|
93
|
+
finalLimit = 1000;
|
|
94
|
+
const params = {
|
|
95
|
+
limit: finalLimit,
|
|
96
|
+
...(timestamp_lt && { timestamp_lt }),
|
|
97
|
+
...(last_hash && { last_hash }),
|
|
98
|
+
};
|
|
99
|
+
switch (filter) {
|
|
100
|
+
case API_FILTER_PARAMS.ALL:
|
|
101
|
+
params["wallet_address"] = wallet;
|
|
102
|
+
break;
|
|
103
|
+
case API_FILTER_PARAMS.SENT:
|
|
104
|
+
params["filter_from_address"] = wallet;
|
|
105
|
+
break;
|
|
106
|
+
case API_FILTER_PARAMS.RECEIVED:
|
|
107
|
+
params["filter_to_address"] = wallet;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const path = `${this.chainId}/transactions/infinite`;
|
|
111
|
+
return this.makeRequest("GET", path, params);
|
|
112
|
+
}
|
|
87
113
|
async getTransactionByWallet(wallet, page = 1, limit = 50, filter, sortBy = 'transaction_timestamp', sortOrder = 'desc') {
|
|
88
114
|
if (!wallet) {
|
|
89
115
|
throw new Error('wallet address cannot be empty');
|
|
@@ -7677,8 +7703,9 @@ const PRNG_CONSTANTS = {
|
|
|
7677
7703
|
BYTE_MASK: 0xff,
|
|
7678
7704
|
};
|
|
7679
7705
|
const TX_TYPE = {
|
|
7680
|
-
|
|
7681
|
-
|
|
7706
|
+
TRANSFER_BY_ZK: 0,
|
|
7707
|
+
TRANSFER_BY_KEY: 1,
|
|
7708
|
+
USER_CONTENT: 2,
|
|
7682
7709
|
};
|
|
7683
7710
|
const DECIMALS = 6;
|
|
7684
7711
|
class MmnClient {
|
|
@@ -7997,7 +8024,7 @@ class MmnClient {
|
|
|
7997
8024
|
seed.fill(0);
|
|
7998
8025
|
keyPair.secretKey.fill(0);
|
|
7999
8026
|
// Return signature based on transaction type
|
|
8000
|
-
if (tx.type === TX_TYPE.
|
|
8027
|
+
if (tx.type === TX_TYPE.TRANSFER_BY_KEY) {
|
|
8001
8028
|
return bs58.encode(BufferCompat.from(signature));
|
|
8002
8029
|
}
|
|
8003
8030
|
// For regular transactions, wrap signature with public key
|
|
@@ -8032,7 +8059,7 @@ class MmnClient {
|
|
|
8032
8059
|
const toAddress = this.getAddressFromUserId(params.recipient);
|
|
8033
8060
|
const signedTx = this.createAndSignTx({
|
|
8034
8061
|
...params,
|
|
8035
|
-
type: TX_TYPE.
|
|
8062
|
+
type: TX_TYPE.TRANSFER_BY_ZK,
|
|
8036
8063
|
sender: fromAddress,
|
|
8037
8064
|
recipient: toAddress,
|
|
8038
8065
|
});
|
|
@@ -8041,14 +8068,21 @@ class MmnClient {
|
|
|
8041
8068
|
async sendTransactionByAddress(params) {
|
|
8042
8069
|
const signedTx = this.createAndSignTx({
|
|
8043
8070
|
...params,
|
|
8044
|
-
type: TX_TYPE.
|
|
8071
|
+
type: TX_TYPE.TRANSFER_BY_ZK,
|
|
8045
8072
|
});
|
|
8046
8073
|
return this.addTx(signedTx);
|
|
8047
8074
|
}
|
|
8048
8075
|
async sendTransactionByPrivateKey(params) {
|
|
8049
8076
|
const signedTx = this.createAndSignTx({
|
|
8050
8077
|
...params,
|
|
8051
|
-
type: TX_TYPE.
|
|
8078
|
+
type: TX_TYPE.TRANSFER_BY_KEY,
|
|
8079
|
+
});
|
|
8080
|
+
return this.addTx(signedTx);
|
|
8081
|
+
}
|
|
8082
|
+
async postDonationCampaignFeed(params) {
|
|
8083
|
+
const signedTx = this.createAndSignTx({
|
|
8084
|
+
...params,
|
|
8085
|
+
type: TX_TYPE.USER_CONTENT,
|
|
8052
8086
|
});
|
|
8053
8087
|
return this.addTx(signedTx);
|
|
8054
8088
|
}
|