Hakeem bin Hizam reported,

He freed one hundred slaves and provided one hundred camels for transport during the days of ignorance. When he embraced Islam, he again provided one hundred camels for transport and freed one hundred slaves.He said, "I asked the Messenger of Allah ﷺ, 'Messenger of Allah, what about the deeds I used to do in the days of ignorance, seeking thereby to draw closer to Allah, that is, seeking righteousness through them?'"The Messenger of Allah ﷺ replied, "You have entered Islam with all the good you previously did preserved for you."

Bukhari 2538

Sahih

حدثنا عبيد بن إسماعيل حدثنا أبو أسامة عن هشام أخبرني أبي أن

حكيم بن حزام رضي الله عنه

أعتق في الجاهلية مائة رقبة وحمل على مائة بعير فلما أسلم حمل على مائة بعير وأعتق مائة رقبة قال فسألت رسول الله ﷺ فقلت يا رسول الله أرأيت أشياء كنت أصنعها في الجاهلية كنت أتحنث بها يعني أتبرر بها قال فقال رسول الله ﷺ أسلمت على ما سلف لك من خير

البخاري 2538صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Emancipation of slaves
Chapter
Freeing a polytheist
Numbering
Darussalam 2538
Bukhari 2538