Skip to content

Commit

Permalink
remove deprecated fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ryley-o committed Aug 26, 2024
1 parent 9b7d434 commit 1cd3cf6
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 220 deletions.
12 changes: 0 additions & 12 deletions schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -248,24 +248,12 @@ type Contract @entity {
"Percentage of primary sales allocated to the platform"
renderProviderPercentage: BigInt!

"Deprecated field, will be removed and is not populated for v3.2+ - see Project.renderProviderSecondarySalesAddress"
renderProviderSecondarySalesAddress: Bytes

"Deprecated field, will be removed and is not populated for v3.2+ - see Project.renderProviderSecondarySalesBPS"
renderProviderSecondarySalesBPS: BigInt

"Address that receives primary sales platform fees, only for V3_Engine contracts"
enginePlatformProviderAddress: Bytes

"Percentage of primary sales allocated to the platform, only for V3_Engine contracts"
enginePlatformProviderPercentage: BigInt

"Deprecated field, will be removed and is not populated for v3.2+ - see Project.enginePlatformProviderSecondarySalesAddress"
enginePlatformProviderSecondarySalesAddress: Bytes

"Deprecated field, will be removed and is not populated for v3.2+ - see Project.enginePlatformProviderSecondarySalesBPS"
enginePlatformProviderSecondarySalesBPS: BigInt

"Default address that receives secondary sales render provider royalties when adding new projects (null for pre-V3 contracts)"
defaultRenderProviderSecondarySalesAddress: Bytes

Expand Down
41 changes: 12 additions & 29 deletions src/mapping-v3-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1531,18 +1531,14 @@ function refreshContract<T>(contract: T, timestamp: BigInt): Contract | null {
const renderProviderSecondarySalesBPS = contract.artblocksSecondarySalesBPS();
// detect if secondary sales payment info have changed
const platformSecondaryHaveChanged =
!contractEntity.renderProviderSecondarySalesAddress ||
!contractEntity.defaultRenderProviderSecondarySalesAddress ||
Address.fromBytes(
contractEntity.renderProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
contractEntity.defaultRenderProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
).toHexString() != renderProviderSecondarySalesAddress.toHexString() ||
!contractEntity.renderProviderSecondarySalesBPS ||
(contractEntity.renderProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
!contractEntity.defaultRenderProviderSecondarySalesBPS ||
(contractEntity.defaultRenderProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
renderProviderSecondarySalesBPS;
if (platformSecondaryHaveChanged) {
// @dev DEPRECATED-START ---
contractEntity.renderProviderSecondarySalesAddress = renderProviderSecondarySalesAddress;
contractEntity.renderProviderSecondarySalesBPS = renderProviderSecondarySalesBPS;
// @dev DEPRECATED-END ---
contractEntity.defaultRenderProviderSecondarySalesAddress = renderProviderSecondarySalesAddress;
contractEntity.defaultRenderProviderSecondarySalesBPS = renderProviderSecondarySalesBPS;
// secondary sales are defined on the projects after release of v3.2 core contracts
Expand Down Expand Up @@ -1588,28 +1584,22 @@ function refreshContract<T>(contract: T, timestamp: BigInt): Contract | null {
const enginePlatformProviderSecondarySalesBPS = preV3_2Contract.platformProviderSecondarySalesBPS();
// detect if secondary sales payment info have changed (to prevent unnecessary updates)
let platformSecondaryHaveChanged =
!contractEntity.renderProviderSecondarySalesAddress ||
!contractEntity.defaultRenderProviderSecondarySalesAddress ||
Address.fromBytes(
contractEntity.renderProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
contractEntity.defaultRenderProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
).toHexString() != renderProviderSecondarySalesAddress.toHexString() ||
!contractEntity.renderProviderSecondarySalesBPS ||
(contractEntity.renderProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
!contractEntity.defaultRenderProviderSecondarySalesBPS ||
(contractEntity.defaultRenderProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
renderProviderSecondarySalesBPS ||
!contractEntity.enginePlatformProviderSecondarySalesAddress ||
!contractEntity.defaultEnginePlatformProviderSecondarySalesAddress ||
Address.fromBytes(
contractEntity.enginePlatformProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
contractEntity.defaultEnginePlatformProviderSecondarySalesAddress as Bytes // @dev casting shouldn't be necessary, but is required to compile
).toHexString() !=
enginePlatformProviderSecondarySalesAddress.toHexString() ||
!contractEntity.enginePlatformProviderSecondarySalesBPS ||
(contractEntity.enginePlatformProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
!contractEntity.defaultEnginePlatformProviderSecondarySalesBPS ||
(contractEntity.defaultEnginePlatformProviderSecondarySalesBPS as BigInt) != // @dev casting shouldn't be necessary, but is required to compile
enginePlatformProviderSecondarySalesBPS;
if (platformSecondaryHaveChanged) {
// @dev DEPRECATED-START ---
contractEntity.renderProviderSecondarySalesAddress = renderProviderSecondarySalesAddress;
contractEntity.renderProviderSecondarySalesBPS = renderProviderSecondarySalesBPS;
contractEntity.enginePlatformProviderSecondarySalesAddress = enginePlatformProviderSecondarySalesAddress;
contractEntity.enginePlatformProviderSecondarySalesBPS = enginePlatformProviderSecondarySalesBPS;
// @dev DEPRECATED-END ---
// set defaults to the contract-level fields for pre-v3.2 contracts
contractEntity.defaultRenderProviderSecondarySalesAddress = renderProviderSecondarySalesAddress;
contractEntity.defaultRenderProviderSecondarySalesBPS = renderProviderSecondarySalesBPS;
Expand Down Expand Up @@ -1648,13 +1638,6 @@ function refreshContract<T>(contract: T, timestamp: BigInt): Contract | null {
// @dev no need to optimally detect if secondary sales payment info have changed, as we are setting defaults
// and not iterating over all projects on the contract

// backwards-compatible deprecated fields
// @dev DEPRECATED-START ---
contractEntity.renderProviderSecondarySalesAddress = defaultRenderProviderSecondarySalesAddress;
contractEntity.renderProviderSecondarySalesBPS = defaultRenderProviderSecondarySalesBPS;
contractEntity.enginePlatformProviderSecondarySalesAddress = defaultEnginePlatformProviderSecondarySalesAddress;
contractEntity.enginePlatformProviderSecondarySalesBPS = defaultEnginePlatformProviderSecondarySalesBPS;
// @dev DEPRECATED-END ---
// set defaults to the default values for v3.2+ contracts
contractEntity.defaultRenderProviderSecondarySalesAddress = defaultRenderProviderSecondarySalesAddress;
contractEntity.defaultRenderProviderSecondarySalesBPS = defaultRenderProviderSecondarySalesBPS;
Expand Down
12 changes: 6 additions & 6 deletions tests/subgraph/mapping-v3-core/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export function mockRefreshContractCalls(
"artblocksSecondarySalesAddress():(address)"
).returns([
ethereum.Value.fromAddress(
TEST_CONTRACT.renderProviderSecondarySalesAddress
TEST_CONTRACT.defaultRenderProviderSecondarySalesAddress
)
]);

Expand All @@ -214,7 +214,7 @@ export function mockRefreshContractCalls(
"artblocksSecondarySalesBPS():(uint256)"
).returns([
ethereum.Value.fromUnsignedBigInt(
TEST_CONTRACT.renderProviderSecondarySalesBPS
TEST_CONTRACT.defaultRenderProviderSecondarySalesBPS
)
]);

Expand Down Expand Up @@ -250,7 +250,7 @@ export function mockRefreshContractCalls(
"renderProviderSecondarySalesAddress():(address)"
).returns([
ethereum.Value.fromAddress(
TEST_CONTRACT.renderProviderSecondarySalesAddress
TEST_CONTRACT.defaultRenderProviderSecondarySalesAddress
)
]);

Expand All @@ -260,7 +260,7 @@ export function mockRefreshContractCalls(
"renderProviderSecondarySalesBPS():(uint256)"
).returns([
ethereum.Value.fromUnsignedBigInt(
TEST_CONTRACT.renderProviderSecondarySalesBPS
TEST_CONTRACT.defaultRenderProviderSecondarySalesBPS
)
]);

Expand Down Expand Up @@ -289,7 +289,7 @@ export function mockRefreshContractCalls(
"platformProviderSecondarySalesAddress():(address)"
).returns([
ethereum.Value.fromAddress(
TEST_CONTRACT.enginePlatformProviderSecondarySalesAddress
TEST_CONTRACT.defaultEnginePlatformProviderSecondarySalesAddress
)
]);

Expand All @@ -299,7 +299,7 @@ export function mockRefreshContractCalls(
"platformProviderSecondarySalesBPS():(uint256)"
).returns([
ethereum.Value.fromUnsignedBigInt(
TEST_CONTRACT.enginePlatformProviderSecondarySalesBPS
TEST_CONTRACT.defaultEnginePlatformProviderSecondarySalesBPS
)
]);

Expand Down
40 changes: 0 additions & 40 deletions tests/subgraph/mapping-v3-core/mapping-v3-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,6 @@ test(`${coreType}: Handles PlatformUpdated::artblocksSecondarySalesAddress - def
mockRefreshContractCalls(BigInt.fromI32(0), coreType, null);

// default value should be false
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
TEST_CONTRACT.renderProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -818,14 +810,6 @@ test(`${coreType}: Handles PlatformUpdated::artblocksSecondarySalesAddress - cha
handlePlatformUpdated(event);

// value in store should be updated
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
newAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -887,14 +871,6 @@ test(`${coreType}: Handles PlatformUpdated::artblocksSecondarySalesAddress - cha
handlePlatformUpdated(event);

// value in store should be updated
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
newAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -1184,14 +1160,6 @@ test(`${coreType}: Handles PlatformUpdated::artblocksSecondaryBPS - default valu
mockRefreshContractCalls(BigInt.fromI32(0), coreType, null);

// default value should be false
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesBPS",
TEST_CONTRACT.renderProviderSecondarySalesBPS.toString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -1230,14 +1198,6 @@ test(`${coreType}: Handles PlatformUpdated::artblocksSecondaryBPS - changed valu
handlePlatformUpdated(event);

// value in store should be updated
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesBPS",
newValue.toString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down
56 changes: 1 addition & 55 deletions tests/subgraph/mapping-v3-core/mapping-v3-engine-core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,14 +605,6 @@ test(`${coreType}: Handles PlatformUpdated::providerSalesAddresses - changed val
"renderProviderAddress",
newRenderProviderPrimarySalesAddress.toHexString()
);
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
newRenderProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand All @@ -625,14 +617,6 @@ test(`${coreType}: Handles PlatformUpdated::providerSalesAddresses - changed val
"enginePlatformProviderAddress",
newPlatformProviderPrimarySalesAddress.toHexString()
);
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"enginePlatformProviderSecondarySalesAddress",
newPlatformProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -729,14 +713,6 @@ test(`${coreType}: Handles PlatformUpdated::providerSalesAddresses - changed val
"renderProviderAddress",
newRenderProviderPrimarySalesAddress.toHexString()
);
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
newRenderProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand All @@ -749,14 +725,6 @@ test(`${coreType}: Handles PlatformUpdated::providerSalesAddresses - changed val
"enginePlatformProviderAddress",
newPlatformProviderPrimarySalesAddress.toHexString()
);
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"enginePlatformProviderSecondarySalesAddress",
newPlatformProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -799,14 +767,6 @@ test(`${coreType}: Handles PlatformUpdated::providerPrimaryPercentages - default
mockRefreshContractCalls(BigInt.fromI32(0), coreType, null);

// default value should be test contract value
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
TEST_CONTRACT.renderProviderSecondarySalesAddress.toHexString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down Expand Up @@ -1190,7 +1150,7 @@ test(`${coreType}: Handles PlatformUpdated::providerSecondaryBPS - default value
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesBPS",
TEST_CONTRACT.renderProviderSecondarySalesBPS.toString()
TEST_CONTRACT.defaultRenderProviderSecondarySalesBPS.toString()
);
// DEFAULT END ---
assert.fieldEquals(
Expand Down Expand Up @@ -1244,20 +1204,6 @@ test(`${coreType}: Handles PlatformUpdated::providerSecondaryBPS - changed value
handlePlatformUpdated(event);

// values in store should be updated
// DEPRECATED START ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesBPS",
newRenderProviderSecondarySalesBPS.toString()
);
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"enginePlatformProviderSecondarySalesBPS",
newPlatformProviderSecondarySalesBPS.toString()
);
// DEPRECATED END ---
assert.fieldEquals(
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ test(`${coreType}: Handles PlatformUpdated::providerPrimaryPercentages - default
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesAddress",
TEST_CONTRACT.renderProviderSecondarySalesAddress.toHexString()
TEST_CONTRACT.defaultRenderProviderSecondarySalesAddress.toHexString()
);
});

Expand Down Expand Up @@ -930,7 +930,7 @@ test(`${coreType}: Handles PlatformUpdated::providerSecondaryBPS - default value
CONTRACT_ENTITY_TYPE,
TEST_CONTRACT_ADDRESS.toHexString(),
"renderProviderSecondarySalesBPS",
TEST_CONTRACT.renderProviderSecondarySalesBPS.toString()
TEST_CONTRACT.defaultRenderProviderSecondarySalesBPS.toString()
);
});

Expand Down
Loading

0 comments on commit 1cd3cf6

Please sign in to comment.