Skip to content

Commit 1905cd5

Browse files
Fixing conflict
2 parents 46342fa + 59c1a45 commit 1905cd5

7 files changed

Lines changed: 375 additions & 3 deletions

crates/contract/src/snapshots/mpc_contract__foreign_chains_metadata__tests__foreign_chains_metadata_borsh_schema__should_not_change.snap

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,11 @@ BorshSchemaContainer {
9090
"Aptos",
9191
"ForeignChain__Aptos",
9292
),
93+
(
94+
12,
95+
"Sui",
96+
"ForeignChain__Sui",
97+
),
9398
],
9499
},
95100
"ForeignChainRpcWhitelist": Struct {
@@ -139,6 +144,9 @@ BorshSchemaContainer {
139144
"ForeignChain__Starknet": Struct {
140145
fields: Empty,
141146
},
147+
"ForeignChain__Sui": Struct {
148+
fields: Empty,
149+
},
142150
"ForeignChain__Ton": Struct {
143151
fields: Empty,
144152
},

crates/contract/tests/sandbox/common.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ use near_account_id::AccountId;
2424
use near_mpc_contract_interface::types::{
2525
AptosAddress, AptosEvent, AptosExtractedValue, AptosExtractor, AptosFinality, AptosRpcRequest,
2626
AptosTxId, Curve, DomainConfig, DomainId, DomainPurpose, Protocol, ReconstructionThreshold,
27+
SuiAddress, SuiEvent, SuiExtractedValue, SuiExtractor, SuiFinality, SuiRpcRequest, SuiTxId,
2728
SupportedForeignChains, TonAddress, TonCellBody, TonExtractedValue, TonExtractor, TonFinality,
2829
TonLog, TonRpcRequest, TonTxId,
2930
};
@@ -826,6 +827,18 @@ pub fn aptos_extracted_values() -> Vec<ExtractedValue> {
826827
)]
827828
}
828829

830+
pub fn sui_extracted_values() -> Vec<ExtractedValue> {
831+
vec![ExtractedValue::SuiExtractedValue(SuiExtractedValue::Event(
832+
SuiEvent {
833+
package_id: SuiAddress([1; 32]),
834+
transaction_module: "omni_bridge".to_string(),
835+
sender: SuiAddress([2; 32]),
836+
type_tag: format!("0x{}::omni_bridge::InitTransfer", "01".repeat(32)),
837+
bcs: vec![0xde, 0xad, 0xbe, 0xef],
838+
},
839+
))]
840+
}
841+
829842
pub fn bnb_evm_request() -> ForeignChainRpcRequest {
830843
ForeignChainRpcRequest::Bnb(EvmRpcRequest {
831844
tx_id: EvmTxId([0xbb; 32]),
@@ -885,3 +898,11 @@ pub fn aptos_request() -> ForeignChainRpcRequest {
885898
extractors: vec![AptosExtractor::Event { event_index: 0 }],
886899
})
887900
}
901+
902+
pub fn sui_request() -> ForeignChainRpcRequest {
903+
ForeignChainRpcRequest::Sui(SuiRpcRequest {
904+
tx_id: SuiTxId([0xbb; 32]),
905+
finality: SuiFinality::Checkpointed,
906+
extractors: vec![SuiExtractor::Event { event_index: 0 }],
907+
})
908+
}

crates/contract/tests/sandbox/foreign_chain_request.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::sandbox::common::{
66
bitcoin_extracted_values, bitcoin_request, bnb_evm_request, bogus_ton_log_extracted_value,
77
ethereum_evm_request, evm_block_hash_extracted_values, hyper_evm_request, polygon_evm_request,
88
register_foreign_chain_configuration, sign_foreign_tx_response, starknet_extracted_values,
9-
starknet_request, ton_request,
9+
starknet_request, sui_extracted_values, sui_request, ton_request,
1010
};
1111
use near_mpc_contract_interface::method_names;
1212
use near_mpc_contract_interface::types::{
@@ -31,6 +31,7 @@ const SIGNATURE_TIMEOUT_BLOCKS: u64 = 200;
3131
#[case::hyper_evm(hyper_evm_request(), evm_block_hash_extracted_values())]
3232
#[case::ton(ton_request(), bogus_ton_log_extracted_value())]
3333
#[case::aptos(aptos_request(), aptos_extracted_values())]
34+
#[case::sui(sui_request(), sui_extracted_values())]
3435
#[tokio::test]
3536
async fn verify_foreign_transaction__should_succeed(
3637
#[case] rpc_request: ForeignChainRpcRequest,
@@ -205,6 +206,7 @@ async fn verify_foreign_transaction__should_fan_out_response_to_duplicates_from_
205206
#[case::hyper_evm(hyper_evm_request())]
206207
#[case::ton(ton_request())]
207208
#[case::aptos(aptos_request())]
209+
#[case::sui(sui_request())]
208210
#[tokio::test]
209211
async fn verify_foreign_transaction__should_reject_without_policy(
210212
#[case] rpc_request: ForeignChainRpcRequest,
@@ -253,6 +255,7 @@ async fn verify_foreign_transaction__should_reject_without_policy(
253255
#[case::hyper_evm(hyper_evm_request())]
254256
#[case::ton(ton_request())]
255257
#[case::aptos(aptos_request())]
258+
#[case::sui(sui_request())]
256259
#[tokio::test]
257260
async fn verify_foreign_transaction__should_timeout_without_response(
258261
#[case] rpc_request: ForeignChainRpcRequest,

crates/contract/tests/snapshots/abi__abi_has_not_changed.snap

Lines changed: 90 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,11 @@ expression: abi
251251
11,
252252
"Aptos",
253253
"ForeignChain__Aptos"
254+
],
255+
[
256+
12,
257+
"Sui",
258+
"ForeignChain__Sui"
254259
]
255260
]
256261
}
@@ -288,6 +293,9 @@ expression: abi
288293
"ForeignChain__Starknet": {
289294
"Struct": null
290295
},
296+
"ForeignChain__Sui": {
297+
"Struct": null
298+
},
291299
"ForeignChain__Ton": {
292300
"Struct": null
293301
},
@@ -2186,6 +2194,11 @@ expression: abi
21862194
11,
21872195
"Aptos",
21882196
"ForeignChain__Aptos"
2197+
],
2198+
[
2199+
12,
2200+
"Sui",
2201+
"ForeignChain__Sui"
21892202
]
21902203
]
21912204
}
@@ -2223,6 +2236,9 @@ expression: abi
22232236
"ForeignChain__Starknet": {
22242237
"Struct": null
22252238
},
2239+
"ForeignChain__Sui": {
2240+
"Struct": null
2241+
},
22262242
"ForeignChain__Ton": {
22272243
"Struct": null
22282244
},
@@ -3133,7 +3149,8 @@ expression: abi
31333149
"Polygon",
31343150
"HyperEvm",
31353151
"Ton",
3136-
"Aptos"
3152+
"Aptos",
3153+
"Sui"
31373154
]
31383155
},
31393156
"ForeignChainConfiguration": {
@@ -3288,6 +3305,18 @@ expression: abi
32883305
}
32893306
},
32903307
"additionalProperties": false
3308+
},
3309+
{
3310+
"type": "object",
3311+
"required": [
3312+
"Sui"
3313+
],
3314+
"properties": {
3315+
"Sui": {
3316+
"$ref": "#/definitions/SuiRpcRequest"
3317+
}
3318+
},
3319+
"additionalProperties": false
32913320
}
32923321
]
32933322
},
@@ -4809,6 +4838,66 @@ expression: abi
48094838
"StarknetTxId": {
48104839
"$ref": "#/definitions/StarknetFelt"
48114840
},
4841+
"SuiExtractor": {
4842+
"oneOf": [
4843+
{
4844+
"type": "object",
4845+
"required": [
4846+
"Event"
4847+
],
4848+
"properties": {
4849+
"Event": {
4850+
"type": "object",
4851+
"required": [
4852+
"event_index"
4853+
],
4854+
"properties": {
4855+
"event_index": {
4856+
"type": "integer",
4857+
"format": "uint64",
4858+
"minimum": 0.0
4859+
}
4860+
}
4861+
}
4862+
},
4863+
"additionalProperties": false
4864+
}
4865+
]
4866+
},
4867+
"SuiFinality": {
4868+
"description": "Sui has no reorgs; a transaction is final once it is included in a committee-certified checkpoint.",
4869+
"type": "string",
4870+
"enum": [
4871+
"Checkpointed"
4872+
]
4873+
},
4874+
"SuiRpcRequest": {
4875+
"type": "object",
4876+
"required": [
4877+
"extractors",
4878+
"finality",
4879+
"tx_id"
4880+
],
4881+
"properties": {
4882+
"extractors": {
4883+
"type": "array",
4884+
"items": {
4885+
"$ref": "#/definitions/SuiExtractor"
4886+
}
4887+
},
4888+
"finality": {
4889+
"$ref": "#/definitions/SuiFinality"
4890+
},
4891+
"tx_id": {
4892+
"$ref": "#/definitions/SuiTxId"
4893+
}
4894+
}
4895+
},
4896+
"SuiTxId": {
4897+
"description": "32-byte Sui transaction digest (Blake2b-256 of the signed transaction data). Sui APIs display it base58-encoded; here it is carried as raw bytes (hex in JSON).",
4898+
"type": "string",
4899+
"pattern": "^(?:[0-9A-Fa-f]{2})*$"
4900+
},
48124901
"SupportedForeignChains": {
48134902
"type": "array",
48144903
"items": {

0 commit comments

Comments
 (0)