Skip to content

Commit

Permalink
Index parameter type for smart rollups
Browse files Browse the repository at this point in the history
  • Loading branch information
Groxan committed May 31, 2024
1 parent 9e87ff5 commit d89b2b5
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Tzkt.Api/Repositories/TokensRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ public async Task<object[][]> GetTokenBalances(TokenBalanceFilter filter, Pagina
break;
case "balanceValue":
foreach (var row in rows)
result[j++][i] = row.BalanceValue == 0M ? null : row.BalanceValue;
result[j++][i] = row.BalanceValue == BigInteger.Zero ? null : row.BalanceValue;
break;
case "firstLevel":
foreach (var row in rows)
Expand Down
3 changes: 3 additions & 0 deletions Tzkt.Data/Migrations/20240424125408_Initial.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Tzkt.Data/Migrations/20240424125408_Initial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -996,6 +996,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
ManagerId = table.Column<int>(type: "integer", nullable: true),
WeirdDelegateId = table.Column<int>(type: "integer", nullable: true),
PvmKind = table.Column<int>(type: "integer", nullable: true),
ParameterSchema = table.Column<byte[]>(type: "bytea", nullable: true),
GenesisCommitment = table.Column<string>(type: "text", nullable: true),
LastCommitment = table.Column<string>(type: "text", nullable: true),
InboxLevel = table.Column<int>(type: "integer", nullable: true),
Expand Down
3 changes: 3 additions & 0 deletions Tzkt.Data/Migrations/20240501115741_Triggers.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Tzkt.Data/Migrations/20240501115809_TokensValue.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Tzkt.Data/Migrations/TzktContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5692,6 +5692,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<int>("OrphanCommitments")
.HasColumnType("integer");

b.Property<byte[]>("ParameterSchema")
.HasColumnType("bytea");

b.Property<int>("PendingCommitments")
.HasColumnType("integer");

Expand Down
1 change: 1 addition & 0 deletions Tzkt.Data/Models/Accounts/SmartRollup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class SmartRollup : Account
[Column("CreatorId")]
public int CreatorId { get; set; }
public PvmKind PvmKind { get; set; }
public byte[] ParameterSchema { get; set; }
public string GenesisCommitment { get; set; }
public string LastCommitment { get; set; }
public int InboxLevel { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
.Select(x =>
(
x["address"].Value<string>(),
x["pvm_kind"].Value<string>()
x["pvm_kind"].Value<string>(),
x["parameters_ty"].ToString()
))
.ToList() ?? new(0);

Expand Down Expand Up @@ -218,7 +219,7 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
#endregion

#region bootstrap smart rollups
foreach (var (address, pvmKind) in bootstrapSmartRollups)
foreach (var (address, pvmKind, parameterType) in bootstrapSmartRollups)
{
var genesisInfo = await Proto.Rpc.GetSmartRollupGenesisInfo(1, address);

Expand All @@ -239,6 +240,7 @@ protected virtual async Task<List<Account>> BootstrapAccounts(Protocol protocol,
"wasm_2_0_0" => PvmKind.Wasm,
_ => throw new NotImplementedException()
},
ParameterSchema = Micheline.FromJson(parameterType).ToBytes(),
GenesisCommitment = genesisInfo.RequiredString("commitment_hash"),
LastCommitment = genesisInfo.RequiredString("commitment_hash"),
InboxLevel = genesisInfo.RequiredInt32("level"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content
Staked = false,
Type = AccountType.SmartRollup,
PvmKind = pvmKind,
ParameterSchema = Micheline.FromJson(content.Required("parameters_ty")).ToBytes(),
GenesisCommitment = result.RequiredString("genesis_commitment_hash"),
LastCommitment = result.RequiredString("genesis_commitment_hash"),
InboxLevel = 0,
Expand Down Expand Up @@ -82,6 +83,7 @@ public virtual async Task Apply(Block block, JsonElement op, JsonElement content
Staked = false,
Type = AccountType.SmartRollup,
PvmKind = pvmKind,
ParameterSchema = Micheline.FromJson(content.Required("parameters_ty")).ToBytes(),
GenesisCommitment = result.RequiredString("genesis_commitment_hash"),
LastCommitment = result.RequiredString("genesis_commitment_hash"),
InboxLevel = 0,
Expand Down

0 comments on commit d89b2b5

Please sign in to comment.