1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use bitcoin::utils::{virtual_transaction_size, InputType, TransactionInputMetadata, TransactionOutputMetadata};
use cumulus_primitives_core::ParaId;
use frame_support::BoundedVec;
use hex_literal::hex;
use pallet_evm::AddressMapping;
use primitives::{
AccountId, Balance, CurrencyId, CurrencyId::Token, CurrencyInfo, Rate, Signature, VaultCurrencyPair,
BITCOIN_MAINNET, BITCOIN_REGTEST, BITCOIN_TESTNET, DOT, IBTC, INTR, KBTC, KINT, KSM,
};
use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};
use sc_service::ChainType;
use serde::{Deserialize, Serialize};
use serde_json::{map::Map, Value};
use sp_arithmetic::{FixedPointNumber, FixedU128};
use sp_consensus_aura::sr25519::AuthorityId as AuraId;
use sp_core::{crypto::UncheckedInto, sr25519, storage::Storage, Pair, Public, H160};
use sp_runtime::traits::{IdentifyAccount, Verify, Zero};
use std::str::FromStr;
pub mod interlay;
pub mod kintsugi;
pub mod testnet_interlay;
pub mod testnet_kintsugi;
pub use interlay::{InterlayChainSpec, InterlayDevChainSpec, InterlayDevGenesisExt};
pub use kintsugi::{KintsugiChainSpec, KintsugiDevChainSpec, KintsugiDevGenesisExt};
pub type DummyChainSpec = sc_service::GenericChainSpec<(), Extensions>;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecExtension, ChainSpecGroup)]
#[serde(deny_unknown_fields)]
pub struct Extensions {
pub relay_chain: String,
pub para_id: u32,
}
impl Extensions {
pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {
sc_chain_spec::get_extension(chain_spec.extensions())
}
}
type AccountPublic = <Signature as Verify>::Signer;
fn get_from_string<TPublic: Public>(src: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(src, None)
.expect("static values are valid; qed")
.public()
}
fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
get_from_string::<TPublic>(&format!("//{}", seed))
}
fn get_account_id_from_string(account_id: &str) -> AccountId {
AccountId::from_str(account_id).expect("account id is not valid")
}
fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId
where
AccountPublic: From<<TPublic::Pair as Pair>::Public>,
{
AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()
}
fn get_authority_keys_from_public_key(src: [u8; 32]) -> (AccountId, AuraId) {
(src.clone().into(), src.unchecked_into())
}
fn get_authority_keys_from_seed(seed: &str) -> (AccountId, AuraId) {
(
get_account_id_from_seed::<sr25519::Public>(seed),
get_from_seed::<AuraId>(seed),
)
}
const DEFAULT_MAX_DELAY_MS: u32 = 60 * 60 * 1000; const DEFAULT_DUST_VALUE: Balance = 1000;
const DEFAULT_BITCOIN_CONFIRMATIONS: u32 = 1;
const SECURE_BITCOIN_CONFIRMATIONS: u32 = 6;
fn expected_transaction_size() -> u32 {
virtual_transaction_size(
TransactionInputMetadata {
count: 4,
script_type: InputType::P2WPKHv0,
},
TransactionOutputMetadata {
num_op_return: 1,
num_p2pkh: 2,
num_p2sh: 0,
num_p2wpkh: 0,
},
)
}
pub const REVERT_BYTECODE: [u8; 5] = [0x60, 0x00, 0x60, 0x00, 0xFD];
pub fn endowed_evm_accounts() -> Vec<[u8; 20]> {
vec![
hex!["f39fd6e51aad88f6f4ce6ab8827279cfffb92266"],
hex!["70997970c51812dc3a010c7d01b50e0d17dc79c8"],
hex!["3c44cdddb6a900fa2b585dd299e03d12fa4293bc"],
hex!["90f79bf6eb2c4f870365e785982e1f101e93b906"],
hex!["15d34aaf54267db7d7c367839aaf71a00a2c6a65"],
hex!["9965507d1a55bcc2695c58ba16fb37d819b0a4dc"],
hex!["976ea74026e726554db657fa54763abd0c3a0aa9"],
hex!["14dc79964da2c08b23698b3d3cc7ca32193d9955"],
hex!["23618e81e3f5cdf7f54c3d65f7fbc0abf5b21e8f"],
hex!["a0ee7a142d267c1f36714e4a8f75612f20a79720"],
]
}