Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use anchor's BpfLoaderUpgradeable when available #222

Open
archseer opened this issue Feb 21, 2022 · 0 comments
Open

Use anchor's BpfLoaderUpgradeable when available #222

archseer opened this issue Feb 21, 2022 · 0 comments
Labels
gauntlet javascript Pull requests that update Javascript code

Comments

@archseer
Copy link
Collaborator

coral-xyz/anchor#1480

export const makeRawUpgradeTransaction = async (
signer: PublicKey,
contractId: CONTRACT_LIST,
bufferAccount: string,
) => {
const contract = getContract(contractId, '')
const programId = new PublicKey(contract.programId)
const [programDataKey, _nonce] = await PublicKey.findProgramAddress(
[programId.toBuffer()],
UPGRADEABLE_BPF_LOADER_PROGRAM_ID,
)
const buffer = new PublicKey(bufferAccount)
const data = encodeInstruction({ Upgrade: {} })
const keys: AccountMeta[] = [
{ pubkey: programDataKey, isSigner: false, isWritable: true },
{ pubkey: programId, isSigner: false, isWritable: true },
{ pubkey: buffer, isSigner: false, isWritable: true },
{ pubkey: signer, isSigner: false, isWritable: true },
{ pubkey: SYSVAR_RENT_PUBKEY, isSigner: false, isWritable: false },
{ pubkey: SYSVAR_CLOCK_PUBKEY, isSigner: false, isWritable: false },
{ pubkey: signer, isSigner: true, isWritable: false },
]
const rawTx: TransactionInstruction = {
data,
keys,
programId: UPGRADEABLE_BPF_LOADER_PROGRAM_ID,
}
return [rawTx]
}
can be simplified away by https://github.com/project-serum/anchor/pull/1480/files#diff-cdc243d74ffea2ca7a80b1e930b6f013f58c0c95c96d0d513c31e4425fa807f7R269-R294

@archseer archseer added the javascript Pull requests that update Javascript code label Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gauntlet javascript Pull requests that update Javascript code
Projects
None yet
Development

No branches or pull requests

2 participants