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.js
CHANGED
|
@@ -86,6 +86,32 @@ class IndexerClient {
|
|
|
86
86
|
const res = await this.makeRequest('GET', path);
|
|
87
87
|
return res.data.transaction;
|
|
88
88
|
}
|
|
89
|
+
async getTransactionsByWalletBeforeTimestamp(wallet, filter, limit, timestamp_lt, last_hash) {
|
|
90
|
+
if (!wallet) {
|
|
91
|
+
throw new Error("wallet address cannot be empty");
|
|
92
|
+
}
|
|
93
|
+
let finalLimit = limit && limit > 0 ? limit : 20;
|
|
94
|
+
if (finalLimit > 1000)
|
|
95
|
+
finalLimit = 1000;
|
|
96
|
+
const params = {
|
|
97
|
+
limit: finalLimit,
|
|
98
|
+
...(timestamp_lt && { timestamp_lt }),
|
|
99
|
+
...(last_hash && { last_hash }),
|
|
100
|
+
};
|
|
101
|
+
switch (filter) {
|
|
102
|
+
case API_FILTER_PARAMS.ALL:
|
|
103
|
+
params["wallet_address"] = wallet;
|
|
104
|
+
break;
|
|
105
|
+
case API_FILTER_PARAMS.SENT:
|
|
106
|
+
params["filter_from_address"] = wallet;
|
|
107
|
+
break;
|
|
108
|
+
case API_FILTER_PARAMS.RECEIVED:
|
|
109
|
+
params["filter_to_address"] = wallet;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const path = `${this.chainId}/transactions/infinite`;
|
|
113
|
+
return this.makeRequest("GET", path, params);
|
|
114
|
+
}
|
|
89
115
|
async getTransactionByWallet(wallet, page = 1, limit = 50, filter, sortBy = 'transaction_timestamp', sortOrder = 'desc') {
|
|
90
116
|
if (!wallet) {
|
|
91
117
|
throw new Error('wallet address cannot be empty');
|
|
@@ -7679,8 +7705,9 @@ const PRNG_CONSTANTS = {
|
|
|
7679
7705
|
BYTE_MASK: 0xff,
|
|
7680
7706
|
};
|
|
7681
7707
|
const TX_TYPE = {
|
|
7682
|
-
|
|
7683
|
-
|
|
7708
|
+
TRANSFER_BY_ZK: 0,
|
|
7709
|
+
TRANSFER_BY_KEY: 1,
|
|
7710
|
+
USER_CONTENT: 2,
|
|
7684
7711
|
};
|
|
7685
7712
|
const DECIMALS = 6;
|
|
7686
7713
|
class MmnClient {
|
|
@@ -7999,7 +8026,7 @@ class MmnClient {
|
|
|
7999
8026
|
seed.fill(0);
|
|
8000
8027
|
keyPair.secretKey.fill(0);
|
|
8001
8028
|
// Return signature based on transaction type
|
|
8002
|
-
if (tx.type === TX_TYPE.
|
|
8029
|
+
if (tx.type === TX_TYPE.TRANSFER_BY_KEY) {
|
|
8003
8030
|
return bs58.encode(BufferCompat.from(signature));
|
|
8004
8031
|
}
|
|
8005
8032
|
// For regular transactions, wrap signature with public key
|
|
@@ -8034,7 +8061,7 @@ class MmnClient {
|
|
|
8034
8061
|
const toAddress = this.getAddressFromUserId(params.recipient);
|
|
8035
8062
|
const signedTx = this.createAndSignTx({
|
|
8036
8063
|
...params,
|
|
8037
|
-
type: TX_TYPE.
|
|
8064
|
+
type: TX_TYPE.TRANSFER_BY_ZK,
|
|
8038
8065
|
sender: fromAddress,
|
|
8039
8066
|
recipient: toAddress,
|
|
8040
8067
|
});
|
|
@@ -8043,14 +8070,21 @@ class MmnClient {
|
|
|
8043
8070
|
async sendTransactionByAddress(params) {
|
|
8044
8071
|
const signedTx = this.createAndSignTx({
|
|
8045
8072
|
...params,
|
|
8046
|
-
type: TX_TYPE.
|
|
8073
|
+
type: TX_TYPE.TRANSFER_BY_ZK,
|
|
8047
8074
|
});
|
|
8048
8075
|
return this.addTx(signedTx);
|
|
8049
8076
|
}
|
|
8050
8077
|
async sendTransactionByPrivateKey(params) {
|
|
8051
8078
|
const signedTx = this.createAndSignTx({
|
|
8052
8079
|
...params,
|
|
8053
|
-
type: TX_TYPE.
|
|
8080
|
+
type: TX_TYPE.TRANSFER_BY_KEY,
|
|
8081
|
+
});
|
|
8082
|
+
return this.addTx(signedTx);
|
|
8083
|
+
}
|
|
8084
|
+
async postDonationCampaignFeed(params) {
|
|
8085
|
+
const signedTx = this.createAndSignTx({
|
|
8086
|
+
...params,
|
|
8087
|
+
type: TX_TYPE.USER_CONTENT,
|
|
8054
8088
|
});
|
|
8055
8089
|
return this.addTx(signedTx);
|
|
8056
8090
|
}
|