-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: add service provider address to config #93
feat: add service provider address to config #93
Conversation
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.
Left some comments! I strongly suggest reading them all before addressing them one by one, they are all kinda linked so it might be more helpful to do so.
As a short summary:
- No env var needed for this
ProtocolProvider
instances should get the new address via its constructor- You'll probably have to update
ProtocolProvider
instantiation in the agent + scripts
const account = privateKeyToAccount(privateKey); | ||
this.serviceProviderAddress = account.address; |
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.
Nice 😎
accessControl?: { | ||
serviceProviderAddress: Address; | ||
}; |
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.
The service provider address should be a ProtocolProvider
constructor stand-alone argument, like the private key (but optional in this case).
The value per se is not related with the RPCs' configuration.
@@ -55,6 +68,7 @@ const protocolProviderConfigSchema = z.object({ | |||
bondEscalationModule: addressSchema, | |||
horizonAccountingExtension: addressSchema, | |||
}), | |||
accessControl: accessControlSchema.optional(), |
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.
If we specify the accessControl
property here (which is good, it's what we want), the user needs to include the accessControl
object within the protocolProvider
object in the config YAML file.
protocolProvider:
rpcsConfig: ...
contracts: ...
accessControl:
serviceProviderAddress: 0x....
Thus we don't need the env var.
Remember that as a general approach, we generally want public values to be in the config YAML file and secrets to be in env vars.
apps/agent/src/config/index.ts
Outdated
accessControl: envData.SERVICE_PROVIDER_ADDRESS | ||
? { serviceProviderAddress: envData.SERVICE_PROVIDER_ADDRESS } | ||
: undefined, |
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.
Given that the service provider address will already be in configData
, we won't be using envData
anymore. You should be able to safely remove this!
apps/agent/README.md
Outdated
@@ -38,6 +38,7 @@ cp .env.example .env | |||
| `BLOCK_NUMBER_BLOCKMETA_TOKEN` | Bearer token for the Blockmeta service (see notes below on how to obtain) | Yes | | |||
| `EBO_AGENT_CONFIG_FILE_PATH` | Path to the agent YAML configuration file | Yes | | |||
| `DISCORD_WEBHOOK` | Your Discord channel webhook for notifications [Learn how to create a Discord webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) | No | | |||
| `SERVICE_PROVIDER_ADDRESS` | Service provider address to use with access control modules | No | |
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.
No need for this if we are not going to use the env var
apps/agent/.env.example
Outdated
|
||
# Optional: Service Provider Address for Access Control Modules | ||
# If not specified, it will be derived from PROTOCOL_PROVIDER_PRIVATE_KEY | ||
SERVICE_PROVIDER_ADDRESS=0xYourServiceProviderAddressHere |
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.
No need for this neither if we are not going to use the env var
apps/agent/src/config/schemas.ts
Outdated
@@ -31,9 +38,11 @@ export const envSchema = z.object({ | |||
BLOCK_NUMBER_BLOCKMETA_TOKEN: z.string(), | |||
EBO_AGENT_CONFIG_FILE_PATH: z.string(), | |||
DISCORD_WEBHOOK: z.string().optional(), | |||
SERVICE_PROVIDER_ADDRESS: serviceProviderAddressSchema, |
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.
Env var related stuff
SERVICE_PROVIDER_ADDRESS: z | ||
.string() | ||
.refine((val) => isAddress(val), { | ||
message: "SERVICE_PROVIDER_ADDRESS must be a valid blockchain address", | ||
}) | ||
.optional(), |
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.
This env var is fine, it can stay as we are not using yaml config files for the scripts.
accessControl: z | ||
.object({ | ||
/** | ||
* The service provider address used with access control modules. | ||
* This is an optional field. If not provided, it will be derived from the PROTOCOL_PROVIDER_PRIVATE_KEY. | ||
*/ | ||
serviceProviderAddress: z | ||
.string() | ||
.refine((val) => isAddress(val), { | ||
message: "serviceProviderAddress must be a valid blockchain address", | ||
}) | ||
.optional(), | ||
}) | ||
.optional(), |
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.
Is this property being used somewhere? 🤔
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.
deleted
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.
good to go after addressing Yaco's comments 🫡
@0xyaco addressed your comments--I think this is what you mean by passing it in the constructor (as part of the yaml |
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.
Just one small change and it's good to go!
private readonly rpcConfig: ProtocolRpcConfig, | ||
private readonly config: ProtocolProviderConfig, | ||
contracts: ProtocolContractsAddresses, | ||
privateKey: Hex, |
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.
The service provider address needs to go below this line. The service provider address is not part of the RpcConfig.
privateKey: Hex,
serviceProviderAddress: Address | undefined
When initializing the agent, you'll need to explicitly pass that address (that you'll have in the config).
This might be useful as an example:
new ProtocolProvider(
config.protocolProvider.rpcConfig,
config.protocolProvider.contracts,
config.privateKey,
config.protocolProvider.accessControl.serviceProviderAddress
...
)
🤖 Linear
Closes GRT-229
Description
-serviceProviderAddress can be unspecified/undefined.
Tests for now don't cover the actual use of this value as that will come next