-
Notifications
You must be signed in to change notification settings - Fork 21
Fix four content-drift items flagged in #21 #22
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
Open
kaankacar
wants to merge
2
commits into
main
Choose a base branch
from
21-skill-content-drift-after-7-skill-restructure-4-high-priority-items
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+55
−46
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,7 +507,7 @@ use soroban_sdk::Env; | |
| #[test] | ||
| fn test_increment() { | ||
| let env = Env::default(); | ||
| let contract_id = env.register_contract(None, CounterContract); | ||
| let contract_id = env.register(CounterContract, ()); | ||
| let client = CounterContractClient::new(&env, &contract_id); | ||
|
|
||
| let admin = Address::generate(&env); | ||
|
|
@@ -524,7 +524,7 @@ fn test_transfer_with_auth() { | |
| let env = Env::default(); | ||
| env.mock_all_auths(); // Auto-approve all auth requests | ||
|
|
||
| let contract_id = env.register_contract(None, TokenContract); | ||
| let contract_id = env.register(TokenContract, ()); | ||
| let client = TokenContractClient::new(&env, &contract_id); | ||
|
|
||
| let alice = Address::generate(&env); | ||
|
|
@@ -631,7 +631,7 @@ fn test_basic_functionality() { | |
| let env = Env::default(); | ||
|
|
||
| // Register contract | ||
| let contract_id = env.register_contract(None, Contract); | ||
| let contract_id = env.register(Contract, ()); | ||
|
|
||
| // Create typed client | ||
| let client = ContractClient::new(&env, &contract_id); | ||
|
|
@@ -657,7 +657,7 @@ fn test_with_auth() { | |
| // Mock all authorizations automatically | ||
| env.mock_all_auths(); | ||
|
|
||
| let contract_id = env.register_contract(None, TokenContract); | ||
| let contract_id = env.register(TokenContract, ()); | ||
| let client = TokenContractClient::new(&env, &contract_id); | ||
|
|
||
| let admin = Address::generate(&env); | ||
|
|
@@ -687,7 +687,7 @@ fn test_with_auth() { | |
| #[test] | ||
| fn test_specific_auth() { | ||
| let env = Env::default(); | ||
| let contract_id = env.register_contract(None, Contract); | ||
| let contract_id = env.register(Contract, ()); | ||
| let client = ContractClient::new(&env, &contract_id); | ||
|
|
||
| let user = Address::generate(&env); | ||
|
|
@@ -713,7 +713,7 @@ fn test_specific_auth() { | |
| #[test] | ||
| fn test_time_based() { | ||
| let env = Env::default(); | ||
| let contract_id = env.register_contract(None, VestingContract); | ||
| let contract_id = env.register(VestingContract, ()); | ||
| let client = VestingContractClient::new(&env, &contract_id); | ||
|
|
||
| let beneficiary = Address::generate(&env); | ||
|
|
@@ -762,7 +762,7 @@ fn test_ledger_manipulation() { | |
| #[test] | ||
| fn test_events() { | ||
| let env = Env::default(); | ||
| let contract_id = env.register_contract(None, Contract); | ||
| let contract_id = env.register(Contract, ()); | ||
| let client = ContractClient::new(&env, &contract_id); | ||
|
|
||
| client.do_something(); | ||
|
|
@@ -786,7 +786,7 @@ fn test_events() { | |
| #[test] | ||
| fn test_storage_ttl() { | ||
| let env = Env::default(); | ||
| let contract_id = env.register_contract(None, Contract); | ||
| let contract_id = env.register(Contract, ()); | ||
| let client = ContractClient::new(&env, &contract_id); | ||
|
|
||
| client.store_data(); | ||
|
|
@@ -809,8 +809,8 @@ fn test_cross_contract() { | |
| let env = Env::default(); | ||
|
|
||
| // Register both contracts | ||
| let token_id = env.register_contract_wasm(None, token::WASM); | ||
| let vault_id = env.register_contract(None, VaultContract); | ||
| let token_id = env.register(token::WASM, ()); | ||
| let vault_id = env.register(VaultContract, ()); | ||
|
|
||
| let token_client = token::Client::new(&env, &token_id); | ||
| let vault_client = VaultContractClient::new(&env, &vault_id); | ||
|
|
@@ -921,8 +921,8 @@ stellar contract deploy \ | |
| --source my-testnet-key \ | ||
| --network testnet | ||
|
|
||
| # Install contract code (separate from deployment) | ||
| stellar contract install \ | ||
| # Upload contract code (separate from deployment) | ||
| stellar contract upload \ | ||
| --wasm target/wasm32-unknown-unknown/release/contract.wasm \ | ||
| --source my-testnet-key \ | ||
| --network testnet | ||
|
|
@@ -1131,7 +1131,7 @@ use soroban_sdk::{testutils::Address as _, Address, Env}; | |
| use crate::{Contract, ContractClient}; | ||
|
|
||
| pub fn setup_contract(env: &Env) -> (Address, ContractClient) { | ||
| let contract_id = env.register_contract(None, Contract); | ||
| let contract_id = env.register(Contract, ()); | ||
| let client = ContractClient::new(env, &contract_id); | ||
| let admin = Address::generate(env); | ||
|
|
||
|
|
@@ -1274,7 +1274,7 @@ fn test_upgrade_compatibility() { | |
| env.mock_all_auths(); | ||
|
|
||
| // Register both versions | ||
| let old_id = env.register_contract_wasm(None, deployed::WASM); | ||
| let old_id = env.register(deployed::WASM, ()); | ||
| let new_id = env.register(NewContract, ()); | ||
|
|
||
| let old_client = deployed::Client::new(&env, &old_id); | ||
|
|
@@ -2407,22 +2407,23 @@ const preparedTx = StellarSdk.rpc.assembleTransaction( | |
|
|
||
| **Solution**: | ||
| ```typescript | ||
| import { isConnected, isAllowed } from "@stellar/freighter-api"; | ||
| import { isConnected, isAllowed, requestAccess } from "@stellar/freighter-api"; | ||
|
|
||
| async function checkFreighter() { | ||
| // Check if extension is installed | ||
| const connected = await isConnected(); | ||
| if (!connected) { | ||
| const { isConnected: installed, error } = await isConnected(); | ||
| if (error || !installed) { | ||
| // Prompt user to install | ||
|
Comment on lines
+2410
to
2416
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 9abdab8. Updated the network mismatch snippet to use Freighter v3 |
||
| window.open("https://freighter.app", "_blank"); | ||
| return; | ||
| } | ||
|
|
||
| // Check if app is allowed | ||
| const allowed = await isAllowed(); | ||
| if (!allowed) { | ||
| // Need to request permission | ||
| await setAllowed(); | ||
| // Check if this app is already authorized | ||
| const { isAllowed: granted } = await isAllowed(); | ||
| if (!granted) { | ||
| // requestAccess prompts the user and returns { address, error } | ||
| const { error: accessError } = await requestAccess(); | ||
| if (accessError) throw new Error(accessError.message); | ||
| } | ||
| } | ||
| ``` | ||
|
|
@@ -2442,7 +2443,8 @@ async function checkFreighter() { | |
| import { getNetwork } from "@stellar/freighter-api"; | ||
|
|
||
| async function validateNetwork() { | ||
| const walletNetwork = await getNetwork(); | ||
| const { network: walletNetwork, error } = await getNetwork(); | ||
| if (error) throw new Error(error.message); | ||
| const appNetwork = process.env.NEXT_PUBLIC_STELLAR_NETWORK; | ||
|
|
||
| if (walletNetwork !== appNetwork) { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 9abdab8. The hook snippet now handles
errorfromgetAddress()/getNetwork()and validates address/network before setting connected state.