Skip to content

Commit 8c3bfbf

Browse files
committed
fix: change some names and add necessary fields to indexing agreements
1 parent 1e4ea11 commit 8c3bfbf

File tree

6 files changed

+41
-30
lines changed

6 files changed

+41
-30
lines changed

.sqlx/query-05cd59d0d9e64a7c6f7d4560a97e6b79fd38523fbcef88b2dd169720b4e9188e.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-78fbff2889a77201ec01cd18fc83d4e7e63037d56e86bd7c462c8f8adc0cfac8.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/dips/src/lib.rs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ sol! {
5656
#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)]
5757
struct SubgraphIndexingVoucherMetadata {
5858
uint256 pricePerBlock; // wei GRT
59-
bytes32 protocolNetwork; // eip199:1 format
60-
// differentiate based on indexed chain
61-
bytes32 chainId; // eip199:1 format
62-
string deployment_ipfs_hash;
59+
uint256 pricePerEntity; // wei GRT
60+
string subgraphDeploymentId; // e.g. "Qmbg1qF4YgHjiVfsVt6a13ddrVcRtWyJQfD4LA3CwHM29f" - TODO consider using bytes32
61+
string protocolNetwork; // e.g. "eip155:42161"
62+
string chainId; // e.g. "eip155:1"
6363
}
6464

6565
#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)]
@@ -77,7 +77,7 @@ sol! {
7777
// data service that will initiate payment collection.
7878
address service;
7979
// signer of the cancellation, can be signed by either party.
80-
address cancellled_by;
80+
address cancelledBy;
8181
// should only be usable within a limited period of time.
8282
uint64 timestamp;
8383
bytes metadata;
@@ -197,7 +197,7 @@ impl SignedCancellationRequest {
197197
.recover_address_from_prehash(&self.request.eip712_signing_hash(domain))
198198
.map_err(|err| DipsError::InvalidSignature(err.to_string()))?;
199199

200-
if signer.ne(&self.request.cancellled_by) {
200+
if signer.ne(&self.request.cancelledBy) {
201201
return Err(DipsError::UnexpectedSigner);
202202
}
203203

@@ -291,9 +291,10 @@ mod test {
291291

292292
let metadata = SubgraphIndexingVoucherMetadata {
293293
pricePerBlock: U256::from(10000_u64),
294-
protocolNetwork: FixedBytes::left_padding_from("arbitrum-one".as_bytes()),
295-
chainId: FixedBytes::left_padding_from("mainnet".as_bytes()),
296-
deployment_ipfs_hash: deployment_id,
294+
pricePerEntity: U256::from(100_u64),
295+
protocolNetwork: "eip155:42161",
296+
chainId: "eip155:1",
297+
subgraphDeploymentId: deployment_id,
297298
};
298299

299300
let voucher = IndexingAgreementVoucher {
@@ -343,9 +344,10 @@ mod test {
343344

344345
let metadata = SubgraphIndexingVoucherMetadata {
345346
pricePerBlock: U256::from(10000_u64),
346-
protocolNetwork: FixedBytes::left_padding_from("arbitrum-one".as_bytes()),
347-
chainId: FixedBytes::left_padding_from("mainnet".as_bytes()),
348-
deployment_ipfs_hash: deployment_id,
347+
pricePerEntity: U256::from(100_u64),
348+
protocolNetwork: "eip155:42161",
349+
chainId: "eip155:1",
350+
subgraphDeploymentId: deployment_id,
349351
};
350352

351353
let voucher = IndexingAgreementVoucher {
@@ -384,9 +386,10 @@ mod test {
384386

385387
let metadata = SubgraphIndexingVoucherMetadata {
386388
pricePerBlock: U256::from(10000_u64),
387-
protocolNetwork: FixedBytes::left_padding_from("arbitrum-one".as_bytes()),
388-
chainId: FixedBytes::left_padding_from("mainnet".as_bytes()),
389-
deployment_ipfs_hash: deployment_id,
389+
pricePerEntity: U256::from(100_u64),
390+
protocolNetwork: "eip155:42161",
391+
chainId: "eip155:1",
392+
subgraphDeploymentId: deployment_id,
390393
};
391394

392395
let voucher = IndexingAgreementVoucher {
@@ -428,9 +431,10 @@ mod test {
428431

429432
let metadata = SubgraphIndexingVoucherMetadata {
430433
pricePerBlock: U256::from(10000_u64),
431-
protocolNetwork: FixedBytes::left_padding_from("arbitrum-one".as_bytes()),
432-
chainId: FixedBytes::left_padding_from("mainnet".as_bytes()),
433-
deployment_ipfs_hash: deployment_id,
434+
pricePerEntity: U256::from(100_u64),
435+
protocolNetwork: "eip155:42161",
436+
chainId: "eip155:1",
437+
subgraphDeploymentId: deployment_id,
434438
};
435439

436440
struct Case<'a> {
@@ -479,7 +483,7 @@ mod test {
479483
payee: payee_addr,
480484
service: Address(FixedBytes::ZERO),
481485
metadata: metadata.eip712_hash_struct().to_owned().into(),
482-
cancellled_by: signer.address(),
486+
cancelledBy: signer.address(),
483487
timestamp,
484488
};
485489
let domain = eip712_domain(0, Address::ZERO);

crates/service/src/database/dips.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct PsqlAgreementStore {
1919
#[async_trait]
2020
impl AgreementStore for PsqlAgreementStore {
2121
async fn get_by_id(&self, id: Uuid) -> anyhow::Result<Option<SignedIndexingAgreementVoucher>> {
22-
let item = sqlx::query!("SELECT * FROM dips_agreements WHERE id=$1", id,)
22+
let item = sqlx::query!("SELECT * FROM indexing_agreements WHERE id=$1", id,)
2323
.fetch_one(&self.pool)
2424
.await;
2525

@@ -43,7 +43,7 @@ impl AgreementStore for PsqlAgreementStore {
4343
let now = Utc::now();
4444

4545
sqlx::query!(
46-
"INSERT INTO dips_agreements VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,null,null)",
46+
"INSERT INTO indexing_agreements VALUES ($1,$2,$3,$4,$5,$6,$7,$8,$9,null,null)",
4747
id,
4848
agreement.signature.as_ref(),
4949
bs,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
-- Add down migration script here
2-
DROP TABLE IF EXISTS dips_agreements;
2+
DROP TABLE IF EXISTS indexing_agreements;
Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
-- Add up migration script here
22

3-
CREATE TABLE IF NOT EXISTS dips_agreements (
3+
CREATE TABLE IF NOT EXISTS indexing_agreements (
44
id UUID PRIMARY KEY,
55
signature BYTEA NOT NULL,
66
signed_payload BYTEA NOT NULL,
77

8-
protocol CHAR(40) NOT NULL,
9-
service BYTEA NOT NULL,
10-
payee BYTEA NOT NULL,
11-
payer BYTEA NOT NULL,
8+
protocol_network VARCHAR(255) NOT NULL,
9+
chain_id VARCHAR(255) NOT NULL,
10+
price_per_block NUMERIC(39) NOT NULL,
11+
price_per_entity NUMERIC(39) NOT NULL,
12+
subgraph_deployment_id VARCHAR(255) NOT NULL,
13+
14+
service CHAR(40) NOT NULL,
15+
payee CHAR(40) NOT NULL,
16+
payer CHAR(40) NOT NULL,
17+
18+
current_allocation_id CHAR(40) NOT NULL,
1219

1320
created_at TIMESTAMP WITH TIME ZONE NOT NULL,
1421
updated_at TIMESTAMP WITH TIME ZONE NOT NULL,
@@ -17,4 +24,4 @@ CREATE TABLE IF NOT EXISTS dips_agreements (
1724
signed_cancellation_payload BYTEA
1825
);
1926

20-
CREATE UNIQUE INDEX IX_UNIQ_SIGNATURE_AGREEMENT on dips_agreements(signature);
27+
CREATE UNIQUE INDEX IX_UNIQ_SIGNATURE_AGREEMENT on indexing_agreements(signature);

0 commit comments

Comments
 (0)