-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28aaf73
commit 2796f80
Showing
12 changed files
with
162 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
This file was deleted.
Oops, something went wrong.
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,75 @@ | ||
import * as beet from "@metaplex-foundation/beet"; | ||
import * as web3 from "@solana/web3.js"; | ||
import { | ||
DelegateAccounts, | ||
DELEGATION_PROGRAM_ID, | ||
} from "@magicblock-labs/delegation-program"; | ||
|
||
export const allowUndelegationStruct = new beet.BeetArgsStruct<{ | ||
instructionDiscriminator: number[] /* size: 8 */; | ||
}>( | ||
[["instructionDiscriminator", beet.uniformFixedSizeArray(beet.u8, 8)]], | ||
"allowUndelegationInstructionArgs" | ||
); | ||
|
||
export interface AllowUndelegationInstructionAccounts { | ||
delegatedAccount: web3.PublicKey; | ||
ownerProgram: web3.PublicKey; | ||
buffer?: web3.PublicKey; | ||
} | ||
|
||
export const allowUndelegateInstructionDiscriminator = [ | ||
255, 66, 82, 208, 247, 5, 210, 126, | ||
]; | ||
|
||
/** | ||
* Creates a Delegate instruction. | ||
*/ | ||
|
||
export function createAllowUndelegationInstruction( | ||
accounts: AllowUndelegationInstructionAccounts | ||
) { | ||
const [data] = allowUndelegationStruct.serialize({ | ||
instructionDiscriminator: allowUndelegateInstructionDiscriminator, | ||
}); | ||
|
||
const { delegationPda, delegationMetadata, bufferPda } = DelegateAccounts( | ||
accounts.delegatedAccount, | ||
accounts.ownerProgram | ||
); | ||
|
||
const keys: web3.AccountMeta[] = [ | ||
{ | ||
pubkey: accounts.delegatedAccount, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: delegationPda, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: delegationMetadata, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: bufferPda, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: new web3.PublicKey(DELEGATION_PROGRAM_ID), | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
]; | ||
|
||
const programId = accounts.ownerProgram; | ||
return new web3.TransactionInstruction({ | ||
programId, | ||
keys, | ||
data, | ||
}); | ||
} |
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
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 |
---|---|---|
|
@@ -84,10 +84,10 @@ | |
wrap-ansi "^8.1.0" | ||
wrap-ansi-cjs "npm:wrap-ansi@^7.0.0" | ||
|
||
"@magicblock-labs/[email protected].1": | ||
version "0.1.1" | ||
resolved "https://registry.yarnpkg.com/@magicblock-labs/delegation-program/-/delegation-program-0.1.1.tgz#71a5fb25ccf88ea7746ea70473fb109ff6b67433" | ||
integrity sha512-4He8V7jkrGy8MTp6qAz2h5y70+6y4cmvQc+7Km6B7WDLODlymPu9zZEl1/bmY24bOeKVKfrEEE7pDVa8qr3BwQ== | ||
"@magicblock-labs/[email protected].2": | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/@magicblock-labs/delegation-program/-/delegation-program-0.1.2.tgz#7b298398259d80a368eb9e91cb911e5a6e542391" | ||
integrity sha512-9EGtcBWGAXGCOjTJVyzxydMpM8GGk8QjzQlgpV0q96BAbmpEO9C6b/N3lvMRTR1FfDuBn43a3Pa5YEiHyUu8Eg== | ||
dependencies: | ||
"@metaplex-foundation/beet" "^0.7.2" | ||
"@solana/web3.js" "^1.92.3" | ||
|
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
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
Binary file not shown.