Skip to content

Commit

Permalink
Support predefined bootstrapped contract addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed Jan 17, 2024
1 parent 82de8c8 commit 984d464
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
x["amount"].Value<long>(),
x["delegate"]?.Value<string>() ?? null,
x["script"]["code"].ToString(),
x["script"]["storage"].ToString()
x["script"]["storage"].ToString(),
x["hash"]?.Value<string>() ?? null
))
.ToList() ?? new(0);

Expand All @@ -33,7 +34,7 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
))
.ToList() ?? new(0);

var accounts = new List<Account>(bootstrapAccounts.Count + bootstrapContracts.Count);
var accounts = new List<Account>(bootstrapAccounts.Count + bootstrapContracts.Count + bootstrapSmartRollups.Count);

#region allocate null-address
var nullAddress = (User)await Cache.Accounts.GetAsync(NullAddress.Address);
Expand Down Expand Up @@ -115,7 +116,7 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,

#region bootstrap contracts
var index = 0;
foreach (var (balance, delegatePkh, codeStr, storageStr) in bootstrapContracts)
foreach (var (balance, delegatePkh, codeStr, storageStr, hash) in bootstrapContracts)
{
#region contract
var delegat = Cache.Accounts.GetDelegate(delegatePkh);
Expand All @@ -124,7 +125,7 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
var contract = new Contract
{
Id = Cache.AppState.NextAccountId(),
Address = OriginationNonce.GetContractAddress(index++),
Address = hash ?? OriginationNonce.GetContractAddress(index++),
Balance = balance,
FirstLevel = 1,
LastLevel = 1,
Expand Down

0 comments on commit 984d464

Please sign in to comment.