Skip to content

Commit

Permalink
Feat/millis timestamp (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
lrazovic authored Apr 3, 2024
1 parent 187ca4b commit e9c1908
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 20 deletions.
1 change: 1 addition & 0 deletions pallets/funding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ pub mod pallet {
type ContributionTreasury: Get<AccountIdOf<Self>>;

/// The Ed25519 Verifier Public Key of credential JWTs
#[pallet::constant]
type VerifierPublicKey: Get<[u8; 32]>;

/// The type used for vesting
Expand Down
3 changes: 2 additions & 1 deletion polimec-common/common/src/credentials/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ where
let Some(who) = origin.clone().into_signer() else { return Err(origin) };
let Ok(token) = Self::verify_token(token, verifying_key) else { return Err(origin) };
let Ok(claims) = Self::extract_claims(&token) else { return Err(origin) };
// Get the current timestamp from the pallet_timestamp. It is in milliseconds.
let Ok(now) = Now::<T>::get().try_into() else { return Err(origin) };
let Some(date_time) = claims.expiration else { return Err(origin) };

if claims.custom.subject == who && (date_time.timestamp() as u64) >= now {
if claims.custom.subject == who && (date_time.timestamp_millis() as u64) >= now {
return Ok((who, claims.custom.did.clone(), claims.custom.investor_type.clone()));
}

Expand Down
48 changes: 29 additions & 19 deletions scripts/zombienet/native/local-testnet.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,41 @@
timeout = 1000
provider = "native"

# Using Rococo 1.7.0 as relay.
[relaychain]
default_command = "polkadot"
default_command = "./bin/polkadot"
chain = "rococo-local"

[[relaychain.nodes]]
name = "eve"
[[relaychain.nodes]]
name = "eve"

[[relaychain.nodes]]
name = "ferdie"
[[relaychain.nodes]]
name = "ferdie"

[[relaychain.nodes]]
name = "charlie"
[[relaychain.nodes]]
name = "charlie"

[[relaychain.nodes]]
name = "dave"
[[relaychain.nodes]]
name = "dave"

[[parachains]]
id = 3344
chain = "polimec-rococo-local"

[[parachains.collators]]
name = "alice"
command = "polimec"
ws_port = 8080

[[parachains.collators]]
name = "bob"
command = "polimec"
chain = "politest-local"

[[parachains.collators]]
name = "alice"
command = "./target/release/polimec-node"
args = [
"-lcredentials::try_origin",
"-lcredentials::ensure_origin"
]
ws_port = 8080

[[parachains.collators]]
name = "bob"
command = "./target/release/polimec-node"
args = [
"-lcredentials::try_origin",
"-lcredentials::ensure_origin"
]
ws_port = 8081

0 comments on commit e9c1908

Please sign in to comment.