Skip to content

Commit

Permalink
Fix loaded addresses field names
Browse files Browse the repository at this point in the history
  • Loading branch information
gagliardetto committed Aug 10, 2023
1 parent 194c959 commit 0998d80
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions cmd-rpc-server-car-getTransaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,39 @@ func adaptTransactionMetaToExpectedOutput(m map[string]any) map[string]any {
"writable": []any{},
}
}
{
// if has loadedReadonlyAddresses and is []string, then use that for loadedAddresses.readonly
if loadedReadonlyAddresses, ok := meta["loadedReadonlyAddresses"].([]any); ok {
// the address list is base64 encoded; decode and encode to base58
for i, addr := range loadedReadonlyAddresses {
addrStr, ok := addr.(string)
if ok {
decoded, err := base64.StdEncoding.DecodeString(addrStr)
if err == nil {
loadedReadonlyAddresses[i] = base58.Encode(decoded)
}
}
}
meta["loadedAddresses"].(map[string]any)["readonly"] = loadedReadonlyAddresses
delete(meta, "loadedReadonlyAddresses")
}
// if has loadedWritableAddresses and is []string, then use that for loadedAddresses.writable
if loadedWritableAddresses, ok := meta["loadedWritableAddresses"].([]any); ok {
// the address list is base64 encoded; decode and encode to base58
for i, addr := range loadedWritableAddresses {
addrStr, ok := addr.(string)
if ok {
decoded, err := base64.StdEncoding.DecodeString(addrStr)
if err == nil {
loadedWritableAddresses[i] = base58.Encode(decoded)
}
}
}
meta["loadedAddresses"].(map[string]any)["writable"] = loadedWritableAddresses
delete(meta, "loadedWritableAddresses")
}
// remove loadedReadonlyAddresses and loadedWritableAddresses
}
if _, ok := meta["postTokenBalances"]; !ok {
meta["postTokenBalances"] = []any{}
}
Expand Down

0 comments on commit 0998d80

Please sign in to comment.