@triadxyz/triad-protocol 1.5.8-beta → 1.6.0-beta

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.js CHANGED
@@ -25,7 +25,7 @@ const sendTransactionWithOptions_1 = __importDefault(require("./utils/sendTransa
25
25
  class TriadProtocolClient {
26
26
  constructor(connection, wallet) {
27
27
  this.provider = new anchor_1.AnchorProvider(connection, wallet, {
28
- commitment: 'processed'
28
+ commitment: 'confirmed'
29
29
  });
30
30
  this.program = new anchor_1.Program(idl_triad_protocol_json_1.default, this.provider);
31
31
  this.trade = new trade_1.default(this.program, this.provider);
package/dist/trade.js CHANGED
@@ -139,7 +139,7 @@ class Trade {
139
139
  getUserTradeNonceWithSlots(userTrades) {
140
140
  return __awaiter(this, void 0, void 0, function* () {
141
141
  let nonce = null;
142
- for (const userTrade of userTrades) {
142
+ for (const userTrade of userTrades.reverse()) {
143
143
  if (nonce !== null) {
144
144
  break;
145
145
  }
@@ -191,19 +191,21 @@ class Trade {
191
191
  })
192
192
  .instruction());
193
193
  }
194
- try {
195
- userTradePDA = yield this.getUserTradeNonceWithSlots(myUserTrades);
196
- }
197
- catch (_a) {
198
- const mainUserTrade = myUserTrades.find((userTrade) => !userTrade.isSubUser);
199
- const subUserTradePDA = (0, trade_1.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, Number(mainUserTrade.nonce) + 1);
200
- userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
201
- ixs.push(yield this.program.methods
202
- .createSubUserTrade(subUserTradePDA)
203
- .accounts({
204
- signer: this.provider.publicKey
205
- })
206
- .instruction());
194
+ if (myUserTrades.length > 0) {
195
+ try {
196
+ userTradePDA = yield this.getUserTradeNonceWithSlots(myUserTrades);
197
+ }
198
+ catch (_a) {
199
+ const mainUserTrade = myUserTrades.find((userTrade) => !userTrade.isSubUser);
200
+ const subUserTradePDA = (0, trade_1.getSubUserTradePDA)(this.program.programId, this.provider.publicKey, Number(mainUserTrade.nonce) + 1);
201
+ userTradePDA = (0, trade_1.getUserTradePDA)(this.program.programId, subUserTradePDA);
202
+ ixs.push(yield this.program.methods
203
+ .createSubUserTrade(subUserTradePDA)
204
+ .accounts({
205
+ signer: this.provider.publicKey
206
+ })
207
+ .instruction());
208
+ }
207
209
  }
208
210
  if (token !== constants_1.TRD_MINT.toBase58()) {
209
211
  const { setupInstructions, swapIxs, addressLookupTableAccounts, trdAmount } = yield (0, swap_1.swap)({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@triadxyz/triad-protocol",
3
- "version": "1.5.8-beta",
3
+ "version": "1.6.0-beta",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",