-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
c1704f4
commit c64972f
Showing
23 changed files
with
688 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
packages/lazy-distributor-sdk/src/functions/updateCompressionDestination.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { Idl, Program } from "@coral-xyz/anchor"; | ||
import { LazyDistributor } from "@helium/idls/lib/types/lazy_distributor"; | ||
import { Asset, AssetProof, proofArgsAndAccounts } from "@helium/spl-utils"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { recipientKey } from "../pdas"; | ||
|
||
export async function updateCompressionDestination<IDL extends Idl>({ | ||
program, | ||
assetId, | ||
lazyDistributor, | ||
rewardsMint, | ||
payer, | ||
destination, | ||
...rest | ||
}: { | ||
program: Program<LazyDistributor>; | ||
assetId: PublicKey; | ||
rewardsMint?: PublicKey; | ||
assetEndpoint?: string; | ||
lazyDistributor: PublicKey; | ||
owner?: PublicKey; | ||
payer?: PublicKey; | ||
destination: PublicKey | null; | ||
getAssetFn?: (url: string, assetId: PublicKey) => Promise<Asset | undefined>; | ||
getAssetProofFn?: ( | ||
url: string, | ||
assetId: PublicKey | ||
) => Promise<AssetProof | undefined>; | ||
}) { | ||
const { | ||
asset: { | ||
ownership: { owner }, | ||
}, | ||
args, | ||
accounts, | ||
remainingAccounts, | ||
} = await proofArgsAndAccounts({ | ||
connection: program.provider.connection, | ||
assetId, | ||
...rest, | ||
}); | ||
|
||
return program.methods | ||
.updateCompressionDestinationV0({ | ||
...args, | ||
}) | ||
.accounts({ | ||
...accounts, | ||
owner, | ||
recipient: recipientKey(lazyDistributor, assetId)[0], | ||
destination: destination == null ? PublicKey.default : destination, | ||
}) | ||
.remainingAccounts(remainingAccounts); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.