Skip to content

Commit

Permalink
[api] Allow JSON no account signature in simulation (#15558)
Browse files Browse the repository at this point in the history
* [api] Allow JSON no account signature in simulation

* fixup: Remaining lint issues with signature
  • Loading branch information
gregnazario authored Jan 9, 2025
1 parent 3169527 commit 1eea32b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 17 deletions.
28 changes: 27 additions & 1 deletion api/doc/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -16427,6 +16427,9 @@
},
{
"$ref": "#/components/schemas/TransactionSignature_AccountSignature"
},
{
"$ref": "#/components/schemas/TransactionSignature_NoAccountSignature"
}
],
"discriminator": {
Expand All @@ -16436,7 +16439,8 @@
"multi_ed25519_signature": "#/components/schemas/TransactionSignature_MultiEd25519Signature",
"multi_agent_signature": "#/components/schemas/TransactionSignature_MultiAgentSignature",
"fee_payer_signature": "#/components/schemas/TransactionSignature_FeePayerSignature",
"single_sender": "#/components/schemas/TransactionSignature_AccountSignature"
"single_sender": "#/components/schemas/TransactionSignature_AccountSignature",
"no_account_signature": "#/components/schemas/TransactionSignature_NoAccountSignature"
}
}
},
Expand Down Expand Up @@ -16550,6 +16554,28 @@
}
]
},
"TransactionSignature_NoAccountSignature": {
"allOf": [
{
"type": "object",
"required": [
"type"
],
"properties": {
"type": {
"type": "string",
"enum": [
"no_account_signature"
],
"example": "no_account_signature"
}
}
},
{
"$ref": "#/components/schemas/NoAccountSignature"
}
]
},
"Transaction_BlockEpilogueTransaction": {
"allOf": [
{
Expand Down
14 changes: 14 additions & 0 deletions api/doc/spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12224,6 +12224,7 @@ components:
- $ref: '#/components/schemas/TransactionSignature_MultiAgentSignature'
- $ref: '#/components/schemas/TransactionSignature_FeePayerSignature'
- $ref: '#/components/schemas/TransactionSignature_AccountSignature'
- $ref: '#/components/schemas/TransactionSignature_NoAccountSignature'
discriminator:
propertyName: type
mapping:
Expand All @@ -12232,6 +12233,7 @@ components:
multi_agent_signature: '#/components/schemas/TransactionSignature_MultiAgentSignature'
fee_payer_signature: '#/components/schemas/TransactionSignature_FeePayerSignature'
single_sender: '#/components/schemas/TransactionSignature_AccountSignature'
no_account_signature: '#/components/schemas/TransactionSignature_NoAccountSignature'
TransactionSignature_AccountSignature:
allOf:
- type: object
Expand Down Expand Up @@ -12292,6 +12294,18 @@ components:
- multi_ed25519_signature
example: multi_ed25519_signature
- $ref: '#/components/schemas/MultiEd25519Signature'
TransactionSignature_NoAccountSignature:
allOf:
- type: object
required:
- type
properties:
type:
type: string
enum:
- no_account_signature
example: no_account_signature
- $ref: '#/components/schemas/NoAccountSignature'
Transaction_BlockEpilogueTransaction:
allOf:
- type: object
Expand Down
3 changes: 3 additions & 0 deletions api/types/src/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,6 +1191,7 @@ pub enum TransactionSignature {
MultiAgentSignature(MultiAgentSignature),
FeePayerSignature(FeePayerSignature),
SingleSender(AccountSignature),
NoAccountSignature(NoAccountSignature),
}

impl VerifyInput for TransactionSignature {
Expand All @@ -1201,6 +1202,7 @@ impl VerifyInput for TransactionSignature {
TransactionSignature::MultiAgentSignature(inner) => inner.verify(),
TransactionSignature::FeePayerSignature(inner) => inner.verify(),
TransactionSignature::SingleSender(inner) => inner.verify(),
TransactionSignature::NoAccountSignature(inner) => inner.verify(),
}
}
}
Expand All @@ -1217,6 +1219,7 @@ impl TryFrom<TransactionSignature> for TransactionAuthenticator {
TransactionSignature::SingleSender(sig) => {
TransactionAuthenticator::single_sender(sig.try_into()?)
},
TransactionSignature::NoAccountSignature(sig) => sig.try_into()?,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/indexer/src/models/signatures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl Signature {
None,
))
},
APITransactionSignature::NoAccountSignature(_) => Ok(vec![]),
}
}

Expand All @@ -106,6 +107,7 @@ impl Signature {
},
APITransactionSignature::FeePayerSignature(_) => String::from("fee_payer_signature"),
APITransactionSignature::SingleSender(_sig) => String::from("single_sender"),
APITransactionSignature::NoAccountSignature(_) => String::from("no_account_signature"),
}
}

Expand Down
36 changes: 20 additions & 16 deletions ecosystem/indexer-grpc/indexer-grpc-fullnode/src/convert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,16 +698,19 @@ pub fn convert_transaction_signature(
TransactionSignature::MultiAgentSignature(_) => transaction::signature::Type::MultiAgent,
TransactionSignature::FeePayerSignature(_) => transaction::signature::Type::FeePayer,
TransactionSignature::SingleSender(_) => transaction::signature::Type::SingleSender,
TransactionSignature::NoAccountSignature(_) => {
unreachable!("No account signature can't be committed onchain")
},
};

let signature = match signature {
TransactionSignature::Ed25519Signature(s) => {
transaction::signature::Signature::Ed25519(convert_ed25519_signature(s))
},
TransactionSignature::MultiEd25519Signature(s) => {
transaction::signature::Signature::MultiEd25519(convert_multi_ed25519_signature(s))
},
TransactionSignature::MultiAgentSignature(s) => {
TransactionSignature::Ed25519Signature(s) => Some(
transaction::signature::Signature::Ed25519(convert_ed25519_signature(s)),
),
TransactionSignature::MultiEd25519Signature(s) => Some(
transaction::signature::Signature::MultiEd25519(convert_multi_ed25519_signature(s)),
),
TransactionSignature::MultiAgentSignature(s) => Some(
transaction::signature::Signature::MultiAgent(transaction::MultiAgentSignature {
sender: Some(convert_account_signature(&s.sender)),
secondary_signer_addresses: s
Expand All @@ -720,9 +723,9 @@ pub fn convert_transaction_signature(
.iter()
.map(convert_account_signature)
.collect(),
})
},
TransactionSignature::FeePayerSignature(s) => {
}),
),
TransactionSignature::FeePayerSignature(s) => Some(
transaction::signature::Signature::FeePayer(transaction::FeePayerSignature {
sender: Some(convert_account_signature(&s.sender)),
secondary_signer_addresses: s
Expand All @@ -737,18 +740,19 @@ pub fn convert_transaction_signature(
.collect(),
fee_payer_address: s.fee_payer_address.to_string(),
fee_payer_signer: Some(convert_account_signature(&s.fee_payer_signer)),
})
},
TransactionSignature::SingleSender(s) => {
}),
),
TransactionSignature::SingleSender(s) => Some(
transaction::signature::Signature::SingleSender(transaction::SingleSender {
sender: Some(convert_account_signature(s)),
})
},
}),
),
TransactionSignature::NoAccountSignature(_) => None,
};

Some(transaction::Signature {
r#type: r#type as i32,
signature: Some(signature),
signature,
})
}

Expand Down

0 comments on commit 1eea32b

Please sign in to comment.