• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

bmresearch / Solnet / 13115839865

03 Feb 2025 02:33PM UTC coverage: 71.215% (-0.9%) from 72.123%
13115839865

push

github

web-flow
Merge pull request #478 from kingsznhone/master

Added Address lookup table Instruction & removed bouncy castle + deprecated code cleanup

1113 of 1754 branches covered (63.45%)

Branch coverage included in aggregate %.

22 of 121 new or added lines in 10 files covered. (18.18%)

1 existing line in 1 file now uncovered.

5114 of 6990 relevant lines covered (73.16%)

1208320.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Solnet.Programs/AddressLookupTableProgram.cs
1
using System.Collections.Generic;
2
using Solnet.Rpc.Models;
3
using Solnet.Wallet;
4

5
namespace Solnet.Programs
6
{
7
    public static class AddressLookupTableProgram
8
    {
9
        /// <summary>
10
        /// The public key of the ATL Program.
11
        /// </summary>
NEW
12
        public static readonly PublicKey ProgramIdKey = new("AddressLookupTab1e1111111111111111111111111");
×
13

14
        /// <summary>
15
        /// The program's name.
16
        /// </summary>
17
        private const string ProgramName = "Address Lookup Table Program";
18

19
        /// <summary>
20
        /// Create New Address Lookup Table Instruction
21
        /// </summary>
22
        /// <param name="Authority"></param>
23
        /// <param name="Payer"></param>
24
        /// <param name="RecentSlot"></param>
25
        /// <returns></returns>
26
        public static TransactionInstruction CreateAddressLookupTable(
27
            PublicKey Authority, PublicKey Payer, PublicKey ALT,byte bump, ulong RecentSlot)
28
        {
29
            //byte[] recentSlotBytes = BitConverter.GetBytes(RecentSlot);
30
            //byte[] seed = Authority.KeyBytes.Concat(recentSlotBytes).ToArray();
31
            //PublicKey.TryFindProgramAddress(new List<byte[]> { seed }, ProgramIdKey, out PublicKey ALTaddress, out byte bump);
32

NEW
33
            List<AccountMeta> keys = new()
×
NEW
34
            {
×
NEW
35
                AccountMeta.Writable(ALT, false),
×
NEW
36
                AccountMeta.ReadOnly(Authority, false),
×
NEW
37
                AccountMeta.Writable(Payer, true),
×
NEW
38
                AccountMeta.ReadOnly(SystemProgram.ProgramIdKey, false)
×
NEW
39
            };
×
NEW
40
            return new TransactionInstruction
×
NEW
41
            {
×
NEW
42
                ProgramId = ProgramIdKey.KeyBytes,
×
NEW
43
                Keys = keys,
×
NEW
44
                Data = AddressLookupTableProgramData.EncodeCreateAddressLookupTableData(RecentSlot, bump)
×
NEW
45
            };
×
46
        }
47

48
        /// <summary>
49
        /// Freeze Lookup Table Instruction
50
        /// </summary>
51
        /// <param name="LookupTable"></param>
52
        /// <param name="Authority"></param>
53
        /// <returns></returns>
54
        public static TransactionInstruction FreezeLookupTable(PublicKey LookupTable, PublicKey Authority)
55
        {
NEW
56
            List<AccountMeta> keys = new()
×
NEW
57
            {
×
NEW
58
                AccountMeta.Writable(LookupTable, false),
×
NEW
59
                AccountMeta.ReadOnly(Authority, true)
×
NEW
60
            };
×
NEW
61
            return new TransactionInstruction
×
NEW
62
            {
×
NEW
63
                ProgramId = ProgramIdKey.KeyBytes,
×
NEW
64
                Keys = keys,
×
NEW
65
                Data = AddressLookupTableProgramData.EncodeFreezeLookupTableData()
×
NEW
66
            };
×
67
        }
68

69
        /// <summary>
70
        /// Extend Lookup Table Instruction
71
        /// </summary>
72
        /// <param name="LookupTable"></param>
73
        /// <param name="Authority"></param>
74
        /// <param name="Payer"></param>
75
        /// <param name="keys"></param>
76
        /// <returns></returns>
77
        public static TransactionInstruction ExtendLookupTable(PublicKey LookupTable, PublicKey Authority, PublicKey Payer, List<PublicKey> keys)
78
        {
NEW
79
            List<AccountMeta> meta = new()
×
NEW
80
            {
×
NEW
81
                AccountMeta.Writable(LookupTable, false),
×
NEW
82
                AccountMeta.ReadOnly(Authority, true),
×
NEW
83
                AccountMeta.Writable(Payer, true),
×
NEW
84
                AccountMeta.ReadOnly(SystemProgram.ProgramIdKey, false)
×
NEW
85
            };
×
NEW
86
            return new TransactionInstruction
×
NEW
87
            {
×
NEW
88
                ProgramId = ProgramIdKey.KeyBytes,
×
NEW
89
                Keys = meta,
×
NEW
90
                Data = AddressLookupTableProgramData.EncodeExtendLookupTableData((ulong)keys.Count, keys)
×
NEW
91
            };
×
92
        }
93

94
        /// <summary>
95
        /// Deactivate  Lookup Table Instruction
96
        /// </summary>
97
        /// <param name="LookupTable"></param>
98
        /// <param name="Authority"></param>
99
        /// <returns></returns>
100
        public static TransactionInstruction DeactivateLookupTable(PublicKey LookupTable, PublicKey Authority)
101
        {
NEW
102
            List<AccountMeta> keys = new()
×
NEW
103
            {
×
NEW
104
                AccountMeta.Writable(LookupTable, false),
×
NEW
105
                AccountMeta.ReadOnly(Authority, true)
×
NEW
106
            };
×
NEW
107
            return new TransactionInstruction
×
NEW
108
            {
×
NEW
109
                ProgramId = ProgramIdKey.KeyBytes,
×
NEW
110
                Keys = keys,
×
NEW
111
                Data = AddressLookupTableProgramData.EncodeDeactivateLookupTableData()
×
NEW
112
            };
×
113
        }
114

115
        /// <summary>
116
        /// Close Lookup Table Instruction
117
        /// </summary>
118
        /// <param name="LookupTable"></param>
119
        /// <param name="Authority"></param>
120
        /// <param name="Recipient"></param>
121
        /// <returns></returns>
122
        public static TransactionInstruction CloseLookupTable(PublicKey LookupTable, PublicKey Authority, PublicKey Recipient)
123
        {
NEW
124
            List<AccountMeta> keys = new()
×
NEW
125
            {
×
NEW
126
                AccountMeta.Writable(LookupTable, false),
×
NEW
127
                AccountMeta.ReadOnly(Authority, true),
×
NEW
128
                AccountMeta.Writable(Recipient, false)
×
NEW
129
            };
×
NEW
130
            return new TransactionInstruction
×
NEW
131
            {
×
NEW
132
                ProgramId = ProgramIdKey.KeyBytes,
×
NEW
133
                Keys = keys,
×
NEW
134
                Data = AddressLookupTableProgramData.EncodeCloseLookupTableData()
×
NEW
135
            };
×
136
        }
137

138

139
    }
140
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc