@loyal-labs/private-transactions 0.2.4 → 0.2.6

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
@@ -22265,7 +22265,9 @@ var telegram_private_transfer_default = {
22265
22265
  {
22266
22266
  name: "UsernameDeposit",
22267
22267
  docs: [
22268
- "A deposit account for a telegram username and token mint."
22268
+ "A deposit account for a telegram username and token mint.",
22269
+ "",
22270
+ "Telegram username is always lowercase (a-z, 0-9 and underscores)"
22269
22271
  ],
22270
22272
  type: {
22271
22273
  kind: "struct",
@@ -22756,7 +22758,18 @@ class LoyalPrivateTransactionsClient {
22756
22758
  delegationProgram: DELEGATION_PROGRAM_ID,
22757
22759
  systemProgram: SystemProgram.programId
22758
22760
  };
22759
- const signature = await this.baseProgram.methods.delegate(user, tokenMint).accountsPartial(accounts).rpc(rpcOptions);
22761
+ const delegationWatcher = waitForAccountOwnerChange(this.baseProgram.provider.connection, depositPda, DELEGATION_PROGRAM_ID);
22762
+ let signature;
22763
+ try {
22764
+ console.log("delegateDeposit Accounts:", prettyStringify(accounts));
22765
+ signature = await this.baseProgram.methods.delegate(user, tokenMint).accountsPartial(accounts).rpc(rpcOptions);
22766
+ console.log("delegateDeposit: waiting for depositPda owner to be DELEGATION_PROGRAM_ID on base connection...");
22767
+ await delegationWatcher.wait();
22768
+ await new Promise((resolve) => setTimeout(resolve, 3000));
22769
+ } catch (e) {
22770
+ await delegationWatcher.cancel();
22771
+ throw e;
22772
+ }
22760
22773
  return signature;
22761
22774
  }
22762
22775
  async delegateUsernameDeposit(params) {
@@ -22784,7 +22797,18 @@ class LoyalPrivateTransactionsClient {
22784
22797
  systemProgram: SystemProgram.programId
22785
22798
  };
22786
22799
  accounts.validator = validator ?? null;
22787
- const signature = await this.baseProgram.methods.delegateUsernameDeposit(username, tokenMint).accountsPartial(accounts).rpc(rpcOptions);
22800
+ const delegationWatcher = waitForAccountOwnerChange(this.baseProgram.provider.connection, depositPda, DELEGATION_PROGRAM_ID);
22801
+ let signature;
22802
+ try {
22803
+ console.log("delegateUsernameDeposit Accounts:", prettyStringify(accounts));
22804
+ signature = await this.baseProgram.methods.delegateUsernameDeposit(username, tokenMint).accountsPartial(accounts).rpc(rpcOptions);
22805
+ console.log("delegateUsernameDeposit: waiting for depositPda owner to be DELEGATION_PROGRAM_ID on base connection...");
22806
+ await delegationWatcher.wait();
22807
+ await new Promise((resolve) => setTimeout(resolve, 3000));
22808
+ } catch (e) {
22809
+ await delegationWatcher.cancel();
22810
+ throw e;
22811
+ }
22788
22812
  return signature;
22789
22813
  }
22790
22814
  async undelegateDeposit(params) {
@@ -23002,7 +23026,6 @@ class LoyalPrivateTransactionsClient {
23002
23026
  }
23003
23027
  async ensureNotDelegated(account, name, passNotExist) {
23004
23028
  const baseAccountInfo = await this.baseProgram.provider.connection.getAccountInfo(account);
23005
- const ephemeralAccountInfo = await this.ephemeralProgram.provider.connection.getAccountInfo(account);
23006
23029
  if (!baseAccountInfo) {
23007
23030
  if (passNotExist) {
23008
23031
  return;
@@ -23010,6 +23033,7 @@ class LoyalPrivateTransactionsClient {
23010
23033
  const displayName2 = name ? `${name} - ` : "";
23011
23034
  throw new Error(`Account is not exists: ${displayName2}${account.toString()}`);
23012
23035
  }
23036
+ const ephemeralAccountInfo = await this.ephemeralProgram.provider.connection.getAccountInfo(account);
23013
23037
  const isDelegated = baseAccountInfo.owner.equals(DELEGATION_PROGRAM_ID);
23014
23038
  const displayName = name ? `${name} - ` : "";
23015
23039
  if (isDelegated) {
@@ -1820,7 +1820,9 @@ export type TelegramPrivateTransfer = {
1820
1820
  {
1821
1821
  "name": "usernameDeposit";
1822
1822
  "docs": [
1823
- "A deposit account for a telegram username and token mint."
1823
+ "A deposit account for a telegram username and token mint.",
1824
+ "",
1825
+ "Telegram username is always lowercase (a-z, 0-9 and underscores)"
1824
1826
  ];
1825
1827
  "type": {
1826
1828
  "kind": "struct";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loyal-labs/private-transactions",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
4
4
  "description": "SDK for Telegram-based private Solana deposits",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",