@0dotxyz/p0-ts-sdk 2.1.0 → 2.2.0-alpha.0

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/vendor.cjs CHANGED
@@ -510,12 +510,36 @@ function createMemoInstruction(memo, signerPubkeys) {
510
510
  });
511
511
  }
512
512
  var TokenInstruction = /* @__PURE__ */ ((TokenInstruction2) => {
513
+ TokenInstruction2[TokenInstruction2["Approve"] = 4] = "Approve";
513
514
  TokenInstruction2[TokenInstruction2["InitializeAccount"] = 1] = "InitializeAccount";
514
515
  TokenInstruction2[TokenInstruction2["TransferChecked"] = 12] = "TransferChecked";
515
516
  TokenInstruction2[TokenInstruction2["CloseAccount"] = 9] = "CloseAccount";
516
517
  TokenInstruction2[TokenInstruction2["SyncNative"] = 17] = "SyncNative";
517
518
  return TokenInstruction2;
518
519
  })(TokenInstruction || {});
520
+ var approveInstructionData = bufferLayout.struct([
521
+ bufferLayout.u8("instruction"),
522
+ bufferLayoutUtils.u64("amount")
523
+ ]);
524
+ function createApproveInstruction(account, delegate, owner, amount, multiSigners = [], programId = TOKEN_PROGRAM_ID) {
525
+ const keys = addSigners(
526
+ [
527
+ { pubkey: account, isSigner: false, isWritable: true },
528
+ { pubkey: delegate, isSigner: false, isWritable: false }
529
+ ],
530
+ owner,
531
+ multiSigners
532
+ );
533
+ const data = buffer.Buffer.alloc(approveInstructionData.span);
534
+ approveInstructionData.encode(
535
+ {
536
+ instruction: 4 /* Approve */,
537
+ amount: BigInt(amount)
538
+ },
539
+ data
540
+ );
541
+ return new web3_js.TransactionInstruction({ keys, programId, data });
542
+ }
519
543
  var initializeAccountInstructionData = bufferLayout.struct([
520
544
  bufferLayout.u8("instruction")
521
545
  ]);
@@ -29261,6 +29285,7 @@ exports.TokenOwnerOffCurveError = TokenOwnerOffCurveError;
29261
29285
  exports.TokenUnsupportedInstructionError = TokenUnsupportedInstructionError;
29262
29286
  exports.ZERO = ZERO;
29263
29287
  exports.addSigners = addSigners;
29288
+ exports.approveInstructionData = approveInstructionData;
29264
29289
  exports.calculateAPYFromAPR = calculateAPYFromAPR;
29265
29290
  exports.calculateDriftBorrowAPR = calculateDriftBorrowAPR;
29266
29291
  exports.calculateDriftBorrowAPY = calculateDriftBorrowAPY;
@@ -29286,6 +29311,7 @@ exports.calculateSlotAdjustmentFactor = calculateSlotAdjustmentFactor;
29286
29311
  exports.calculateUtilizationRatio = calculateUtilizationRatio;
29287
29312
  exports.closeAccountInstructionData = closeAccountInstructionData;
29288
29313
  exports.createAccountIx = createAccountIx;
29314
+ exports.createApproveInstruction = createApproveInstruction;
29289
29315
  exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction;
29290
29316
  exports.createAssociatedTokenAccountInstruction = createAssociatedTokenAccountInstruction;
29291
29317
  exports.createCloseAccountInstruction = createCloseAccountInstruction;