@@ -127,15 +127,15 @@ func ConvertEventSigFromProto(b []byte) (typesolana.EventSignature, error) {
127127
128128func ConvertEncodingTypeFromProto (e EncodingType ) typesolana.EncodingType {
129129 switch e {
130- case EncodingType_ENCODING_BASE58 :
130+ case EncodingType_ENCODING_TYPE_BASE58 :
131131 return typesolana .EncodingBase58
132- case EncodingType_ENCODING_BASE64 :
132+ case EncodingType_ENCODING_TYPE_BASE64 :
133133 return typesolana .EncodingBase64
134- case EncodingType_ENCODING_BASE64_ZST :
134+ case EncodingType_ENCODING_TYPE_BASE64_ZSTD :
135135 return typesolana .EncodingBase64Zstd
136- case EncodingType_ENCODING_JSON :
136+ case EncodingType_ENCODING_TYPE_JSON :
137137 return typesolana .EncodingJSON
138- case EncodingType_ENCODING_JSON_PARSED :
138+ case EncodingType_ENCODING_TYPE_JSON_PARSED :
139139 return typesolana .EncodingJSONParsed
140140 default :
141141 return typesolana .EncodingType ("" )
@@ -145,27 +145,27 @@ func ConvertEncodingTypeFromProto(e EncodingType) typesolana.EncodingType {
145145func ConvertEncodingTypeToProto (e typesolana.EncodingType ) EncodingType {
146146 switch e {
147147 case typesolana .EncodingBase64 :
148- return EncodingType_ENCODING_BASE64
148+ return EncodingType_ENCODING_TYPE_BASE64
149149 case typesolana .EncodingBase58 :
150- return EncodingType_ENCODING_BASE58
150+ return EncodingType_ENCODING_TYPE_BASE58
151151 case typesolana .EncodingBase64Zstd :
152- return EncodingType_ENCODING_BASE64_ZST
152+ return EncodingType_ENCODING_TYPE_BASE64_ZSTD
153153 case typesolana .EncodingJSONParsed :
154- return EncodingType_ENCODING_JSON_PARSED
154+ return EncodingType_ENCODING_TYPE_JSON_PARSED
155155 case typesolana .EncodingJSON :
156- return EncodingType_ENCODING_JSON
156+ return EncodingType_ENCODING_TYPE_JSON
157157 default :
158- return EncodingType_ENCODING_NONE
158+ return EncodingType_ENCODING_TYPE_NONE
159159 }
160160}
161161
162162func ConvertCommitmentFromProto (c CommitmentType ) typesolana.CommitmentType {
163163 switch c {
164- case CommitmentType_COMMITMENT_CONFIRMED :
164+ case CommitmentType_COMMITMENT_TYPE_CONFIRMED :
165165 return typesolana .CommitmentConfirmed
166- case CommitmentType_COMMITMENT_FINALIZED :
166+ case CommitmentType_COMMITMENT_TYPE_FINALIZED :
167167 return typesolana .CommitmentFinalized
168- case CommitmentType_COMMITMENT_PROCESSED :
168+ case CommitmentType_COMMITMENT_TYPE_PROCESSED :
169169 return typesolana .CommitmentProcessed
170170 default :
171171 return typesolana .CommitmentType ("" )
@@ -175,36 +175,36 @@ func ConvertCommitmentFromProto(c CommitmentType) typesolana.CommitmentType {
175175func ConvertCommitmentToProto (c typesolana.CommitmentType ) CommitmentType {
176176 switch c {
177177 case typesolana .CommitmentFinalized :
178- return CommitmentType_COMMITMENT_FINALIZED
178+ return CommitmentType_COMMITMENT_TYPE_FINALIZED
179179 case typesolana .CommitmentConfirmed :
180- return CommitmentType_COMMITMENT_CONFIRMED
180+ return CommitmentType_COMMITMENT_TYPE_CONFIRMED
181181 case typesolana .CommitmentProcessed :
182- return CommitmentType_COMMITMENT_PROCESSED
182+ return CommitmentType_COMMITMENT_TYPE_PROCESSED
183183 default :
184- return CommitmentType_COMMITMENT_NONE
184+ return CommitmentType_COMMITMENT_TYPE_NONE
185185 }
186186}
187187
188188func ConvertConfirmationStatusToProto (c typesolana.ConfirmationStatusType ) ConfirmationStatusType {
189189 switch c {
190190 case typesolana .ConfirmationStatusFinalized :
191- return ConfirmationStatusType_CONFIRMATION_FINALIZED
191+ return ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_FINALIZED
192192 case typesolana .ConfirmationStatusConfirmed :
193- return ConfirmationStatusType_CONFIRMATION_CONFIRMED
193+ return ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_CONFIRMED
194194 case typesolana .ConfirmationStatusProcessed :
195- return ConfirmationStatusType_CONFIRMATION_PROCESSED
195+ return ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_PROCESSED
196196 default :
197- return ConfirmationStatusType_CONFIRMATION_NONE
197+ return ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_NONE
198198 }
199199}
200200
201201func ConvertConfirmationStatusFromProto (c ConfirmationStatusType ) typesolana.ConfirmationStatusType {
202202 switch c {
203- case ConfirmationStatusType_CONFIRMATION_CONFIRMED :
203+ case ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_CONFIRMED :
204204 return typesolana .ConfirmationStatusConfirmed
205- case ConfirmationStatusType_CONFIRMATION_FINALIZED :
205+ case ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_FINALIZED :
206206 return typesolana .ConfirmationStatusFinalized
207- case ConfirmationStatusType_CONFIRMATION_PROCESSED :
207+ case ConfirmationStatusType_CONFIRMATION_STATUS_TYPE_PROCESSED :
208208 return typesolana .ConfirmationStatusProcessed
209209 default :
210210 return typesolana .ConfirmationStatusType ("" )
@@ -268,10 +268,8 @@ func ConvertAccountFromProto(p *Account) (*typesolana.Account, error) {
268268 if err != nil {
269269 return nil , fmt .Errorf ("owner: %w" , err )
270270 }
271- data , err := ConvertDataBytesOrJSONFromProto (p .Data )
272- if err != nil {
273- return nil , fmt .Errorf ("data: %w" , err )
274- }
271+ data := ConvertDataBytesOrJSONFromProto (p .Data )
272+
275273 return & typesolana.Account {
276274 Lamports : p .Lamports ,
277275 Owner : owner ,
@@ -296,26 +294,42 @@ func ConvertAccountToProto(a *typesolana.Account) *Account {
296294 }
297295}
298296
299- func ConvertDataBytesOrJSONFromProto (p * DataBytesOrJSON ) ( * typesolana.DataBytesOrJSON , error ) {
297+ func ConvertDataBytesOrJSONFromProto (p * DataBytesOrJSON ) * typesolana.DataBytesOrJSON {
300298 if p == nil {
301- return nil , nil
299+ return nil
302300 }
303- return & typesolana.DataBytesOrJSON {
304- RawDataEncoding : ConvertEncodingTypeFromProto (p .RawDataEncoding ),
305- AsDecodedBinary : p .AsDecodedBinary ,
306- AsJSON : p .AsJson ,
307- }, nil
301+ switch t := p .GetBody ().(type ) {
302+ case * DataBytesOrJSON_Raw :
303+ return & typesolana.DataBytesOrJSON {
304+ AsDecodedBinary : t .Raw ,
305+ RawDataEncoding : ConvertEncodingTypeFromProto (p .Encoding ),
306+ }
307+ case * DataBytesOrJSON_Json :
308+ return & typesolana.DataBytesOrJSON {
309+ AsJSON : t .Json ,
310+ RawDataEncoding : ConvertEncodingTypeFromProto (p .Encoding ),
311+ }
312+ }
313+
314+ return nil
308315}
309316
310317func ConvertDataBytesOrJSONToProto (d * typesolana.DataBytesOrJSON ) * DataBytesOrJSON {
311318 if d == nil {
312319 return nil
313320 }
314- return & DataBytesOrJSON {
315- RawDataEncoding : ConvertEncodingTypeToProto (d .RawDataEncoding ),
316- AsDecodedBinary : d .AsDecodedBinary ,
317- AsJson : d .AsJSON ,
321+
322+ ret := & DataBytesOrJSON {
323+ Encoding : ConvertEncodingTypeToProto (d .RawDataEncoding ),
318324 }
325+ if d .AsJSON != nil {
326+ ret .Body = & DataBytesOrJSON_Json {Json : d .AsJSON }
327+ return ret
328+ }
329+
330+ ret .Body = & DataBytesOrJSON_Raw {Raw : d .AsDecodedBinary }
331+
332+ return ret
319333}
320334
321335func ConvertGetAccountInfoOptsFromProto (p * GetAccountInfoOpts ) * typesolana.GetAccountInfoOpts {
@@ -419,6 +433,7 @@ func ConvertCompiledInstructionFromProto(p *CompiledInstruction) typesolana.Comp
419433 for i , a := range p .Accounts {
420434 accts [i ] = uint16 (a )
421435 }
436+
422437 return typesolana.CompiledInstruction {
423438 ProgramIDIndex : uint16 (p .ProgramIdIndex ),
424439 Accounts : accts ,
@@ -681,7 +696,7 @@ func ConvertTransactionMetaFromProto(p *TransactionMeta) (*typesolana.Transactio
681696 LogMessages : p .LogMessages ,
682697 LoadedAddresses : la ,
683698 ReturnData : * ret ,
684- ComputeUnitsConsumed : ptrUint64 ( p .ComputeUnitsConsumed ) ,
699+ ComputeUnitsConsumed : p .ComputeUnitsConsumed ,
685700 }
686701 return meta , nil
687702}
@@ -717,7 +732,7 @@ func ConvertTransactionMetaToProto(m *typesolana.TransactionMeta) *TransactionMe
717732 InnerInstructions : inner ,
718733 LoadedAddresses : ConvertLoadedAddressesToProto (m .LoadedAddresses ),
719734 ReturnData : ConvertReturnDataToProto (& m .ReturnData ),
720- ComputeUnitsConsumed : cuc ,
735+ ComputeUnitsConsumed : & cuc ,
721736 }
722737}
723738
@@ -775,8 +790,8 @@ func ConvertGetTransactionReplyFromProto(p *GetTransactionReply) (*typesolana.Ge
775790 return nil , err
776791 }
777792 var bt * typesolana.UnixTimeSeconds
778- if p .BlockTime != 0 {
779- bt = ptrUnix (typesolana .UnixTimeSeconds (p .BlockTime ))
793+ if p .BlockTime != nil {
794+ bt = ptrUnix (typesolana .UnixTimeSeconds (* p .BlockTime ))
780795 }
781796
782797 return & typesolana.GetTransactionReply {
@@ -801,7 +816,7 @@ func ConvertGetTransactionReplyToProto(r *typesolana.GetTransactionReply) *GetTr
801816 }
802817 return & GetTransactionReply {
803818 Slot : r .Slot ,
804- BlockTime : bt ,
819+ BlockTime : & bt ,
805820 Transaction : tx ,
806821 Meta : ConvertTransactionMetaToProto (r .Meta ),
807822 }
@@ -887,9 +902,10 @@ func ConvertGetBlockOptsReplyFromProto(p *GetBlockReply) (*typesolana.GetBlockRe
887902 }
888903
889904 var bt * solana.UnixTimeSeconds
890- if p .BlockTime != 0 {
891- bt = ptrUnix (typesolana .UnixTimeSeconds (p .BlockTime ))
905+ if p .BlockTime != nil {
906+ bt = ptrUnix (typesolana .UnixTimeSeconds (* p .BlockTime ))
892907 }
908+
893909 return & typesolana.GetBlockReply {
894910 Blockhash : hash ,
895911 PreviousBlockhash : prev ,
@@ -903,14 +919,16 @@ func ConvertGetBlockReplyToProto(r *typesolana.GetBlockReply) *GetBlockReply {
903919 if r == nil {
904920 return nil
905921 }
906- var bt int64
922+ var bt * int64
907923 if r .BlockTime != nil {
908- bt = int64 (* r .BlockTime )
924+ t := int64 (* r .BlockTime )
925+ bt = & t
909926 }
910927 var bh uint64
911928 if r .BlockHeight != nil {
912929 bh = * r .BlockHeight
913930 }
931+
914932 return & GetBlockReply {
915933 Blockhash : r .Blockhash [:],
916934 PreviousBlockhash : r .PreviousBlockhash [:],
@@ -1001,7 +1019,7 @@ func ConvertGetMultipleAccountsReplyFromProto(p *GetMultipleAccountsWithOptsRepl
10011019 }
10021020 val := make ([]* typesolana.Account , 0 , len (p .Value ))
10031021 for _ , a := range p .Value {
1004- acc , err := ConvertAccountFromProto (a )
1022+ acc , err := ConvertAccountFromProto (a . Account )
10051023 if err != nil {
10061024 return nil , err
10071025 }
@@ -1016,10 +1034,11 @@ func ConvertGetMultipleAccountsReplyToProto(r *typesolana.GetMultipleAccountsRep
10161034 if r == nil {
10171035 return nil
10181036 }
1019- val := make ([]* Account , 0 , len (r .Value ))
1037+ val := make ([]* OptionalAccountWrapper , 0 , len (r .Value ))
10201038 for _ , a := range r .Value {
1021- val = append (val , ConvertAccountToProto (a ))
1039+ val = append (val , & OptionalAccountWrapper { Account : ConvertAccountToProto (a )} )
10221040 }
1041+
10231042 return & GetMultipleAccountsWithOptsReply {
10241043 Value : val ,
10251044 }
@@ -1051,7 +1070,7 @@ func ConvertGetSignatureStatusesReplyFromProto(p *GetSignatureStatusesReply) *ty
10511070 for _ , r := range p .Results {
10521071 out .Results = append (out .Results , typesolana.GetSignatureStatusesResult {
10531072 Slot : r .Slot ,
1054- Confirmations : ptrUint64 ( r .Confirmations ) ,
1073+ Confirmations : r .Confirmations ,
10551074 Err : r .Err ,
10561075 ConfirmationStatus : ConvertConfirmationStatusFromProto (r .ConfirmationStatus ),
10571076 })
@@ -1071,7 +1090,7 @@ func ConvertGetSignatureStatusesReplyToProto(r *typesolana.GetSignatureStatusesR
10711090 }
10721091 out .Results = append (out .Results , & GetSignatureStatusesResult {
10731092 Slot : r .Results [i ].Slot ,
1074- Confirmations : conf ,
1093+ Confirmations : ptrUint64 ( conf ) ,
10751094 Err : r .Results [i ].Err ,
10761095 ConfirmationStatus : ConvertConfirmationStatusToProto (r .Results [i ].ConfirmationStatus ),
10771096 })
@@ -1257,30 +1276,19 @@ func ConvertSubmitTransactionReplyToProto(r *typesolana.SubmitTransactionReply)
12571276 return & SubmitTransactionReply {
12581277 Signature : r .Signature [:],
12591278 IdempotencyKey : r .IdempotencyKey ,
1260- Status : TransactionStatus (r .Status ),
1279+ Status : TxStatus (r .Status ),
12611280 }
12621281}
12631282
1264- func ConvertContextFromProto (p * Context ) typesolana.Context {
1265- if p == nil {
1266- return typesolana.Context {}
1267- }
1268- return typesolana.Context {Slot : p .Slot }
1269- }
1270-
1271- func ConvertContextToProto (c typesolana.Context ) * Context {
1272- return & Context {Slot : c .Slot }
1273- }
1274-
12751283func ConvertRPCContextFromProto (p * RPCContext ) typesolana.RPCContext {
12761284 if p == nil {
12771285 return typesolana.RPCContext {}
12781286 }
1279- return typesolana.RPCContext {Context : ConvertContextFromProto ( p . Context ) }
1287+ return typesolana.RPCContext {Slot : p . Slot }
12801288}
12811289
12821290func ConvertRPCContextToProto (r typesolana.RPCContext ) * RPCContext {
1283- return & RPCContext {Context : ConvertContextToProto ( r . Context ) }
1291+ return & RPCContext {Slot : r . Slot }
12841292}
12851293
12861294func ConvertLogFromProto (p * Log ) (* typesolana.Log , error ) {
0 commit comments