Skip to content

Commit

Permalink
Add AccountPermission
Browse files Browse the repository at this point in the history
  • Loading branch information
yinyiqian1 committed Nov 4, 2024
1 parent 50dbe3d commit dff8719
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/xrpl/protocol/detail/sfields.macro
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ TYPED_SFIELD(sfUnauthorize, ACCOUNT, 6)
TYPED_SFIELD(sfRegularKey, ACCOUNT, 8)
TYPED_SFIELD(sfNFTokenMinter, ACCOUNT, 9)
TYPED_SFIELD(sfEmitCallback, ACCOUNT, 10)
TYPED_SFIELD(sfOnBehalfOf, ACCOUNT, 11)

// account (uncommon)
TYPED_SFIELD(sfHookAccount, ACCOUNT, 16)
Expand Down
1 change: 1 addition & 0 deletions src/libxrpl/protocol/TxFormats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ TxFormats::TxFormats()
{sfTxnSignature, soeOPTIONAL},
{sfSigners, soeOPTIONAL}, // submit_multisigned
{sfNetworkID, soeOPTIONAL},
{sfOnBehalfOf, soeOPTIONAL},
};

#pragma push_macro("UNWRAP")
Expand Down
20 changes: 20 additions & 0 deletions src/xrpld/app/tx/detail/AMMCreate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,26 @@ AMMCreate::calculateBaseFee(ReadView const& view, STTx const& tx)
TER
AMMCreate::preclaim(PreclaimContext const& ctx)
{
// if (ctx.rules.enabled(featureAccountPermission))
// {
auto const onBehalfOfAccount =
ctx.view.read(keylet::account(ctx.tx[sfOnBehalfOf]));
if (!onBehalfOfAccount)
return terNO_ACCOUNT;

auto const accountPermissionKey =
keylet::accountPermission(ctx.tx[sfAccount], ctx.tx[sfOnBehalfOf]);
auto const sle = ctx.view.read(accountPermissionKey);
if (!sle)
return temMALFORMED; // todo: change error code

auto const permissions = sle->getFieldArray(sfPermissions);
for (auto const permission : permissions)
{
}

//}

auto const accountID = ctx.tx[sfAccount];
auto const amount = ctx.tx[sfAmount];
auto const amount2 = ctx.tx[sfAmount2];
Expand Down

0 comments on commit dff8719

Please sign in to comment.