Skip to content

Commit

Permalink
add admin, update readme with contract address, migrate to new versio…
Browse files Browse the repository at this point in the history
…n, add attributes to methods
  • Loading branch information
Saeed committed Feb 14, 2024
1 parent bf44ff4 commit 7f8963c
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "haypay"
version = "0.1.0"
version = "0.1.1"
authors = ["Saeed <github.com/omni001s>", "Sam <github.com/meisamtaher>"]
edition = "2021"

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ The required environment variables for deploy script are
$DEPLOYER_ADDRESS, $RPC, $CHAIN_ID, $GAS_PRICE
# GAS_PRICE could be set to 0uxion for xion testnet
```
### (Optional) Install the `cargo-run-script`
### (Optional) Install the [cargo-run-script](#requirements)
### Deploy the contract
you could invoke the deploy scripts directly or using cargo
- Directly run the script
Expand All @@ -57,4 +57,4 @@ After deploying the contract, the script gives you the `code_id`, `contract_addr
## Testing
You could use the [test](./Scripts/test.sh) script in scripts folder to test the contract on testnet, but it requires jwt and email address, the email address and your `xion_address` shall be in jwt, preparing this jwt is kindof difficult but you could check it out in our demo [video](https://youtu.be/xxxxxxxxxxx)
## Deployed contract in Xion Testnet
The contract is deployed to Xion testnet at `xionxxxx` with code_id of `1xx`.
The contract is deployed to Xion testnet at `xion1zt64jdruawm4dl0svxe973gkd4kgvllwzgw6wexlgkpjmcssu4gqnqwdyp`.
13 changes: 9 additions & 4 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use semver::Version;

use crate::error::ContractError;
use crate::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg};
use crate::state::ADMIN;

// version info for migration
const CONTRACT_NAME: &str = env!("CARGO_PKG_NAME");
Expand All @@ -19,8 +20,11 @@ pub fn instantiate(
_msg: InstantiateMsg,
) -> Result<Response, ContractError> {
set_contract_version(_deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
ADMIN.save(_deps.storage, &_info.sender.to_string())?;

Ok(Response::default().add_attribute(CONTRACT_NAME, CONTRACT_VERSION))
Ok(Response::default()
.add_attribute(CONTRACT_NAME, CONTRACT_VERSION)
.add_attribute("action", "instantiate"))
}

#[cfg_attr(not(feature = "library"), entry_point)]
Expand Down Expand Up @@ -61,10 +65,10 @@ pub fn migrate(mut _deps: DepsMut, _env: Env, _msg: MigrateMsg) -> Result<Respon
});
}

// run the migration ...
// Migrate the state

set_contract_version(_deps.storage, CONTRACT_NAME, CONTRACT_VERSION)?;
Ok(Response::new())
Ok(Response::new().add_attribute("action", "migrate"))
}

fn from_semver(err: semver::Error) -> ContractError {
Expand Down Expand Up @@ -152,14 +156,15 @@ mod execute {
// transfer the claims to sender and add atributes
if !txs.is_empty() {
Ok(Response::new()
.add_attribute("action", "claim")
.add_event(
Event::new("memos").add_attributes(
txs.iter()
.flat_map(|t| t.memos.iter().cloned())
.filter(|(_, memo)| !memo.is_empty())
.collect::<Vec<(String, String)>>(),
),
) //TODO add memo attribs
)
.add_event(
Event::new("claims").add_attributes(
txs.iter()
Expand Down
6 changes: 0 additions & 6 deletions src/jwt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,7 @@ use rsa::{BigUint, Pkcs1v15Sign, RsaPublicKey};
use sha2::{Digest, Sha256};

static AUD_KEY_MAP: Map<&'static str, &'static str> = phf_map! {
// GA - Testnet - Test project
"project-test-5ae234a7-6b74-46af-a7b7-969f3df38cc0" => "4ia1pODcj-BPNblyJ1ao1etK0VltRWQEmeoQtHaCWrOES-2BCFbcOBsDDxrXPzkTUK5j15fpMFbg36vDqXiYDNPHTp7WxUrOKOSyONk4gZUd626GZwKJBryMAhU7mBMByO56sLUHdDPajykYIlpHut75gDqipDI5QY9fh_piLh7OMy-MORaWdmkv1zFqLfjAr2GUKFmd7xiUAYTsjDClTTMn1rGskjBF8qPK9jDrPz9SEwN1n7N0JPsJVRqP6m5Yf_l9JWSKarSLbV9O0qMC7Nl0MpBKTw8HTVlwaBWF-5aGbg3dMQl8Cbn4vNUv-pPjrlvrpw2m_r0Gr5N9CBEKFQ;AQAB",
// GA - Testnet - Live project
"project-live-7e4a3221-79cd-4f34-ac1d-fedac4bde13e" => "7DEDs11mtM85pjdpELjoNBqBPcPf3rUU7llkoycaUfhlQF3ghMVBrIoVs4ivaBGJiBGBEnM64lKeCMYDaTDa67AUsUIahyBtKTHvZ_tEgOiqX6feWg-z6MsoA7HFoxbIzgwTGEVcFzy5y0BQEqffPstSBLUeZRfh7NGSXbGoo5zXPx1oEgrFtzfpnBgz-OP2rg1JLdycMP3YoKFIu5v2nnRobvlEraXil3ETJ-c6TLcaOctd1T4HSFNk5xy7HqiqMqU4Ixy5HfzC7gJqo1g1ppPrkSY36hpPgtpa6xR161cPr9Acvejqt8LK5xpoeW8oS67r1_m-TkKjTOhKzjbVNw;AQAB",
// Exodvs - Test project
"project-test-185e9a9f-8bab-42f2-a924-953a59e8ff94" => "sQKkA829tzjU2VA-INHvdrewkbQzjpsMn0PNM7KJaBODbB4ItZM4x1NVSWBiy2DGHkaDDvADRbbq1BZsC1iXVtIYm0AoD7x4QC1w89kp2_s0wmvUOSPiQZlYrgJqRDXirXJZX3MNku2McXbwdyPajDaR4nBBQOoUOF21CHqLDqBHs2R6tHyL80R_8mgueiqQ-4wg6SSVcB_6ZOh59vRcjKr34upKPWGQzvMGCkeTO9whzbIWbA1j-8ykiS63EhjWBZU_sSolsf1ZGq8peVrADDLhOvHtZxCZLKwB46k2kb8GKAWlO4wRP6BDVjzpnea7BsvZ6JwULKg3HisH9gzaiQ;AQAB",
"integration-test-project" => "olg7TF3aai-wR4HTDe5oR-WRhEsdW3u-O3IJHl0BiHkmR4MLskHG9HzivWoXsloUBnBMrFNxOH0x5cNMI07oi4PeRbHySiogRW9CXPjJaNlTi-pT_IgKFsyJNXsLyzrnajLkDbQU6pRsHmNeL0hAOUv48rtXv8VVWWN8okJehD2q9N7LHoFAOmIUEPg_VTHTt8K__O-9eMZKN4eMjh_4-sxRX6NXPSPT87XRlrK4GZ4pUdp86K0tOFLhwO4Uj0JkMNfI82eVZ1tAbDlqjd8jFnAb8fWm8wtdaTNbL_AAXmbDhswwJOyrw8fARZIhrXSdKBWa6e4k7sLwTIy-OO8saebnlARsjGst7ZCzmw5KCm2ctEVl3hYhHwyXu_A5rOblMrV3H0G7WqeKMCMVSJ11ssrlsmfVhNIwu1Qlt5GYmPTTJiCgGUGRxZkgDyOyjFNHglYpZamCGyJ9oyofsukEGoqMQ6WzjFi_hjVapzXi7Li-Q0OjEopIUUDDgeUrgjbGY0eiHI6sAz5hoaD0Qjc9e3Hk6-y7VcKCTCAanZOlJV0vJkHB98LBLh9qAoVUei_VaLFe2IcfVlrL_43aXlsHhr_SUQY5pHPlUMbQihE_57dpPRh31qDX_w6ye8dilniP8JmpKM2uIwnJ0x7hfJ45Qa0oLHmrGlzY9wi-RGP0YUk;AQAB",
};
pub struct Token {
//header: String,
Expand Down
3 changes: 2 additions & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use crate::error::ContractError;
use cosmwasm_schema::cw_serde;
use cosmwasm_std::{Addr, Uint128};
use cw_storage_plus::Map;
use cw_storage_plus::{Item, Map};

#[cw_serde]
pub struct ClaimData {
Expand Down Expand Up @@ -70,3 +70,4 @@ impl ClaimData {
}

pub const CLAIMS: Map<&str, Vec<ClaimData>> = Map::new("haypay");
pub const ADMIN: Item<String> = Item::new("Admin");

0 comments on commit 7f8963c

Please sign in to comment.