From 15df516bad951177d52a5b656c0b9eb75222d49b Mon Sep 17 00:00:00 2001 From: Fernando Otero Date: Tue, 27 Jun 2023 11:23:40 +0100 Subject: [PATCH 1/2] Serialize gateway token changes --- solana/program/src/processor.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/solana/program/src/processor.rs b/solana/program/src/processor.rs index 989c0ff01..78bc7fe5f 100644 --- a/solana/program/src/processor.rs +++ b/solana/program/src/processor.rs @@ -362,7 +362,9 @@ fn expire_token(accounts: &[AccountInfo], gatekeeper_network: Pubkey) -> Program gateway_token.set_expire_time(Clock::get()?.unix_timestamp - 120); - Ok(()) + gateway_token + .serialize(&mut *gateway_token_info.data.borrow_mut()) + .map_err(|e| e.into()) as ProgramResult } fn add_feature_to_network(accounts: &[AccountInfo], feature: NetworkFeature) -> ProgramResult { From 22283763bb82d083cbf3440156e394973344f4f6 Mon Sep 17 00:00:00 2001 From: dankelleher Date: Tue, 27 Jun 2023 13:05:22 +0200 Subject: [PATCH 2/2] Solana: Test for update-expiry bugfix --- solana/gateway-ts/scripts/burn.ts | 60 ------------------- solana/program/Cargo.toml | 2 +- .../tests/update_gateway_token_expiry.rs | 7 +++ 3 files changed, 8 insertions(+), 61 deletions(-) delete mode 100644 solana/gateway-ts/scripts/burn.ts diff --git a/solana/gateway-ts/scripts/burn.ts b/solana/gateway-ts/scripts/burn.ts deleted file mode 100644 index 72c8a0109..000000000 --- a/solana/gateway-ts/scripts/burn.ts +++ /dev/null @@ -1,60 +0,0 @@ -import { - clusterApiUrl, - Connection, - Keypair, - PublicKey, - Transaction, -} from "@solana/web3.js"; -import { - burn, - expireToken, - findGatewayToken, - getGatekeeperAccountAddress, - getGatewayToken, -} from "../src"; -import * as os from "os"; - -const gatewayToken = new PublicKey(process.argv[2]); -const keypair = Keypair.fromSecretKey( - Buffer.from(require(os.homedir() + "/.config/solana/id.json")) -); -const gatekeeperNetwork = new PublicKey( - "tgnuXXNMDLK8dy7Xm1TdeGyc95MDym4bvAQCwcW21Bf" -); -const gatekeeperKey = Keypair.fromSecretKey( - Buffer.from( - require("/Users/daniel/code/identity-com/on-chain-identity-gateway/solana/gatekeeper-cli/src/util/test-gatekeeper.json") - ) -); - -(async () => { - const endpoint = process.env.CLUSTER_ENDPOINT || clusterApiUrl("devnet"); - const connection = new Connection(endpoint, "confirmed"); - - const token = await getGatewayToken(connection, gatewayToken); - - console.log(token); - - if (!token) throw new Error("Token not found"); - - console.log("gatekeeperNetwork", token.gatekeeperNetwork.toBase58()); - - const gatekeeperAccount = getGatekeeperAccountAddress( - token.issuingGatekeeper, - gatekeeperNetwork - ); - - const instruction = burn( - gatewayToken, - token.issuingGatekeeper, - gatekeeperAccount, - keypair.publicKey - ); - - const tx = await connection.sendTransaction( - new Transaction().add(instruction), - [gatekeeperKey] - ); - - console.log(tx); -})().catch(console.error); diff --git a/solana/program/Cargo.toml b/solana/program/Cargo.toml index a7f196979..91488fd92 100644 --- a/solana/program/Cargo.toml +++ b/solana/program/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "solana-gateway" -version = "0.3.0" +version = "0.3.1" description = "OCIV Gateway Program" authors = ["Daniel Kelleher "] repository = "https://github.com/identity-com/on-chain-identity-gateway" diff --git a/solana/program/tests/update_gateway_token_expiry.rs b/solana/program/tests/update_gateway_token_expiry.rs index 65f671796..3bad86abb 100644 --- a/solana/program/tests/update_gateway_token_expiry.rs +++ b/solana/program/tests/update_gateway_token_expiry.rs @@ -209,6 +209,13 @@ async fn expire_token_should_succeed() { .process_transaction(expire_tx) .await .unwrap(); + + let now = GatewayContext::now(); + let gateway_token = context + .get_gateway_token(&context.owner.pubkey()) + .await + .unwrap(); + assert!(gateway_token.expire_time.unwrap() <= now); } #[tokio::test]