@ar.io/sdk 4.0.0-solana.30 → 4.0.0-solana.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/esm/solana/io-writeable.js +50 -20
- package/lib/esm/version.js +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -53,7 +53,7 @@ function toGeneratedFundingSourceSpec(s) {
|
|
|
53
53
|
import { getSyncAttributesInstruction } from '@ar.io/solana-contracts/ant';
|
|
54
54
|
import { getApprovePrimaryNameInstructionAsync, getCloseExpiredRequestInstruction, getCreateVaultInstructionAsync, getExtendVaultInstructionAsync, getIncreaseVaultInstructionAsync, getReleaseVaultInstructionAsync, getRemovePrimaryNameInstructionAsync, getRequestAndSetPrimaryNameFromFundingPlanInstructionAsync, getRequestAndSetPrimaryNameInstructionAsync, getRequestPrimaryNameFromFundingPlanInstructionAsync, getRequestPrimaryNameInstructionAsync, getRevokeVaultInstructionAsync, getVaultedTransferInstructionAsync, } from '@ar.io/solana-contracts/core';
|
|
55
55
|
import { getDelegationDecoder, getGatewayDecoder, } from '@ar.io/solana-contracts/gar';
|
|
56
|
-
import { Protocol, getAllowDelegateInstructionAsync, getCancelWithdrawalInstruction, getClaimDelegateFromDisabledGatewayInstructionAsync, getClaimDelegateFromLeavingGatewayInstructionAsync, getClaimWithdrawalInstructionAsync, getCloseDrainedWithdrawalInstruction, getCloseEmptyDelegationInstruction, getCloseEpochInstructionAsync, getCloseObservationInstructionAsync, getCreateEpochInstructionAsync, getDecreaseDelegateStakeInstructionAsync, getDecreaseOperatorStakeInstructionAsync, getDelegateStakeInstructionAsync, getDisallowDelegateInstructionAsync, getDistributeEpochInstructionAsync, getFinalizeGoneInstructionAsync, getIncreaseOperatorStakeInstructionAsync, getInstantWithdrawalInstructionAsync, getJoinNetworkInstructionAsync, getLeaveNetworkInstructionAsync, getPrescribeEpochInstructionAsync, getPruneGatewayInstructionAsync, getRedelegateStakeInstructionAsync, getSaveObservationsInstructionAsync, getSetAllowlistEnabledInstructionAsync, getTallyWeightsInstructionAsync, getUpdateGatewaySettingsInstructionAsync, } from '@ar.io/solana-contracts/gar';
|
|
56
|
+
import { Protocol, getAllowDelegateInstructionAsync, getCancelWithdrawalInstruction, getClaimDelegateFromDisabledGatewayInstructionAsync, getClaimDelegateFromLeavingGatewayInstructionAsync, getClaimWithdrawalInstructionAsync, getCloseDrainedWithdrawalInstruction, getCloseEmptyDelegationInstruction, getCloseEpochInstructionAsync, getCloseObservationInstructionAsync, getCreateEpochInstructionAsync, getDecreaseDelegateStakeInstructionAsync, getDecreaseOperatorStakeInstructionAsync, getDelegateStakeInstructionAsync, getDisallowDelegateInstructionAsync, getDistributeEpochInstructionAsync, getFinalizeGoneInstructionAsync, getIncreaseOperatorStakeInstructionAsync, getInstantWithdrawalInstructionAsync, getJoinNetworkInstructionAsync, getLeaveNetworkInstructionAsync, getPrescribeEpochInstructionAsync, getPruneGatewayInstructionAsync, getRedelegateStakeInstructionAsync, getSaveObservationsInstructionAsync, getSetAllowlistEnabledInstructionAsync, getTallyWeightsInstructionAsync, getUpdateGatewaySettingsInstructionAsync, getUpdateObserverAddressInstructionAsync, } from '@ar.io/solana-contracts/gar';
|
|
57
57
|
import { getTransferCheckedInstruction } from '@solana-program/token';
|
|
58
58
|
import { ARIO_ANT_PROGRAM_ID, TOKEN_DECIMALS } from './constants.js';
|
|
59
59
|
import { SolanaARIOReadable } from './io-readable.js';
|
|
@@ -591,25 +591,50 @@ export class SolanaARIOWriteable extends SolanaARIOReadable {
|
|
|
591
591
|
return { id: sig };
|
|
592
592
|
}
|
|
593
593
|
async updateGatewaySettings(params, _options) {
|
|
594
|
-
const
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
: null,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
594
|
+
const ixs = [];
|
|
595
|
+
// Settings fields (label, fqdn, port, etc.) — only emit when at least one
|
|
596
|
+
// non-observer field is provided so we don't send a no-op instruction.
|
|
597
|
+
const { observerAddress: _observer, ...settingsFields } = params;
|
|
598
|
+
if (Object.keys(settingsFields).length > 0) {
|
|
599
|
+
const settingsIx = await getUpdateGatewaySettingsInstructionAsync(await this.withGarDefaults({
|
|
600
|
+
operator: this.signer,
|
|
601
|
+
label: params.label ?? null,
|
|
602
|
+
fqdn: params.fqdn ?? null,
|
|
603
|
+
port: params.port ?? null,
|
|
604
|
+
// Codama exposes `protocol` as Option<Protocol>. We only ever updated
|
|
605
|
+
// the URL parts above, so leave protocol untouched (None).
|
|
606
|
+
protocol: null,
|
|
607
|
+
properties: params.properties ?? null,
|
|
608
|
+
note: params.note ?? null,
|
|
609
|
+
allowDelegatedStaking: typeof params.allowDelegatedStaking === 'boolean'
|
|
610
|
+
? params.allowDelegatedStaking
|
|
611
|
+
: null,
|
|
612
|
+
delegateRewardShareRatio: params.delegateRewardShareRatio ?? null,
|
|
613
|
+
minDelegateStake: params.minDelegatedStake !== undefined
|
|
614
|
+
? BigInt(params.minDelegatedStake)
|
|
615
|
+
: null,
|
|
616
|
+
}), { programAddress: this.garProgram });
|
|
617
|
+
ixs.push(settingsIx);
|
|
618
|
+
}
|
|
619
|
+
// Observer address update — uses a separate on-chain instruction that
|
|
620
|
+
// swaps the observer lookup PDA from old → new.
|
|
621
|
+
if (params.observerAddress !== undefined) {
|
|
622
|
+
const newObserver = address(params.observerAddress);
|
|
623
|
+
const gateway = await this.getGateway({
|
|
624
|
+
address: this.signer.address,
|
|
625
|
+
});
|
|
626
|
+
const oldObserver = address(gateway.observerAddress);
|
|
627
|
+
const [oldObserverLookupPda] = await getObserverLookupPDA(oldObserver, this.garProgram);
|
|
628
|
+
const [newObserverLookupPda] = await getObserverLookupPDA(newObserver, this.garProgram);
|
|
629
|
+
const observerIx = await getUpdateObserverAddressInstructionAsync(await this.withGarDefaults({
|
|
630
|
+
operator: this.signer,
|
|
631
|
+
oldObserverLookup: oldObserverLookupPda,
|
|
632
|
+
newObserverLookup: newObserverLookupPda,
|
|
633
|
+
newObserver,
|
|
634
|
+
}), { programAddress: this.garProgram });
|
|
635
|
+
ixs.push(observerIx);
|
|
636
|
+
}
|
|
637
|
+
const sig = await this.sendTransaction(ixs, 1_000_000);
|
|
613
638
|
return { id: sig };
|
|
614
639
|
}
|
|
615
640
|
async increaseOperatorStake(params, _options) {
|
|
@@ -670,6 +695,11 @@ export class SolanaARIOWriteable extends SolanaARIOReadable {
|
|
|
670
695
|
amount,
|
|
671
696
|
}), { programAddress: this.garProgram });
|
|
672
697
|
const sig = await this.sendTransaction([ix], 1_000_000);
|
|
698
|
+
if (!params.instant) {
|
|
699
|
+
return { id: sig };
|
|
700
|
+
}
|
|
701
|
+
// Instant boolean on decrease delegated stake (vs protected exit vault) is not currently supported by the contract — Instead we call InstantWithdrawal after creating the withdrawal, which achieves the same effect but requires two transactions. The protected exit vault is still created in the first transaction, but will be empty and can be ignored when instant = true.
|
|
702
|
+
await this.instantWithdrawal({ vaultId: nextId.toString() }, _options);
|
|
673
703
|
return { id: sig };
|
|
674
704
|
}
|
|
675
705
|
async instantWithdrawal(params, _options) {
|
package/lib/esm/version.js
CHANGED
package/lib/types/version.d.ts
CHANGED