Skip to content

Commit

Permalink
Rename authority to upgradeAuthority
Browse files Browse the repository at this point in the history
  • Loading branch information
ml-james committed Sep 18, 2024
1 parent 2ba22fd commit b585ce4
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@ public static BpfLoaderUpgradeableProgram factory(final TransactionBuilder tb)
/**
* Sets the upgrade authority for a given program address.
*
* @param programAddress The public key of the program whose upgrade authority is being changed.
* @param currentAuthorityAddress The current authority's public key.
* @param maybeNewAuthorityAddress An optional public key for the new authority. If not present, no new authority is set.
* @param programAddress The public key of the program whose upgrade authority is being changed.
* @param currentUpgradeAuthorityAddress The current upgrade authority's public key.
* @param maybeNewUpgradeAuthorityAddress An optional public key for the new upgrade authority. If not present, no new upgrade authority is set.
* @return The current instance of {@code BpfLoaderUpgradeableProgram} to allow method chaining.
*/
public BpfLoaderUpgradeableProgram setUpgradeAuthority(
final PublicKey programAddress,
final PublicKey currentAuthorityAddress,
final Optional<PublicKey> maybeNewAuthorityAddress)
final PublicKey currentUpgradeAuthorityAddress,
final Optional<PublicKey> maybeNewUpgradeAuthorityAddress)
{
tb.append(ib ->
{
ib.program(PROGRAM_ACCOUNT)
.account(deriveAddress(programAddress).programId(), false, true)
.account(currentAuthorityAddress, true, false);
maybeNewAuthorityAddress.ifPresent(newAuthorityAddress -> ib.account(newAuthorityAddress, false, false));
.account(currentUpgradeAuthorityAddress, true, false);
maybeNewUpgradeAuthorityAddress.ifPresent(newUpgradeAuthorityAddress -> ib.account(newUpgradeAuthorityAddress, false, false));
ib.data(4, bb -> bb.order(ByteOrder.LITTLE_ENDIAN).putInt(SET_AUTHORITY_INSTRUCTION));
});

Expand Down
8 changes: 4 additions & 4 deletions src/test-support/java/com/lmax/solana4j/SolanaDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ public String setComputeUnits(final int computeUnitLimit, final long computeUnit

public String setUpgradeAuthority(
final PublicKey program,
final PublicKey oldAuthority,
final PublicKey newAuthority,
final PublicKey oldUpgradeAuthority,
final PublicKey newUpgradeAuthority,
final PublicKey payer,
final List<TestKeyPair> signers,
final List<AddressLookupTable> addressLookupTables)
Expand All @@ -378,8 +378,8 @@ public String setUpgradeAuthority(

final String transactionBlob = getTransactionFactory().setUpgradeAuthority(
program,
oldAuthority,
newAuthority,
oldUpgradeAuthority,
newUpgradeAuthority,
Solana.blockhash(blockhash.getBytes()),
payer,
signers,
Expand Down
20 changes: 10 additions & 10 deletions src/test-support/java/com/lmax/solana4j/SolanaNodeDsl.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,16 +608,16 @@ public void setUpgradeAuthority(final String... args)
final DslParams params = DslParams.create(
args,
new RequiredArg("program"),
new RequiredArg("oldAuthorityPublicKey"),
new RequiredArg("oldAuthorityPrivateKey"),
new RequiredArg("newAuthority"),
new RequiredArg("oldUpgradeAuthorityPublicKey"),
new RequiredArg("oldUpgradeAuthorityPrivateKey"),
new RequiredArg("newUpgradeAuthority"),
new RequiredArg("payer"),
new OptionalArg("addressLookupTables")
);

final String program = testContext.lookupOrLiteral(params.value("program"), TestDataType.TEST_PUBLIC_KEY);
final String oldAuthorityPublicKey = testContext.lookupOrLiteral(params.value("oldAuthorityPublicKey"), TestDataType.TEST_PUBLIC_KEY);
final String oldAuthorityPrivateKey = testContext.lookupOrLiteral(params.value("oldAuthorityPrivateKey"), TestDataType.TEST_KEY_PAIR);
final String oldUpgradeAuthorityPublicKey = testContext.lookupOrLiteral(params.value("oldUpgradeAuthorityPublicKey"), TestDataType.TEST_PUBLIC_KEY);
final String oldUpgradeAuthorityPrivateKey = testContext.lookupOrLiteral(params.value("oldUpgradeAuthorityPrivateKey"), TestDataType.TEST_KEY_PAIR);

final String newAuthority = testContext.lookupOrLiteral(params.value("newAuthority"), TestDataType.TEST_PUBLIC_KEY);

Expand All @@ -630,10 +630,10 @@ public void setUpgradeAuthority(final String... args)

final String transactionSignature = solanaDriver.setUpgradeAuthority(
Solana.account(Base58.decode(program)),
Solana.account(Base58.decode(oldAuthorityPublicKey)),
Solana.account(Base58.decode(oldUpgradeAuthorityPublicKey)),
Solana.account(Base58.decode(newAuthority)),
payer.getSolana4jPublicKey(),
List.of(payer, new TestKeyPair(oldAuthorityPublicKey, oldAuthorityPrivateKey)),
List.of(payer, new TestKeyPair(oldUpgradeAuthorityPublicKey, oldUpgradeAuthorityPrivateKey)),
addressLookupTables);

Waiter.waitFor(isNotNull(() -> solanaDriver.getTransactionResponse(transactionSignature).getTransaction()));
Expand All @@ -644,19 +644,19 @@ public void upgradeAuthority(final String... args)
final DslParams params = DslParams.create(
args,
new RequiredArg("address"),
new OptionalArg("authority")
new OptionalArg("upgradeAuthority")
);

final String address = testContext.lookupOrLiteral(params.value("address"), TestDataType.TEST_PUBLIC_KEY);
final String authority = testContext.lookupOrLiteral(params.value("authority"), TestDataType.TEST_PUBLIC_KEY);
final String upgradeAuthority = testContext.lookupOrLiteral(params.value("upgradeAuthority"), TestDataType.TEST_PUBLIC_KEY);

final ProgramDerivedAddress programDataAddress = BpfLoaderUpgradeableProgram.deriveAddress(Solana.account(Base58.decode(address)));

final AccountInfo accountInfo = Waiter.waitFor(isNotNull(() -> solanaDriver.getAccountInfo(new TestPublicKey(programDataAddress.address().bytes()))));

final byte[] accountInfoBytes = Base64.decode(accountInfo.getData().get(0));

assertThat(Base58.encode(Arrays.copyOfRange(accountInfoBytes, 13, 45))).isEqualTo(authority);
assertThat(Base58.encode(Arrays.copyOfRange(accountInfoBytes, 13, 45))).isEqualTo(upgradeAuthority);
}

private void waitForSlot(final long slot)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,8 +529,8 @@ public String setComputeUnits(final int computeUnitLimit, final long computeUnit
@Override
public String setUpgradeAuthority(
final PublicKey program,
final PublicKey oldAuthority,
final PublicKey newAuthority,
final PublicKey oldUpgradeAuthority,
final PublicKey newUpgradeAuthority,
final Blockhash blockhash,
final PublicKey payer,
final List<TestKeyPair> signers,
Expand All @@ -544,8 +544,8 @@ public String setUpgradeAuthority(
.instructions(legacyTransactionBuilder -> BpfLoaderUpgradeableProgram.factory(legacyTransactionBuilder)
.setUpgradeAuthority(
program,
oldAuthority,
Optional.of(newAuthority))
oldUpgradeAuthority,
Optional.of(newUpgradeAuthority))
)
.payer(payer)
.seal()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ String setComputeUnits(

String setUpgradeAuthority(
PublicKey program,
PublicKey oldAuthority,
PublicKey newAuthority,
PublicKey oldUpgradeAuthority,
PublicKey newUpgradeAuthority,
Blockhash blockhash,
PublicKey payer,
List<TestKeyPair> signers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ public String setComputeUnits(
@Override
public String setUpgradeAuthority(
final PublicKey program,
final PublicKey oldAuthority,
final PublicKey newAuthority,
final PublicKey oldUpgradeAuthority,
final PublicKey newUpgradeAuthority,
final Blockhash blockhash,
final PublicKey payer,
final List<TestKeyPair> signers,
Expand All @@ -546,8 +546,8 @@ public String setUpgradeAuthority(
.instructions(versionedTransactionBuilder -> BpfLoaderUpgradeableProgram.factory(versionedTransactionBuilder)
.setUpgradeAuthority(
program,
oldAuthority,
Optional.of(newAuthority))
oldUpgradeAuthority,
Optional.of(newUpgradeAuthority))
)
.payer(payer)
.lookups(addressLookupTables)
Expand Down

0 comments on commit b585ce4

Please sign in to comment.