|
1 | 1 | import { |
2 | | - BN, |
3 | 2 | Program, |
4 | 3 | parseIdlErrors, |
5 | 4 | translateError, |
@@ -33,6 +32,7 @@ import { |
33 | 32 | VAA, |
34 | 33 | keccak256, |
35 | 34 | } from "@wormhole-foundation/sdk-definitions"; |
| 35 | +import BN from "bn.js"; |
36 | 36 |
|
37 | 37 | import { Ntt } from "@wormhole-foundation/sdk-definitions-ntt"; |
38 | 38 |
|
@@ -93,6 +93,7 @@ export namespace NTT { |
93 | 93 | ["inbox_item", Ntt.messageDigest(chain, nttMessage)], |
94 | 94 | programId |
95 | 95 | ); |
| 96 | + const upgradeLock = (): PublicKey => derivePda("upgrade_lock", programId); |
96 | 97 | const outboxRateLimitAccount = (): PublicKey => |
97 | 98 | derivePda("outbox_rate_limit", programId); |
98 | 99 | const tokenAuthority = (): PublicKey => |
@@ -131,6 +132,7 @@ export namespace NTT { |
131 | 132 | outboxRateLimitAccount, |
132 | 133 | inboxRateLimitAccount, |
133 | 134 | inboxItemAccount, |
| 135 | + upgradeLock, |
134 | 136 | sessionAuthority, |
135 | 137 | tokenAuthority, |
136 | 138 | pendingTokenAuthority, |
@@ -720,19 +722,66 @@ export namespace NTT { |
720 | 722 | return transferIx; |
721 | 723 | } |
722 | 724 |
|
| 725 | + export async function createTransferOwnershipOneStepUncheckedInstruction( |
| 726 | + program: Program<NttBindings.NativeTokenTransfer<IdlVersion>>, |
| 727 | + args: { |
| 728 | + owner: PublicKey; |
| 729 | + newOwner: PublicKey; |
| 730 | + }, |
| 731 | + pdas?: Pdas |
| 732 | + ) { |
| 733 | + pdas = pdas ?? NTT.pdas(program.programId); |
| 734 | + return program.methods |
| 735 | + .transferOwnershipOneStepUnchecked() |
| 736 | + .accountsStrict({ |
| 737 | + config: pdas.configAccount(), |
| 738 | + owner: args.owner, |
| 739 | + newOwner: args.newOwner, |
| 740 | + upgradeLock: pdas.upgradeLock(), |
| 741 | + programData: programDataAddress(program.programId), |
| 742 | + bpfLoaderUpgradeableProgram: BPF_LOADER_UPGRADEABLE_PROGRAM_ID, |
| 743 | + }) |
| 744 | + .instruction(); |
| 745 | + } |
| 746 | + |
723 | 747 | export async function createTransferOwnershipInstruction( |
724 | 748 | program: Program<NttBindings.NativeTokenTransfer<IdlVersion>>, |
725 | 749 | args: { |
| 750 | + owner: PublicKey; |
726 | 751 | newOwner: PublicKey; |
727 | 752 | }, |
728 | 753 | pdas?: Pdas |
729 | 754 | ) { |
730 | 755 | pdas = pdas ?? NTT.pdas(program.programId); |
731 | 756 | return program.methods |
732 | 757 | .transferOwnership() |
733 | | - .accounts({ |
| 758 | + .accountsStrict({ |
734 | 759 | config: pdas.configAccount(), |
| 760 | + owner: args.owner, |
735 | 761 | newOwner: args.newOwner, |
| 762 | + upgradeLock: pdas.upgradeLock(), |
| 763 | + programData: programDataAddress(program.programId), |
| 764 | + bpfLoaderUpgradeableProgram: BPF_LOADER_UPGRADEABLE_PROGRAM_ID, |
| 765 | + }) |
| 766 | + .instruction(); |
| 767 | + } |
| 768 | + |
| 769 | + export async function createClaimOwnershipInstruction( |
| 770 | + program: Program<NttBindings.NativeTokenTransfer<IdlVersion>>, |
| 771 | + args: { |
| 772 | + newOwner: PublicKey; |
| 773 | + }, |
| 774 | + pdas?: Pdas |
| 775 | + ) { |
| 776 | + pdas = pdas ?? NTT.pdas(program.programId); |
| 777 | + return program.methods |
| 778 | + .claimOwnership() |
| 779 | + .accountsStrict({ |
| 780 | + config: pdas.configAccount(), |
| 781 | + newOwner: args.newOwner, |
| 782 | + upgradeLock: pdas.upgradeLock(), |
| 783 | + programData: programDataAddress(program.programId), |
| 784 | + bpfLoaderUpgradeableProgram: BPF_LOADER_UPGRADEABLE_PROGRAM_ID, |
736 | 785 | }) |
737 | 786 | .instruction(); |
738 | 787 | } |
@@ -1035,7 +1084,7 @@ export namespace NTT { |
1035 | 1084 | .instruction(); |
1036 | 1085 | } |
1037 | 1086 |
|
1038 | | - export async function setInboundLimit( |
| 1087 | + export async function createSetInboundLimitInstruction( |
1039 | 1088 | program: Program<NttBindings.NativeTokenTransfer<IdlVersion>>, |
1040 | 1089 | args: { |
1041 | 1090 | owner: PublicKey; |
|
0 commit comments