Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serialise bigint as idiomatic Filecoin form #1516

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion actors/verifreg/src/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use crate::{ActorError, AllocationID};
use crate::{ClaimID, DataCap};
use fil_actors_runtime::runtime::Runtime;
use fil_actors_runtime::EventBuilder;
use fvm_shared::bigint::bigint_ser::BigIntSer;
use fvm_shared::ActorID;

/// Indicates a new value for a verifier's datacap balance.
Expand All @@ -18,7 +19,7 @@ pub fn verifier_balance(
&EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier)
.field("balance", new_balance)
.field("balance", &BigIntSer(new_balance))
.build()?,
)
}
Expand Down
6 changes: 3 additions & 3 deletions actors/verifreg/tests/harness/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl Harness {
EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier_resolved.id().unwrap())
.field("balance", &allowance)
.field("balance", &BigIntSer(allowance))
.build()?,
);

Expand All @@ -166,7 +166,7 @@ impl Harness {
EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier.id().unwrap())
.field("balance", &DataCap::zero())
.field("balance", &BigIntSer(&DataCap::zero()))
.build()?,
);
rt.set_caller(*ACCOUNT_ACTOR_CODE_ID, self.root);
Expand Down Expand Up @@ -234,7 +234,7 @@ impl Harness {
EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier.id().unwrap())
.field("balance", &(verifier_balance - allowance))
.field("balance", &BigIntSer(&(verifier_balance - allowance)))
.build()?,
);
let ret = rt.call::<VerifregActor>(
Expand Down
3 changes: 2 additions & 1 deletion actors/verifreg/tests/verifreg_actor_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use fvm_shared::address::Address;
use fvm_shared::bigint::bigint_ser::BigIntSer;
use lazy_static::lazy_static;

mod harness;
Expand Down Expand Up @@ -447,7 +448,7 @@ mod clients {
EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &VERIFIER.id().unwrap())
.field("balance", &(allowance_verifier - allowance_client))
.field("balance", &BigIntSer(&(allowance_verifier - allowance_client)))
.build()
.unwrap(),
);
Expand Down
3 changes: 2 additions & 1 deletion integration_tests/src/util/workflows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use fvm_ipld_encoding::ipld_block::IpldBlock;
use fvm_ipld_encoding::BytesDe;
use fvm_ipld_encoding::RawBytes;
use fvm_shared::address::Address;
use fvm_shared::bigint::bigint_ser::BigIntSer;
use fvm_shared::clock::ChainEpoch;
use fvm_shared::crypto::signature::Signature;
use fvm_shared::crypto::signature::SignatureType;
Expand Down Expand Up @@ -764,7 +765,7 @@ pub fn verifier_balance_event(verifier: ActorID, data_cap: DataCap) -> EmittedEv
event: EventBuilder::new()
.typ("verifier-balance")
.field_indexed("verifier", &verifier)
.field("balance", &data_cap)
.field("balance", &BigIntSer(&data_cap))
.build()
.unwrap(),
}
Expand Down
Loading