Skip to content

[SDK] feat: kvstore.get to return none/undefined when no key found#3819

Open
dnechay wants to merge 2 commits intoescrow-fee-kvstorefrom
dnechay/kv-get
Open

[SDK] feat: kvstore.get to return none/undefined when no key found#3819
dnechay wants to merge 2 commits intoescrow-fee-kvstorefrom
dnechay/kv-get

Conversation

@dnechay
Copy link
Collaborator

@dnechay dnechay commented Mar 11, 2026

Issue tracking

Freestyle

Context behind the change

Changed KVStoreUtils.get implementation in both SDK to return undefined/None instead of throwing an error. Throwing and error is a bit confusing behavior and usually when value is retrieved SDK consumer checks if the value is there, not empty string and correct, so it's better to return "absence of value" type rather than throw.

How has this been tested?

  • unit tests

Release plan

As part of major release in parent branch.

Potential risks; What to monitor; Rollback plan

Should be none

@vercel
Copy link

vercel bot commented Mar 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
human-app Ready Ready Preview, Comment Mar 11, 2026 3:42pm
human-dashboard-frontend Ready Ready Preview, Comment Mar 11, 2026 3:42pm
staking-dashboard Ready Ready Preview, Comment Mar 11, 2026 3:42pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
faucet-frontend Ignored Ignored Mar 11, 2026 3:42pm
faucet-server Ignored Ignored Mar 11, 2026 3:42pm

Request Review

@dnechay dnechay changed the title feat: kvstore.get to return none/undefined when no key found [SDK] feat: kvstore.get to return none/undefined when no key found Mar 11, 2026
@dnechay dnechay self-assigned this Mar 11, 2026
@dnechay dnechay moved this to In Review in Core tech - 2026 (H1) Mar 11, 2026
./scripts/run-unit-test.sh

run-test:
make build-contracts
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script is used in CI, but locally it makes sense to have just unit-test to not rebuild contracts every time

@dnechay dnechay requested review from flopez7 and portuu3 and removed request for portuu3 March 11, 2026 15:45
Copy link
Contributor

@flopez7 flopez7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it no longer returns an error if there is no key, let's remove the try catch, as we are interested in logging the other errors.

Comment on lines 213 to 223
try {
const reputationOracleAddress =
await escrowClient.getReputationOracleAddress(webhook.escrowAddress);
reputationOracleWebhook = (await KVStoreUtils.get(
webhook.chainId,
reputationOracleAddress,
KVStoreKeys.webhookUrl,
)) as string;
} catch {
//Ignore the error
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const reputationOracleAddress =
await escrowClient.getReputationOracleAddress(webhook.escrowAddress);
const reputationOracleWebhook = await KVStoreUtils.get(
webhook.chainId,
reputationOracleAddress,
KVStoreKeys.webhookUrl,
);

Comment on lines +242 to 251
let exchangeOracleURL: string | undefined;
try {
exchangeOracleURL = (await KVStoreUtils.get(
webhook.chainId,
await escrowClient.getExchangeOracleAddress(webhook.escrowAddress),
KVStoreKeys.webhookUrl,
)) as string;
} catch {
//Ignore the error
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const exchangeOracleURL = await KVStoreUtils.get(
webhook.chainId,
await escrowClient.getExchangeOracleAddress(webhook.escrowAddress),
KVStoreKeys.webhookUrl,
);

Comment on lines +314 to 325
let reputationOracleWebhook: string | undefined;
try {
const reputationOracleAddress =
await escrowClient.getReputationOracleAddress(webhook.escrowAddress);
reputationOracleWebhook = (await KVStoreUtils.get(
webhook.chainId,
reputationOracleAddress,
KVStoreKeys.webhookUrl,
)) as string;
} catch {
//Ignore the error
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const reputationOracleAddress =
await escrowClient.getReputationOracleAddress(webhook.escrowAddress);
const reputationOracleWebhook = await KVStoreUtils.get(
webhook.chainId,
reputationOracleAddress,
KVStoreKeys.webhookUrl,
);

Comment on lines +134 to 139
let fee: string | undefined;
try {
fee = await KVStoreUtils.get(chainId, address, KVStoreKeys.fee);
} catch {
// noop
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const fee = await KVStoreUtils.get(chainId, address, KVStoreKeys.fee);

Comment on lines +116 to 121
let role: string | undefined;
try {
role = await KVStoreUtils.get(chainId, address, KVStoreKeys.role);
} catch {
// noop
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const role = await KVStoreUtils.get(chainId, address, KVStoreKeys.role);

Comment on lines +144 to 149
let url: string | undefined;
try {
url = await KVStoreUtils.get(chainId, address, KVStoreKeys.url);
} catch {
// noop
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const url = await KVStoreUtils.get(chainId, address, KVStoreKeys.url);

Comment on lines 320 to +330
@@ -327,6 +327,7 @@
} catch {
// noop
}
operatorStatus = operatorStatus || OperatorStatus.INACTIVE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const operatorStatus = (await KVStoreUtils.get(
this.web3ConfigService.reputationNetworkChainId,
this.web3ConfigService.operatorAddress,
userEntity.evmAddress,
)) || OperatorStatus.INACTIVE;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Review

Development

Successfully merging this pull request may close these issues.

2 participants