@@ -87,8 +87,9 @@ func (h *OpenAccountsIntentHandler) PopulateMetadata(ctx context.Context, intent
8787 if err != nil {
8888 return err
8989 }
90- if ! common .IsCoreMint (mint ) {
91- return NewIntentValidationError ("only the core mint is supported" )
90+
91+ if typedProtoMetadata .AccountSet != transactionpb .OpenAccountsMetadata_USER && ! common .IsCoreMint (mint ) {
92+ return NewIntentDeniedError ("non-core mint account opening is only supported for the user account set" )
9293 }
9394
9495 intentRecord .IntentType = intent .OpenAccounts
@@ -104,10 +105,14 @@ func (h *OpenAccountsIntentHandler) CreatesNewUser(ctx context.Context, metadata
104105 return false , errors .New ("unexpected metadata proto message" )
105106 }
106107
107- return typedMetadata .AccountSet == transactionpb .OpenAccountsMetadata_USER , nil
108+ mint , err := common .GetBackwardsCompatMint (typedMetadata .Mint )
109+ if err != nil {
110+ return false , err
111+ }
112+
113+ return typedMetadata .AccountSet == transactionpb .OpenAccountsMetadata_USER && common .IsCoreMint (mint ), nil
108114}
109115
110- // todo: Not all multi-mint validation checks are implemented
111116func (h * OpenAccountsIntentHandler ) IsNoop (ctx context.Context , intentRecord * intent.Record , metadata * transactionpb.Metadata , actions []* transactionpb.Action ) (bool , error ) {
112117 typedMetadata := metadata .GetOpenAccounts ()
113118 if typedMetadata == nil {
@@ -119,9 +124,13 @@ func (h *OpenAccountsIntentHandler) IsNoop(ctx context.Context, intentRecord *in
119124 return false , NewActionValidationError (actions [0 ], "expected an open account action" )
120125 }
121126
127+ mint , err := common .GetBackwardsCompatMint (typedMetadata .Mint )
128+ if err != nil {
129+ return false , err
130+ }
131+
122132 var authorityToCheck * common.Account
123133 var expectedAccountType commonpb.AccountType
124- var err error
125134 switch typedMetadata .AccountSet {
126135 case transactionpb .OpenAccountsMetadata_USER :
127136 authorityToCheck , err = common .NewAccountFromPublicKeyString (intentRecord .InitiatorOwnerAccount )
@@ -145,18 +154,17 @@ func (h *OpenAccountsIntentHandler) IsNoop(ctx context.Context, intentRecord *in
145154 } else if err != nil {
146155 return false , err
147156 }
148- coreMintAccountInfoRecord , ok := accountInfoRecordByMint [common . CoreMintAccount .PublicKey ().ToBase58 ()]
157+ accountInfoRecord , ok := accountInfoRecordByMint [mint .PublicKey ().ToBase58 ()]
149158 if ! ok {
150159 return false , nil
151160 }
152- return coreMintAccountInfoRecord .AccountType == expectedAccountType , nil
161+ return accountInfoRecord .AccountType == expectedAccountType , nil
153162}
154163
155164func (h * OpenAccountsIntentHandler ) GetBalanceLocks (ctx context.Context , intentRecord * intent.Record , metadata * transactionpb.Metadata ) ([]* intentBalanceLock , error ) {
156165 return nil , nil
157166}
158167
159- // todo: Not all multi-mint validation checks are implemented
160168func (h * OpenAccountsIntentHandler ) AllowCreation (ctx context.Context , intentRecord * intent.Record , metadata * transactionpb.Metadata , actions []* transactionpb.Action ) error {
161169 typedMetadata := metadata .GetOpenAccounts ()
162170 if typedMetadata == nil {
@@ -1188,7 +1196,7 @@ func (h *PublicDistributionIntentHandler) PopulateMetadata(ctx context.Context,
11881196 return err
11891197 }
11901198 if ! common .IsCoreMint (mint ) {
1191- return NewIntentValidationError ("only the core mint is supported" )
1199+ return NewIntentDeniedError ("only the core mint is supported" )
11921200 }
11931201
11941202 source , err := common .NewAccountFromPublicKeyBytes (typedProtoMetadata .Source .Value )
0 commit comments