recordMigration
Contract: JBSingleTokenPaymentTerminalStore
Interface: IJBSingleTokenPaymentTerminalStore
- Step by step
- Code
- Errors
- Bug bounty
Records the migration of funds from this store.
The msg.sender must be an IJBSingleTokenPaymentTerminal
.
Definition
function recordMigration(uint256 _projectId)
external
override
nonReentrant
returns (uint256 balance) { ... }
- Arguments:
_projectId
is the ID of the project being migrated.
- The resulting function overrides a function definition from the
JBSingleTokenPaymentTerminalStore
interface. - The function returns the project's migrated balance, as a fixed point number with the same amount of decimals as its relative terminal.
Body
-
Get a reference to the project's current funding cycle.
// Get a reference to the project's current funding cycle.
JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);External references:
-
Make sure that migrating terminals is allowed by the current funding cycle.
// Migration must be allowed.
if (!_fundingCycle.terminalMigrationAllowed()) revert PAYMENT_TERMINAL_MIGRATION_NOT_ALLOWED();Library references:
JBFundingCycleMetadataResolver
.terminalMigrationAllowed(...)
-
Get a reference to the project's current balance. Set this to the value that the function will return.
// Return the current balance.
balance = balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId];Internal references:
-
Set the project's balance to 0 since funds are moving away from this terminal.
// Set the balance to 0.
balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] = 0;Internal references:
/**
@notice
Records the migration of funds from this store.
@dev
The msg.sender must be an IJBSingleTokenPaymentTerminal.
@param _projectId The ID of the project being migrated.
@return balance The project's migrated balance, as a fixed point number with the same amount of decimals as its relative terminal.
*/
function recordMigration(uint256 _projectId)
external
override
nonReentrant
returns (uint256 balance)
{
// Get a reference to the project's current funding cycle.
JBFundingCycle memory _fundingCycle = fundingCycleStore.currentOf(_projectId);
// Migration must be allowed.
if (!_fundingCycle.terminalMigrationAllowed()) revert PAYMENT_TERMINAL_MIGRATION_NOT_ALLOWED();
// Return the current balance.
balance = balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId];
// Set the balance to 0.
balanceOf[IJBSingleTokenPaymentTerminal(msg.sender)][_projectId] = 0;
}
String | Description |
---|---|
PAYMENT_TERMINAL_MIGRATION_NOT_ALLOWED | Thrown if the project's current funding cycle disallows terminal migrations. |
Category | Description | Reward |
---|---|---|
Optimization | Help make this operation more efficient. | 0.5ETH |
Low severity | Identify a vulnerability in this operation that could lead to an inconvenience for a user of the protocol or for a protocol developer. | 1ETH |
High severity | Identify a vulnerability in this operation that could lead to data corruption or loss of funds. | 5+ETH |