Skip to content

Commit 4c27fca

Browse files
authored
Merge branch 'refactor/accountId-changes' into fix-SVM-verification-program-id-err
2 parents e777199 + 5e8be5e commit 4c27fca

30 files changed

+1112
-931
lines changed

api/ue/v1/tx.pulsar.go

Lines changed: 208 additions & 207 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/ue/v1/types.pulsar.go

Lines changed: 257 additions & 181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

proto/ue/v1/tx.proto

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ message MsgDeployUEA {
6464
// signer is the Cosmos address initiating the tx (used for tx signing)
6565
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
6666

67-
// universal_account is the identifier of the owner account
68-
UniversalAccount universal_account = 2;
67+
// universal_account_id is the identifier of the owner account
68+
UniversalAccountId universal_account_id = 2;
6969

7070
// tx_hash is the hash of the transaction in which user locked the tokens
7171
string tx_hash = 3;
@@ -86,8 +86,8 @@ message MsgMintPC {
8686
// signer is the Cosmos address initiating the tx (used for tx signing)
8787
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
8888

89-
// universal_account is the identifier of the owner account
90-
UniversalAccount universal_account = 2;
89+
// universal_account_id is the identifier of the owner account
90+
UniversalAccountId universal_account_id = 2;
9191

9292
// tx_hash is the hash of the transaction in which user locked the tokens
9393
string tx_hash = 3;
@@ -104,8 +104,8 @@ message MsgExecutePayload {
104104
// signer is the Cosmos address initiating the tx (used for tx signing)
105105
string signer = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
106106

107-
// universal_account is the identifier of the owner account
108-
UniversalAccount universal_account = 2;
107+
// universal_account_id is the identifier of the owner account
108+
UniversalAccountId universal_account_id = 2;
109109

110110
// payload is the universal payload to be executed
111111
UniversalPayload universal_payload = 3;

proto/ue/v1/types.proto

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum VM_TYPE {
3030
}
3131

3232
// Signature verification types
33-
enum SignatureType {
33+
enum VerificationType {
3434
signedVerification = 0; // Signed verification using a signature
3535
universalTxVerification = 1; // Universal transaction verification
3636
}
@@ -49,17 +49,18 @@ message UniversalPayload {
4949
string max_priority_fee_per_gas = 6; // uint256 as string
5050
string nonce = 7; // uint256 as string
5151
string deadline = 8; // uint256 as string
52-
SignatureType sig_type = 9; // Type of signature verification
52+
VerificationType v_type = 9; // Type of verification to use before execution
5353
}
5454

55-
// UniversalAccount is the identifier of a owner account
56-
message UniversalAccount {
55+
// UniversalAccountId is the identifier of a owner account
56+
message UniversalAccountId {
5757
option (amino.name) = "ue/universal_account";
5858
option (gogoproto.equal) = true;
5959
option (gogoproto.goproto_stringer) = false;
6060

61-
string chain = 1; // chain is the caip2 identifier of the chain where the owner is located - (e.g. "eip155:1" for Ethereum mainnet)
62-
string owner = 2; // Owner's public key bytes or address in hex format
61+
string chain_namespace = 1; // chain_namespace is the CAIP-2 namespace of the chain where the owner is located (e.g. "eip155" for Ethereum)
62+
string chain_id = 2; // chain_id is the chain ID of the chain where the owner is located
63+
string owner = 3; // Owner's public key bytes or address in hex format
6364
}
6465

6566
// MethodConfig defines the configuration for a method that can be used for universal operations

x/ue/keeper/evm.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ import (
1212
func (k Keeper) CallFactoryToComputeUEAAddress(
1313
ctx sdk.Context,
1414
from, factoryAddr common.Address,
15-
universalAccount *types.UniversalAccount,
15+
universalAccountId *types.UniversalAccountId,
1616
) (*evmtypes.MsgEthereumTxResponse, error) {
1717
abi, err := types.ParseFactoryABI()
1818
if err != nil {
1919
return nil, errors.Wrap(err, "failed to parse factory ABI")
2020
}
2121

22-
abiUniversalAccount, err := types.NewAbiUniversalAccount(universalAccount)
22+
abiUniversalAccountId, err := types.NewAbiUniversalAccountId(universalAccountId)
2323
if err != nil {
2424
return nil, errors.Wrapf(err, "failed to create universal account")
2525
}
@@ -31,7 +31,7 @@ func (k Keeper) CallFactoryToComputeUEAAddress(
3131
factoryAddr,
3232
false, // commit
3333
"computeUEA",
34-
abiUniversalAccount,
34+
abiUniversalAccountId,
3535
)
3636
}
3737

@@ -40,14 +40,14 @@ func (k Keeper) CallFactoryToComputeUEAAddress(
4040
func (k Keeper) CallFactoryToDeployUEA(
4141
ctx sdk.Context,
4242
from, factoryAddr common.Address,
43-
universalAccount *types.UniversalAccount,
43+
universalAccountId *types.UniversalAccountId,
4444
) (*evmtypes.MsgEthereumTxResponse, error) {
4545
abi, err := types.ParseFactoryABI()
4646
if err != nil {
4747
return nil, errors.Wrap(err, "failed to parse factory ABI")
4848
}
4949

50-
abiUniversalAccount, err := types.NewAbiUniversalAccount(universalAccount)
50+
abiUniversalAccountId, err := types.NewAbiUniversalAccountId(universalAccountId)
5151
if err != nil {
5252
return nil, errors.Wrapf(err, "failed to create universal account")
5353
}
@@ -59,7 +59,7 @@ func (k Keeper) CallFactoryToDeployUEA(
5959
factoryAddr, // destination: FactoryV1 contract
6060
true, // commit = true (real tx, not simulation)
6161
"deployUEA",
62-
abiUniversalAccount,
62+
abiUniversalAccountId,
6363
)
6464
}
6565

x/ue/keeper/keeper_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import (
3636
"github.com/rollchains/pchain/app"
3737
module "github.com/rollchains/pchain/x/ue"
3838
"github.com/rollchains/pchain/x/ue/keeper"
39-
"github.com/rollchains/pchain/x/ue/keeper/mocks"
39+
"github.com/rollchains/pchain/x/ue/mocks"
4040
"github.com/rollchains/pchain/x/ue/types"
4141

4242
"github.com/ethereum/go-ethereum/accounts/abi"

x/ue/keeper/msg_deploy_uea.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
)
1212

1313
// updateParams is for updating params collections of the module
14-
func (k Keeper) DeployUEA(ctx context.Context, evmFrom common.Address, universalAccount *types.UniversalAccount, txHash string) ([]byte, error) {
14+
func (k Keeper) DeployUEA(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, txHash string) ([]byte, error) {
1515
sdkCtx := sdk.UnwrapSDKContext(ctx)
1616

1717
// EVM Call arguments
1818
factoryAddress := common.HexToAddress(types.FACTORY_PROXY_ADDRESS_HEX)
1919

2020
// RPC call verification to verify the gateway interaction tx on source chain
21-
err := k.utvKeeper.VerifyGatewayInteractionTx(ctx, universalAccount.Owner, txHash, universalAccount.Chain)
21+
err := k.utvKeeper.VerifyGatewayInteractionTx(ctx, universalAccountId.Owner, txHash, universalAccountId.GetCAIP2())
2222
if err != nil {
2323
return nil, errors.Wrapf(err, "failed to verify gateway interaction transaction")
2424
}
@@ -28,7 +28,7 @@ func (k Keeper) DeployUEA(ctx context.Context, evmFrom common.Address, universal
2828
sdkCtx,
2929
evmFrom,
3030
factoryAddress,
31-
universalAccount,
31+
universalAccountId,
3232
)
3333
if err != nil {
3434
return nil, err

x/ue/keeper/msg_execute_payload.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,25 @@ import (
1414
)
1515

1616
// updateParams is for updating params collections of the module
17-
func (k Keeper) ExecutePayload(ctx context.Context, evmFrom common.Address, universalAccount *types.UniversalAccount, universalPayload *types.UniversalPayload, signature string) error {
17+
func (k Keeper) ExecutePayload(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, universalPayload *types.UniversalPayload, signature string) error {
1818
sdkCtx := sdk.UnwrapSDKContext(ctx)
1919

20-
chainConfig, err := k.GetChainConfig(sdkCtx, universalAccount.Chain)
20+
// Get Caip2Identifier for the universal account
21+
caip2Identifier := universalAccountId.GetCAIP2()
22+
23+
chainConfig, err := k.GetChainConfig(sdkCtx, caip2Identifier)
2124
if err != nil {
22-
return errors.Wrapf(err, "failed to get chain config for chain %s", universalAccount.Chain)
25+
return errors.Wrapf(err, "failed to get chain config for chain %s", caip2Identifier)
2326
}
2427

2528
if !chainConfig.Enabled {
26-
return fmt.Errorf("chain %s is not enabled", universalAccount.Chain)
29+
return fmt.Errorf("chain %s is not enabled", caip2Identifier)
2730
}
2831

2932
factoryAddress := common.HexToAddress(types.FACTORY_PROXY_ADDRESS_HEX)
3033

3134
// Step 1: Compute smart account address
32-
receipt, err := k.CallFactoryToComputeUEAAddress(sdkCtx, evmFrom, factoryAddress, universalAccount)
35+
receipt, err := k.CallFactoryToComputeUEAAddress(sdkCtx, evmFrom, factoryAddress, universalAccountId)
3336
if err != nil {
3437
return err
3538
}

x/ue/keeper/msg_mint_pc.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ import (
1515
)
1616

1717
// updateParams is for updating params collections of the module
18-
func (k Keeper) MintPC(ctx context.Context, evmFrom common.Address, universalAccount *types.UniversalAccount, txHash string) error {
18+
func (k Keeper) MintPC(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, txHash string) error {
1919
sdkCtx := sdk.UnwrapSDKContext(ctx)
2020

2121
factoryAddress := common.HexToAddress(types.FACTORY_PROXY_ADDRESS_HEX)
2222

2323
// RPC call verification to get amount to be mint
24-
amountOfUsdLocked, usdDecimals, err := k.utvKeeper.VerifyAndGetLockedFunds(ctx, universalAccount.Owner, txHash, universalAccount.Chain)
24+
amountOfUsdLocked, usdDecimals, err := k.utvKeeper.VerifyAndGetLockedFunds(ctx, universalAccountId.Owner, txHash, universalAccountId.GetCAIP2())
2525
if err != nil {
2626
return errors.Wrapf(err, "failed to verify gateway interaction transaction")
2727
}
2828
amountToMint := ConvertUsdToPCTokens(&amountOfUsdLocked, usdDecimals)
2929

3030
// Calling factory contract to compute the UEA address
31-
receipt, err := k.CallFactoryToComputeUEAAddress(sdkCtx, evmFrom, factoryAddress, universalAccount)
31+
receipt, err := k.CallFactoryToComputeUEAAddress(sdkCtx, evmFrom, factoryAddress, universalAccountId)
3232
if err != nil {
3333
return err
3434
}

x/ue/keeper/msg_server.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (ms msgServer) DeployUEA(ctx context.Context, msg *types.MsgDeployUEA) (*ty
4343
return nil, errors.Wrapf(err, "failed to parse signer address")
4444
}
4545

46-
sa, err := ms.k.DeployUEA(ctx, evmFromAddress, msg.UniversalAccount, msg.TxHash)
46+
sa, err := ms.k.DeployUEA(ctx, evmFromAddress, msg.UniversalAccountId, msg.TxHash)
4747
if err != nil {
4848
return nil, err
4949
}
@@ -60,7 +60,7 @@ func (ms msgServer) MintPC(ctx context.Context, msg *types.MsgMintPC) (*types.Ms
6060
return nil, errors.Wrapf(err, "failed to parse signer address")
6161
}
6262

63-
err = ms.k.MintPC(ctx, evmFromAddress, msg.UniversalAccount, msg.TxHash)
63+
err = ms.k.MintPC(ctx, evmFromAddress, msg.UniversalAccountId, msg.TxHash)
6464
if err != nil {
6565
return nil, err
6666
}
@@ -75,7 +75,7 @@ func (ms msgServer) ExecutePayload(ctx context.Context, msg *types.MsgExecutePay
7575
return nil, errors.Wrapf(err, "failed to parse signer address")
7676
}
7777

78-
err = ms.k.ExecutePayload(ctx, evmFromAddress, msg.UniversalAccount, msg.UniversalPayload, msg.Signature)
78+
err = ms.k.ExecutePayload(ctx, evmFromAddress, msg.UniversalAccountId, msg.UniversalPayload, msg.Signature)
7979
if err != nil {
8080
return nil, err
8181
}

0 commit comments

Comments
 (0)