Skip to content

Commit

Permalink
Init account if pledging to community without an account (#394)
Browse files Browse the repository at this point in the history
  • Loading branch information
filipzeta authored May 14, 2024
1 parent ae5be2b commit cfdaac0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Version changes are pinned to SDK releases.
## [1.31.0]

- Add rndr, fix oracle loading with dummy wallet and revert some pyth changes for stale prices. ([#396](https://github.com/zetamarkets/sdk/pull/396))
- Add account creation ixs to chooseAirdropCommunity ([#394](https://github.com/zetamarkets/sdk/pull/394))

## [1.30.0]

Expand Down
23 changes: 23 additions & 0 deletions src/cross-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,29 @@ export class CrossClient {
this.delegatedCheck();
let tx = new Transaction();

if (this._accountManager === null) {
console.log(
"User has no cross margin account manager. Creating account manager..."
);
tx.add(
instructions.initializeCrossMarginAccountManagerV2Ix(
this._accountManagerAddress,
this._provider.wallet.publicKey
)
);
}

if (this._account === null) {
console.log("User has no cross margin account. Creating account...");
tx.add(
instructions.initializeCrossMarginAccountIx(
this._accountAddress,
this._accountManagerAddress,
this._provider.wallet.publicKey
)
);
}

tx.add(
instructions.chooseAirdropCommunityIx(
community,
Expand Down

0 comments on commit cfdaac0

Please sign in to comment.